ScrollView - scroll finished?
Hi everyone,
If I add a 'scroll' event listener to a ScrollView, is it possible to tell when the scroll has effectively finished?
Thanks,
Toby
1 Answer
-
In case it helps anyone else, here's what I currently have - this is adapted/simplified from my actual implementation, apologies if I've broken it in the process (it seems to be working for me though):
var lastCenter = ''; var scrollTimeout; scrollMap.addEventListener('scroll', function(e) { if (lastCenter != null) { var offset = Titanium.UI.currentWindow.scrollMap.contentOffset; if (e.dragging || (lastCenter.x == offset.x && lastCenter.y == offset.y)) { if (scrollTimeout != null) { clearTimeout(scrollTimeout); } scrollTimeout = setTimeout(scrollFinish, 100); } } lastCenter = scrollMap.contentOffset; }); Titanium.UI.currentWindow.add(scrollMap); Titanium.UI.currentWindow.scrollMap = scrollMap; lastCenter = Titanium.UI.currentWindow.scrollMap.contentOffset; function scrollFinish() { // Do some stuff after scrolling has finished. }