簡體   English   中英

使用鈦合金動畫在滾動條上隱藏導航欄

[英]Hide navigation bar on scroll with animation Titanium

某些應用(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;  
        }
});

我們也嘗試在視圖上使用平移動畫來執行此操作,但是仍然很慢。

有一個針對問題的iOS解決方案。 任何幫助,將不勝感激!

在此處輸入圖片說明

不知道您是否解決了這個問題,但是我做了一個對我來說很有用的技巧(至少對於導航欄來說)這是代碼段:

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或window(在我的示例中)

這實際上是一個非常不錯的功能。 Appcelerator剛解決了該問題,根據此票證,它應該在6.0版中可用: https : //jira.appcelerator.org/browse/TIMOB-23684

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM