Skip to content

Commit

Permalink
Only run thumb update while showing, otherwise scrollBounds may be un…
Browse files Browse the repository at this point in the history
…initialized.
  • Loading branch information
Kevin Schaaf committed May 30, 2012
1 parent b3c5122 commit 29f88d8
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions source/touch/Thumb.js
Expand Up @@ -22,38 +22,40 @@
this.update(inStrategy);
},
update: function(inStrategy) {
var d = this.dimension, o = this.offset;
var bd = this.scrollBounds[this.sizeDimension], sbd = this.scrollBounds[d];
var overs = 0, overp = 0, over = 0;
if (bd >= sbd) {
this.hide();
return;
}
if (inStrategy.isOverscrolling()) {
over = inStrategy.getOverScrollBounds()["over" + o];
overs = Math.abs(over);
overp = Math.max(over, 0);
}
var sbo = inStrategy[this.positionMethod]() - over;
// calc size & position
var bdc = bd - this.cornerSize;
var s = Math.floor((bd * bd / sbd) - overs);
s = Math.max(this.minSize, s);
var p = Math.floor((bdc * sbo / sbd) + overp);
p = Math.max(0, Math.min(bdc - this.minSize, p));
// apply thumb styling
this.needed = s < bd;
if (this.needed && this.hasNode()) {
if (this._pos !== p) {
this._pos = p;
enyo.dom.transformValue(this, this.translation, p + "px");
if (this.showing) {
var d = this.dimension, o = this.offset;
var bd = this.scrollBounds[this.sizeDimension], sbd = this.scrollBounds[d];
var overs = 0, overp = 0, over = 0;
if (bd >= sbd) {
this.hide();
return;
}
if (inStrategy.isOverscrolling()) {
over = inStrategy.getOverScrollBounds()["over" + o];
overs = Math.abs(over);
overp = Math.max(over, 0);
}
if (this._size !== s) {
this._size = s;
this.node.style[d] = this.domStyles[d] = s + "px";
var sbo = inStrategy[this.positionMethod]() - over;
// calc size & position
var bdc = bd - this.cornerSize;
var s = Math.floor((bd * bd / sbd) - overs);
s = Math.max(this.minSize, s);
var p = Math.floor((bdc * sbo / sbd) + overp);
p = Math.max(0, Math.min(bdc - this.minSize, p));
// apply thumb styling
this.needed = s < bd;
if (this.needed && this.hasNode()) {
if (this._pos !== p) {
this._pos = p;
enyo.dom.transformValue(this, this.translation, p + "px");
}
if (this._size !== s) {
this._size = s;
this.node.style[d] = this.domStyles[d] = s + "px";
}
} else {
this.hide();
}
} else {
this.hide();
}
},
// implement set because showing is not changed while
Expand Down

0 comments on commit 29f88d8

Please sign in to comment.