From 2dc3146d1f21b7e4dacdb62493515a431e07420c Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 27 Jul 2013 05:16:56 -0500 Subject: [PATCH] cleanup scroll. --- lib/widget.js | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index b6b7734..1e1f494 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2633,19 +2633,13 @@ Element.prototype._getCoords = function(get) { , xl = xi + this._getWidth(get) , yi = this._getTop(get) , yl = yi + this._getHeight(get) + , base = this.childBase || 0 + , el = this , coords , v - , base - , cbase , notop , nobot; - // Find a scrollable ancestor if we have one. - var el = this; - while (el = el.parent) { - if (el.scrollable) break; - } - // Attempt to shrink the element base on the // size of the content and child elements. if (this.shrink) { @@ -2654,6 +2648,11 @@ Element.prototype._getCoords = function(get) { yi = coords.yi, yl = coords.yl; } + // Find a scrollable ancestor if we have one. + while (el = el.parent) { + if (el.scrollable) break; + } + // Check to make sure we're visible and // inside of the visible scroll area. // NOTE: Lists have a property where only @@ -2669,13 +2668,11 @@ Element.prototype._getCoords = function(get) { // Is above. return; } else { - // Is partially covered below. + // Is partially covered above. notop = true; - v = (this.parent.lpos.yi + 0) - yi; - //if (!this.itop) v += this.parent.itop; + v = this.parent.lpos.yi - yi; v += this.parent.itop - this.itop; - base = (this.childBase || 0) + v; - cbase = base; + base += v; yi += v; } } else if (yl > this.parent.lpos.yl - this.parent.ibottom) { @@ -2685,7 +2682,7 @@ Element.prototype._getCoords = function(get) { } else { // Is partially covered below. nobot = true; - v = yl - (this.parent.lpos.yl - 0); + v = yl - this.parent.lpos.yl; v += this.parent.ibottom - this.ibottom; yl -= v; } @@ -2700,8 +2697,7 @@ Element.prototype._getCoords = function(get) { xl: xl, yi: yi, yl: yl, - base: base != null ? base : this.childBase || 0, - cbase: cbase != null ? cbase : this.childBase || 0, + base: base, notop: notop, nobot: nobot }; @@ -2729,7 +2725,7 @@ Element.prototype.render = function() { , attr , ch , content = this._pcontent - , ci = this._clines.ci[coords.cbase] + , ci = this._clines.ci[coords.base] , battr , dattr , c @@ -2749,16 +2745,10 @@ Element.prototype.render = function() { // If we're in a scrollable text box, check to // see which attributes this line starts with. if (ci > 0) { - attr = this._clines.attr[Math.min(coords.cbase, this._clines.length - 1)]; + attr = this._clines.attr[Math.min(coords.base, this._clines.length - 1)]; } if (this.border) xi++, xl--, yi++, yl--; - /* - if (this.border) { - if (coords.notop) yi--; - if (coords.nobot) yl++; - } - */ // If we have padding/valign, that means the // content-drawing loop will skip a few cells/lines. @@ -2869,12 +2859,6 @@ Element.prototype.render = function() { } if (this.border) xi--, xl++, yi--, yl++; - /* - if (this.border) { - //if (coords.notop) yi++; - if (coords.nobot) yl--; - } - */ if (this.tpadding) { xi -= this.padding.left, xl += this.padding.right;