Make zoom box handle overlaps properly, and position full-width tables better.

This commit is contained in:
Davide P. Cervone 2015-04-08 10:48:40 -04:00
parent 02066cb7cc
commit c994ee9994
2 changed files with 10 additions and 2 deletions

View File

@ -450,7 +450,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
}); box.appendChild(table); }); box.appendChild(table);
var labels = HTML.Element("mjx-stack"); var labels = HTML.Element("mjx-stack");
table.style.display = "inline-table"; if (!table.style.width) table.style.width = "auto"; table.style.display = "inline-table"; if (!table.style.width) table.style.width = "auto";
labels.style.verticalAlign = table.style.verticalAlign = "top"; labels.style.verticalAlign = "top";
node.style.verticalAlign = ""; node.style.verticalAlign = "";
if (shift) table.style[margin] = CHTML.Em(shift); if (shift) table.style[margin] = CHTML.Em(shift);
// //

View File

@ -574,9 +574,17 @@
var node = HTML.addElement(span,"mjx-chtml"); var node = HTML.addElement(span,"mjx-chtml");
this.idPostfix = "-zoom"; jax.root.toCommonHTML(node); this.idPostfix = ""; this.idPostfix = "-zoom"; jax.root.toCommonHTML(node); this.idPostfix = "";
// //
// Adjust margins to prevent overlaps at the edges
//
var style = node.style, bbox = jax.root.CHTML;
if (bbox.t > bbox.h) style.marginTop = CHTML.Em(bbox.t-Math.max(bbox.h,CHTML.FONTDATA.lineH));
if (bbox.b > bbox.d) style.marginBottom = CHTML.Em(bbox.b-Math.max(bbox.d,CHTML.FONTDATA.lineD));
if (bbox.l < 0) style.paddingLeft = CHTML.Em(-bbox.l);
if (bbox.r > bbox.w) style.marginRight = CHTML.Em(bbox.r-bbox.w);
//
// Get height and width of zoomed math and original math // Get height and width of zoomed math and original math
// //
node.style.position = "absolute"; style.position = "absolute";
var zW = node.offsetWidth, zH = node.offsetHeight, var zW = node.offsetWidth, zH = node.offsetHeight,
mH = math.firstChild.offsetHeight, mW = math.firstChild.offsetWidth; mH = math.firstChild.offsetHeight, mW = math.firstChild.offsetWidth;
node.style.position = ""; node.style.position = "";