|
11 | 11 |
|
12 | 12 | ionic.views.Slider = ionic.views.View.inherit({
|
13 | 13 | initialize: function (options) {
|
| 14 | + var slider = this; |
| 15 | + |
14 | 16 | // utilities
|
15 | 17 | var noop = function() {}; // simple no operation function
|
16 | 18 | var offloadFn = function(fn) { setTimeout(fn || noop, 0) }; // offload a functions execution
|
@@ -254,8 +256,8 @@ ionic.views.Slider = ionic.views.View.inherit({
|
254 | 256 | switch (event.type) {
|
255 | 257 | case 'mousedown': this.start(event); break;
|
256 | 258 | case 'touchstart': this.start(event); break;
|
257 |
| - case 'touchmove': this.move(event); break; |
258 |
| - case 'mousemove': this.move(event); break; |
| 259 | + case 'touchmove': this.touchmove(event); break; |
| 260 | + case 'mousemove': this.touchmove(event); break; |
259 | 261 | case 'touchend': offloadFn(this.end(event)); break;
|
260 | 262 | case 'mouseup': offloadFn(this.end(event)); break;
|
261 | 263 | case 'webkitTransitionEnd':
|
@@ -301,10 +303,15 @@ ionic.views.Slider = ionic.views.View.inherit({
|
301 | 303 | document.addEventListener('mouseup', this, false);
|
302 | 304 | }
|
303 | 305 | },
|
304 |
| - move: function(event) { |
| 306 | + touchmove: function(event) { |
305 | 307 |
|
306 | 308 | // ensure swiping with one touch and not pinching
|
307 |
| - if ( event.touches.length > 1 || event.scale && event.scale !== 1) return |
| 309 | + // ensure sliding is enabled |
| 310 | + if (event.touches.length > 1 || |
| 311 | + event.scale && event.scale !== 1 || |
| 312 | + slider.slideIsDisabled) { |
| 313 | + return; |
| 314 | + } |
308 | 315 |
|
309 | 316 | if (options.disableScroll) event.preventDefault();
|
310 | 317 |
|
@@ -468,6 +475,12 @@ ionic.views.Slider = ionic.views.View.inherit({
|
468 | 475 | setup();
|
469 | 476 | };
|
470 | 477 |
|
| 478 | + this.enableSlide = function(shouldEnable) { |
| 479 | + if (arguments.length) { |
| 480 | + this.slideIsDisabled = !shouldEnable; |
| 481 | + } |
| 482 | + return !this.slideIsDisabled; |
| 483 | + }, |
471 | 484 | this.slide = function(to, speed) {
|
472 | 485 | // cancel slideshow
|
473 | 486 | stop();
|
|
0 commit comments