I used to listen to the scroll event and get e.currentPage from the scrollableview to know which photo i was on. With the latest SDK it noted that I should listen for the dragEnd event instead. The only problem with this is sometimes currentPage updates and other times it does not which is a big issue. I have not found a solution yet or maybe I am just doing something wrong. Can anyone confirm this is an issue? When running my code I would expect to get 0 on the first slide and increment by 1 each swipe but instead ill get 1,1,3,4,5,7. This is just an example and happens randomly.. Code snippet below:
var scrollView = Titanium.UI.createScrollableView({ views : imageViewArray, currentPage : 0, bottom : '50dp' }); scrollView.addEventListener('dragEnd', function(e) { alert('e.currentPage: ' + e.currentPage.toString()); });
2 Answers
Accepted Answer
According to the docs, it seems like maybe you should try using 'scrollEnd' instead of 'dragEnd'.
Prior to 2.1, the scroll event did not fire consistently on all platforms. On iOS and Mobile Web, it fired when scrolling ended, and on Android, it fired when drag ended. You can restore the pre-2.1 behavior by listening for the scrollEnd or dragEnd events instead.
http://docs.appcelerator.com/titanium/2.1/#!/api/Titanium.UI.ScrollableView
Also, it appears 'dragEnd' only works on Android and Mobile Web.
I tried it real quick with scrollEnd on iOS and it seemed to work fine.
I'm with the same issue, my ScrollableView has 4 items and when i alert the currentPage (fired by scrollEnd), this give to me 0-0-1-3
I tried with SDK 2.1.4GA and 3.0.0GA and no sucess. I'm desperated... it's a simple operation and wont work!
Your Answer
Think you can help? Login to answer this question!