-
17 Jul 2012 1:41 PM #1
Answered: Carousel listen for and intercept swipe event?
Answered: Carousel listen for and intercept swipe event?
In certain cases, I want to prevent a user from swiping my carousel in a certain direction . Is there a way to listen for swipe events on the carousel and intercept and prevent the default behavior?
-
Best Answer Posted by bluehipy
You can override the carousel class
The "swipe" is given by the drag start event:
Code:onDragStart: function(e) { var direction = this.getDirection(), absDeltaX = e.absDeltaX, absDeltaY = e.absDeltaY, directionLock = this.getDirectionLock(); this.isDragging = true; if (directionLock) { if ((direction === 'horizontal' && absDeltaX > absDeltaY) || (direction === 'vertical' && absDeltaY > absDeltaX)) { e.stopPropagation(); } else { this.isDragging = false; return; } } if (this.isAnimating) { this.getActiveCarouselItem().getTranslatable().stopAnimation(); } this.dragStartOffset = this.offset; this.dragDirection = 0; },
Check source here and implement your logic in a subclass
http://docs.sencha.com/touch/2-0/sou...ousel-Carousel
-
18 Jul 2012 12:44 AM #2
You can override the carousel class
The "swipe" is given by the drag start event:
Code:onDragStart: function(e) { var direction = this.getDirection(), absDeltaX = e.absDeltaX, absDeltaY = e.absDeltaY, directionLock = this.getDirectionLock(); this.isDragging = true; if (directionLock) { if ((direction === 'horizontal' && absDeltaX > absDeltaY) || (direction === 'vertical' && absDeltaY > absDeltaX)) { e.stopPropagation(); } else { this.isDragging = false; return; } } if (this.isAnimating) { this.getActiveCarouselItem().getTranslatable().stopAnimation(); } this.dragStartOffset = this.offset; this.dragDirection = 0; },
Check source here and implement your logic in a subclass
http://docs.sencha.com/touch/2-0/sou...ousel-Carousel
-
19 Jul 2012 7:40 AM #3
Thanks exactly what I needed.


Reply With Quote