From 22a66cb6e243a3f1c867b62e3942fd2e828019d9 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 8 Mar 2012 13:56:09 -0800 Subject: integrating v0.7 montage into ninja Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/scroller.reel/scroller.js | 36 ++++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'node_modules/montage/ui/scroller.reel/scroller.js') diff --git a/node_modules/montage/ui/scroller.reel/scroller.js b/node_modules/montage/ui/scroller.reel/scroller.js index 2dfff059..b578807e 100644 --- a/node_modules/montage/ui/scroller.reel/scroller.js +++ b/node_modules/montage/ui/scroller.reel/scroller.js @@ -126,7 +126,10 @@ exports.Scroller = Montage.create(Component, { return this._momentumDuration; }, set: function (value) { - this._momentumDuration = value; + this._momentumDuration = isNaN(parseInt(value, 10)) ? 1 : parseInt(value, 10); + if (this._momentumDuration < 1) { + this._momentumDuration = 1; + } } }, @@ -140,7 +143,10 @@ exports.Scroller = Montage.create(Component, { return this._bouncingDuration; }, set: function (value) { - this._bouncingDuration = value; + this._bouncingDuration = isNaN(parseInt(value, 10)) ? 1 : parseInt(value, 10); + if (this._bouncingDuration < 1) { + this._bouncingDuration = 1; + } } }, @@ -162,7 +168,7 @@ exports.Scroller = Montage.create(Component, { handleTranslateStart: { value: function(event) { - this._scrollBars.opacity = .5; + this._scrollBars.opacity = 0.5; } }, @@ -179,9 +185,10 @@ exports.Scroller = Montage.create(Component, { this._top = this._element.offsetTop; this._width = this._element.offsetWidth; this._height = this._element.offsetHeight; + this._maxTranslateX = this._content.scrollWidth - this._width; if (this._maxTranslateX < 0) { - this._.maxTranslateX = 0; + this._maxTranslateX = 0; } this._maxTranslateY = this._content.offsetHeight - this._height; if (this._maxTranslateY < 0) { @@ -192,6 +199,7 @@ exports.Scroller = Montage.create(Component, { this._maxTranslateX = delegateValue.x; this._maxTranslateY = delegateValue.y; } + switch (this._displayScrollbars) { case "horizontal": this._scrollBars.displayHorizontal = true; @@ -206,23 +214,9 @@ exports.Scroller = Montage.create(Component, { this._scrollBars.displayVertical = true; break; case "auto": - if (this._maxTranslateX && this._maxTranslateY) { - this._scrollBars.displayHorizontal = true; - this._scrollBars.displayVertical = true; - } else { - if (this._maxTranslateX) { - this._scrollBars.displayHorizontal = true; - this._scrollBars.displayVertical = false; - } else { - if (this._maxTranslateY) { - this._scrollBars.displayHorizontal = false; - this._scrollBars.displayVertical = true; - } else { - this._scrollBars.displayHorizontal = false; - this._scrollBars.displayVertical = false; - } - } - } + // Only display the scroll bars if we can scroll in that direction + this._scrollBars.displayHorizontal = !!this._maxTranslateX; + this._scrollBars.displayVertical = !!this._maxTranslateY; break; case "none": this._scrollBars.displayHorizontal = false; -- cgit v1.2.3