最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Wow.js offset equal to element height - Stack Overflow

programmeradmin1浏览0评论

According to the wow.js documentation I can set the bottom offset at which the animation will trigger:

  wow = new WOW(
    {
      boxClass:     'wow',      // default
      animateClass: 'animated', // default
      offset:       0,          // < --------------- This one
      mobile:       true,       // default
      live:         true        // default
    }
  )
  wow.init();

I have a .foo container <div class="foo wow fadeIn"></div> I want to animate when its bottom hits the bottom of the viewport i.e. it is fully on my screen. So I guess the offset should be equal to the .foo element height. Is there any way to specify this in the wow.js settings above?

According to the wow.js documentation I can set the bottom offset at which the animation will trigger:

  wow = new WOW(
    {
      boxClass:     'wow',      // default
      animateClass: 'animated', // default
      offset:       0,          // < --------------- This one
      mobile:       true,       // default
      live:         true        // default
    }
  )
  wow.init();

I have a .foo container <div class="foo wow fadeIn"></div> I want to animate when its bottom hits the bottom of the viewport i.e. it is fully on my screen. So I guess the offset should be equal to the .foo element height. Is there any way to specify this in the wow.js settings above?

Share Improve this question edited Mar 26, 2018 at 12:49 Carol Skelly 363k92 gold badges737 silver badges647 bronze badges asked Dec 29, 2014 at 13:30 sdvnksvsdvnksv 9,72819 gold badges64 silver badges119 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Since the bottom offset can be defined with a data-wow-offset attrubute I came up with this solution:

$(".wow").each(function() {
  var wowHeight = $(this).height();
  $(this).attr("data-wow-offset", wowHeight);
});

Hope this will help somebody. Also I'd be glad to know of a more elegant solution.

发布评论

评论列表(0)

  1. 暂无评论