Hello,
I am trying to let the navbar slide up when scrolling a tableview down and have it slide down again when scrolling up. This is my code and it kind of works. Except for two things. Is there a better way of detecting what direction the table is scrolling?
- When I reach the bottom the navbar slides down.
- I get this warning: [WARN] New layout set while view [object TiUIView] animating: Will relayout after animation.
EventMessages.addEventListener ('scroll',function(e) { if (offset < e.contentOffset.y && offset > 0) { navbar.animate({top: -70, duration:50}, function(){ offset = e.contentOffset.y; }); } else { navbar.animate({top: 0, duration:50}, function(){ offset = e.contentOffset.y; }); } });
2 Answers
to remove the warning, provide a delay using setTimeout so that the animations dont overlap.
to determine direction, can't you check to see if the offset is increasing or decreasing?
well, i'm also trying to solve the problem. When i check the api document, i found Ti.UI.Window has a event swipe and this event has a property called direction which can tell your finger is swiping left/right/up/down. So i'm wondering maybe you can add your nvabar in the window, and listen to 'swipe' event of the window. i didn't try it, i'll do it later and keep you informed.
/kent
Your Answer
Think you can help? Login to answer this question!