2014-01-21 255 views

回答

7
/** 
* Header scroll control 
* When the user scrolls down the page hide the header, when they scroll up show it. 
*/ 
var lastScrollPosition; 

$(document).scroll(function() { 
    var scrollPosition = $(this).scrollTop(); 

    // Scrolling down 
    if (scrollPosition > lastScrollPosition){ 
    // If the header is currently showing 
    if (!$('[data-role=header].ui-fixed-hidden').length) { 
     $('[data-role=header]').toolbar('hide'); 
    } 
    } 

    // Scrolling up 
    else { 
    // If the header is currently hidden 
    if ($('[data-role=header].ui-fixed-hidden').length) { 
     $('[data-role=header]').toolbar('show'); 
    } 
    } 

    lastScrollPosition = scrollPosition; 
}); 
+2

謝謝你它完美的作品 –

相關問題