diff options
author | Pushkar Joshi | 2012-03-12 15:26:10 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-12 15:26:10 -0700 |
commit | 46b2e561fa6ca054cad58e4c372a598bbb7ee2c9 (patch) | |
tree | 38d1c8666098a10078834c1eaac3d455135bee12 /node_modules/montage/ui/scroller.reel/scroller.js | |
parent | 7b4b068cadc0af8ec7e930e1c2b429e945f96984 (diff) | |
parent | 69d90467865a1384725b2301901be2180c5a841f (diff) | |
download | ninja-46b2e561fa6ca054cad58e4c372a598bbb7ee2c9.tar.gz |
Merge branch 'master' into brushtool
Diffstat (limited to 'node_modules/montage/ui/scroller.reel/scroller.js')
-rw-r--r-- | node_modules/montage/ui/scroller.reel/scroller.js | 36 |
1 files changed, 15 insertions, 21 deletions
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, { | |||
126 | return this._momentumDuration; | 126 | return this._momentumDuration; |
127 | }, | 127 | }, |
128 | set: function (value) { | 128 | set: function (value) { |
129 | this._momentumDuration = value; | 129 | this._momentumDuration = isNaN(parseInt(value, 10)) ? 1 : parseInt(value, 10); |
130 | if (this._momentumDuration < 1) { | ||
131 | this._momentumDuration = 1; | ||
132 | } | ||
130 | } | 133 | } |
131 | }, | 134 | }, |
132 | 135 | ||
@@ -140,7 +143,10 @@ exports.Scroller = Montage.create(Component, { | |||
140 | return this._bouncingDuration; | 143 | return this._bouncingDuration; |
141 | }, | 144 | }, |
142 | set: function (value) { | 145 | set: function (value) { |
143 | this._bouncingDuration = value; | 146 | this._bouncingDuration = isNaN(parseInt(value, 10)) ? 1 : parseInt(value, 10); |
147 | if (this._bouncingDuration < 1) { | ||
148 | this._bouncingDuration = 1; | ||
149 | } | ||
144 | } | 150 | } |
145 | }, | 151 | }, |
146 | 152 | ||
@@ -162,7 +168,7 @@ exports.Scroller = Montage.create(Component, { | |||
162 | 168 | ||
163 | handleTranslateStart: { | 169 | handleTranslateStart: { |
164 | value: function(event) { | 170 | value: function(event) { |
165 | this._scrollBars.opacity = .5; | 171 | this._scrollBars.opacity = 0.5; |
166 | } | 172 | } |
167 | }, | 173 | }, |
168 | 174 | ||
@@ -179,9 +185,10 @@ exports.Scroller = Montage.create(Component, { | |||
179 | this._top = this._element.offsetTop; | 185 | this._top = this._element.offsetTop; |
180 | this._width = this._element.offsetWidth; | 186 | this._width = this._element.offsetWidth; |
181 | this._height = this._element.offsetHeight; | 187 | this._height = this._element.offsetHeight; |
188 | |||
182 | this._maxTranslateX = this._content.scrollWidth - this._width; | 189 | this._maxTranslateX = this._content.scrollWidth - this._width; |
183 | if (this._maxTranslateX < 0) { | 190 | if (this._maxTranslateX < 0) { |
184 | this._.maxTranslateX = 0; | 191 | this._maxTranslateX = 0; |
185 | } | 192 | } |
186 | this._maxTranslateY = this._content.offsetHeight - this._height; | 193 | this._maxTranslateY = this._content.offsetHeight - this._height; |
187 | if (this._maxTranslateY < 0) { | 194 | if (this._maxTranslateY < 0) { |
@@ -192,6 +199,7 @@ exports.Scroller = Montage.create(Component, { | |||
192 | this._maxTranslateX = delegateValue.x; | 199 | this._maxTranslateX = delegateValue.x; |
193 | this._maxTranslateY = delegateValue.y; | 200 | this._maxTranslateY = delegateValue.y; |
194 | } | 201 | } |
202 | |||
195 | switch (this._displayScrollbars) { | 203 | switch (this._displayScrollbars) { |
196 | case "horizontal": | 204 | case "horizontal": |
197 | this._scrollBars.displayHorizontal = true; | 205 | this._scrollBars.displayHorizontal = true; |
@@ -206,23 +214,9 @@ exports.Scroller = Montage.create(Component, { | |||
206 | this._scrollBars.displayVertical = true; | 214 | this._scrollBars.displayVertical = true; |
207 | break; | 215 | break; |
208 | case "auto": | 216 | case "auto": |
209 | if (this._maxTranslateX && this._maxTranslateY) { | 217 | // Only display the scroll bars if we can scroll in that direction |
210 | this._scrollBars.displayHorizontal = true; | 218 | this._scrollBars.displayHorizontal = !!this._maxTranslateX; |
211 | this._scrollBars.displayVertical = true; | 219 | this._scrollBars.displayVertical = !!this._maxTranslateY; |
212 | } else { | ||
213 | if (this._maxTranslateX) { | ||
214 | this._scrollBars.displayHorizontal = true; | ||
215 | this._scrollBars.displayVertical = false; | ||
216 | } else { | ||
217 | if (this._maxTranslateY) { | ||
218 | this._scrollBars.displayHorizontal = false; | ||
219 | this._scrollBars.displayVertical = true; | ||
220 | } else { | ||
221 | this._scrollBars.displayHorizontal = false; | ||
222 | this._scrollBars.displayVertical = false; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | break; | 220 | break; |
227 | case "none": | 221 | case "none": |
228 | this._scrollBars.displayHorizontal = false; | 222 | this._scrollBars.displayHorizontal = false; |