【问题标题】:Hide navigation bar on scroll with animation Titanium使用动画钛隐藏滚动导航栏
【发布时间】:2015-06-14 06:27:06
【问题描述】:

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

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

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;  
        }
});

我们也尝试过在视图上使用平移动画,但仍然很慢。

this 问题上有一个适用于 iOS 的解决方案。任何帮助将不胜感激!

【问题讨论】:

标签: javascript titanium scrollview navbar


【解决方案1】:

不知道你是否解决了这个问题,但我做了一个对我很有效的技巧(至少对于导航栏) 这是sn-p:

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

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

【讨论】:

    【解决方案2】:

    这实际上是一个非常好的功能。 Appcelerator 刚刚解决了这个问题,根据这张票应该可以在 6.0 版上使用:https://jira.appcelerator.org/browse/TIMOB-23684

    【讨论】:

      猜你喜欢
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      相关资源
      最近更新 更多