PDA

View Full Version : Flipping cards in Carousel too quickly cancels cardswitch event



eishak
2 Aug 2011, 7:53 PM
I'll get consecutive beforecardswitch events fire before any cardswitch events fire if I swipe through a carousel too fast.

hitman01
21 Oct 2011, 1:01 PM
Any workaround for this bug?

TRob
8 Dec 2011, 2:33 PM
I ran into this as well. Quickest fix I could do was to set a flag in the beforecardswitch event and clear the flag in the cardswitch event. Then override onDrag and onDragEnd to do nothing if if the flag is set.



initComponent: function() {
.....
carousel.on( 'cardswitch', this.cardSwitched, this);
carousel.on( 'beforeCardSwitch', this.beforeCardSwitch, this);
.....
}

beforeCardSwitch: function() {
this.waitingForCardSwitch = true;
return true;
}

cardSwitched: function() {
this.waitingForCardSwitch = false;
}

onDrag: function() {
if (!this.waitingForCardSwitch) myview.superclass.onDrag.apply( this, arguments);
}



onDragEnd: function() {
if (!this.waitingForCardSwitch) myview.superclass.onDragEnd.apply( this, arguments);
}

This works well for me as I'm building panels on the fly for an infinite carousel so can't let the swipes get ahead of the panel creation. An alternate fix might be to remember the oldCard and activeItem state and pass them to the transitionEnd function inside updateCardPositions.