-
14 Mar 2013 2:14 AM #1
Answered: Picker determine animation
Answered: Picker determine animation
I need to change an item in one of the slots in the Picker component. When I do so while the slot is still animating, I get an error: "Uncaught TypeError: Cannot read property 'style' of undefined" which is obviously caused by changing an element which is currently being animated.
Is there a way to determine / listen to an event that indicates whether the slots are currently moving / animating?
Edit:
Listening to the 'pick' event indicates the end of the animation but when there is currently no selection / animation of the slot, I listen to the pick event forever and nothing happens.
So I need to determine whether there is any selection / animation going on in the slot.
-
Best Answer Posted by hermanvandermaas
I found that a picker slot has a scroller instance, on which you can listen to the "scroll" event to check if it is currently scrolling and if so, listen for the "scrollend" event to wait for the animation to complete:
Code:var firstslot = pickerinstance.query('pickerslot')[0]; firstslot.getScrollable().getScroller().on({ scope: this, scroll: function() { console.log('scroll'); }, scrollend: function() { console.log('scrollend'); } });
-
14 Mar 2013 4:27 AM #2
I found that a picker slot has a scroller instance, on which you can listen to the "scroll" event to check if it is currently scrolling and if so, listen for the "scrollend" event to wait for the animation to complete:
Code:var firstslot = pickerinstance.query('pickerslot')[0]; firstslot.getScrollable().getScroller().on({ scope: this, scroll: function() { console.log('scroll'); }, scrollend: function() { console.log('scrollend'); } });


Reply With Quote