From c994ee999473b6049c627cdaffd27d708cdbbecf Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 8 Apr 2015 10:48:40 -0400 Subject: [PATCH] Make zoom box handle overlaps properly, and position full-width tables better. --- unpacked/jax/output/CommonHTML/autoload/mtable.js | 2 +- unpacked/jax/output/CommonHTML/jax.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/autoload/mtable.js b/unpacked/jax/output/CommonHTML/autoload/mtable.js index 0b3f5fa5a..606f0866e 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mtable.js +++ b/unpacked/jax/output/CommonHTML/autoload/mtable.js @@ -450,7 +450,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { }); box.appendChild(table); var labels = HTML.Element("mjx-stack"); 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 = ""; if (shift) table.style[margin] = CHTML.Em(shift); // diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index f03958425..8dcd112ca 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -574,9 +574,17 @@ var node = HTML.addElement(span,"mjx-chtml"); 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 // - node.style.position = "absolute"; + style.position = "absolute"; var zW = node.offsetWidth, zH = node.offsetHeight, mH = math.firstChild.offsetHeight, mW = math.firstChild.offsetWidth; node.style.position = "";