jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-mobile – jQuery Mobile:将页眉隐藏在向下滚动并在向上滚动时显示大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我们在许多移动应用程序中看到的一个常见问题是当用户向下@L_874_2@时标题消失,当它们向上@L_874_2@时,标题会出现.我们如何在jQuery Mobile中实现这一目标? (我在下面回答我自己的问题)
@H_419_8@解决方法
/**
 * 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;  
});
@H_673_11@

大佬总结

以上是大佬教程为你收集整理的jquery-mobile – jQuery Mobile:将页眉隐藏在向下滚动并在向上滚动时显示全部内容,希望文章能够帮你解决jquery-mobile – jQuery Mobile:将页眉隐藏在向下滚动并在向上滚动时显示所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。