基金会麦哲伦 - 检查它是否粘稠

时间:2014-05-26 18:40:15

标签: zurb-foundation sticky magellan

如果Magellan栏(或我添加的元素"data-magellan-expedition='fixed'")在滚动时是否粘滞,我如何检查JS?

我想添加一个类,如果它是粘性的。否则应删除该课程。

2 个答案:

答案 0 :(得分:1)

在我的SCSS中添加以下脚本结尾(使用其他脚本)然后使用.navstuck类为我工作:



<!--for Sticky Nav per http://codepen.io/zurbchris/pen/rxMaoX-->
      <script>
          $(document).foundation();
          $('.sticky').on('sticky.zf.stuckto:top', function(){
              $(this).addClass('navstuck');
          }).on('sticky.zf.unstuckfrom:top', function(){
              $(this).removeClass('navstuck');
          })
          console.log(Foundation.version);
      </script>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

当粘贴被激活时,div获得

的css attr
style="position: fixed; top: 0px;"

因此您可以使用它来添加类

if ($('#yourElement').css('position') == 'fixed')
{
  // true
}
相关问题