Javascript 使用动画隐藏滚动条上的导航栏

Javascript 使用动画隐藏滚动条上的导航栏,javascript,titanium,scrollview,navbar,Javascript,Titanium,Scrollview,Navbar,一些应用程序(facebook、9gag)具有此功能。当用户向上滚动时,导航栏会逐渐隐藏到消失的位置。然后,当用户向下滚动时,导航栏会逐渐显示(取决于滚动的速度) 我们试图通过调整滚动事件上导航视图的高度,在Tianium上实现这一点,但它滞后且非常缓慢: scrollView.addEventListener('touchstart',function(e){ boolScroll=true; }); scrollView.addEventListener('scroll'

一些应用程序(facebook、9gag)具有此功能。当用户向上滚动时,导航栏会逐渐隐藏到消失的位置。然后,当用户向下滚动时,导航栏会逐渐显示(取决于滚动的速度)

我们试图通过调整滚动事件上导航视图的高度,在Tianium上实现这一点,但它滞后且非常缓慢:

scrollView.addEventListener('touchstart',function(e){ 
        boolScroll=true;
});

scrollView.addEventListener('scroll',function(e){ 
    if(boolScroll){
        auxScroll=e.y;
        boolScroll=false;
    }
    var bh=bars.height;
    var sh=scrolls.height;

    if(auxScroll<e.y)//scrolling down
        if(bars.height>appHeight*0.08){
            bars.height=bh-appHeight*0.005; //rate for hiding
            if(scrolls.height<appHeight*0.7)
                scrolls.height=sh+appHeight*0.005;//same rate to increase the height of the scroll
        }

    if(auxScroll>e.y)//scrolling up
        if(bars.height<appHeight*0.08){
            bars.height=bh+appHeight*0.005; 
            if(scrolls.height>appHeight*0.7)
                scrolls.height=sh-appHeight*0.005;  
        }
});
scrollView.addEventListener('touchstart',函数(e){ boolScroll=true; }); scrollView.addEventListener('scroll',函数(e){ 如果(布尔斯克罗尔){ auxScroll=e.y; boolScroll=false; } var bh=钢筋高度; var sh=滚动高度; 如果(auxScrollappHeight*0.08){ bars.height=bh appHeight*0.005;//隐藏率 如果(滚动)高度问题。任何帮助将不胜感激


不知道你是否解决了这个问题,但我做了一个对我来说很有效的技巧(至少对导航栏是这样) 以下是片段:

self.addEventListener('scroll',function(e){
        if(e.contentOffset.y > 20) NavigationWindow.window.hideNavBar();
        if(e.contentOffset.y < 20) NavigationWindow.window.showNavBar();
    });
self.addEventListener('scroll',函数(e){
如果(e.contentOffset.y>20)NavigationWindow.window.hideNavBar();
如果(e.contentOffset.y<20)NavigationWindow.window.showNavBar();
});

NavigationWindow是Ti.UI.iOS.createNavigationWindow的实例,self可以是tableview、view、scrollview或窗口(在我的示例中)

这实际上是一个非常好的功能。Appcelerator刚刚解决了这个问题,应该可以在6.0版上使用。根据以下说明:

钛合金JIRA有一个未解决的问题,但今年没有人碰它:(