Fix the alignment function so that it handles overlapping on the left and right better, and so we don't have to do it in the linebreaking directly.

This commit is contained in:
Davide P. Cervone 2014-09-09 19:22:02 -04:00
parent ea42f427f6
commit a9c66b5cee
2 changed files with 3 additions and 20 deletions

View File

@ -92,7 +92,6 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
if (isTop && parent.type !== "mtd") {
if (SVG.linebreakWidth < SVG.BIGDIMEN) {svg.w = SVG.linebreakWidth}
else {svg.w = SVG.cwidth}
svg.lw = svg.w;
}
var state = {
@ -212,10 +211,6 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var align = this.SVGgetAlign(state,values),
shift = this.SVGgetShift(state,values,align);
//
// Add in space for the shift
//
line.x = shift;
//
// Set the Y offset based on previous depth, leading, and current height
//
if (state.n > 0) {
@ -226,8 +221,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
//
// Place the new line
//
svg.Align(line,align,0,state.Y);
svg.w = svg.lw; // in case a line extends past the right
svg.Align(line,align,0,state.Y,shift);
//
// Save the values needed for the future
//

View File

@ -889,20 +889,9 @@
this.childScale = svg.scale; this.childX = svg.x; this.childY = svg.y; this.n++;
return svg;
},
Align: function (svg,align,dx,dy) {
Align: function (svg,align,dx,dy,shift) {
dx = ({left: dx, center: (this.w - svg.w)/2, right: this.w - svg.w - dx})[align] || 0;
//
// If we extend to the left of the current contents,
// move the contents to the right and adjust the bounding box
//
if (dx < 0) {
if (this.element.childNodes.length) {
this.element.setAttribute("transform","translate("+Math.floor(-dx)+",0)");
var g = SVG.Element("g"); g.appendChild(this.element); this.element = g;
}
this.l -= dx; this.w -= dx; this.r -= dx; dx = 0;
}
this.Add(svg,dx,dy);
var w = this.w; this.Add(svg,dx+(shift||0),dy); this.w = w;
},
Clean: function () {
if (this.h === -SVG.BIGDIMEN) {this.h = this.d = this.l = 0}