Skip to content

Instantly share code, notes, and snippets.

@jpurcell
Created April 1, 2011 19:25
Show Gist options
  • Save jpurcell/898695 to your computer and use it in GitHub Desktop.
Save jpurcell/898695 to your computer and use it in GitHub Desktop.
Fire on scroll direction change.
var scrollingUp = false;
var prevIndex = 1;
Ti.API.debug('init: scrolling down');
tableView.scrollToIndex(1);
tableView.addEventListener('scroll',function(e){
Ti.API.debug('prev '+prevIndex+', curr '+e.firstVisibleItem+', scrollingUp '+scrollingUp);
if (prevIndex > e.firstVisibleItem) {
if (!scrollingUp) {
Ti.API.debug('scrolling up');
scrollingUp = true;
}
} else if(prevIndex < e.firstVisibleItem) {
if (scrollingUp) {
Ti.API.debug('scrolling down');
scrollingUp = false;
}
}
prevIndex = e.firstVisibleItem;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment