【问题标题】:jQuery Waypoints not firing at correct locationjQuery Waypoints 没有在正确的位置触发
【发布时间】:2014-06-10 09:59:49
【问题描述】:

我正在尝试设置三个带有偏移位置的航路点,第一个航路点工作得非常好并且在正确的偏移位置 (75%) 开火,但是位于 Flexslider Carousel 之后的第二个和第三个航路点不是在正确的偏移位置射击。由于 Carousel 改变了页面的高度尺寸,第二个和第三个航路点在页面向下滚动很多时触发,然后需要,因此增加了实际偏移位置。

我曾尝试致电$.waypoints('refresh'),但我没有任何运气。我的代码如下。

// first-flexslider
$(window).load(function() {
  $('#firstSlider').flexslider({
    animation: "slide",
    directionNav: false,
    controlNav: true,
  });
});
// second-flexslider
$(window).load(function() {
  $('#secondSlider').flexslider({
    animation: "slide",
    directionNav: false,
    controlNav: false,
  });
});
$('.prev, .next').on('click', function() {
  var href = $(this).attr('href');
  $('#secondSlider').flexslider(href)
  return false;
})
$(document).ready(function(){
  $.waypoints('refresh');
});
// waypoints
$(document).ready(function() {

  $('.wp1').waypoint(function() {
    $('.wp1').addClass('animated fadeInUp');
  }, {
    offset: '75%'
  });

  $('.wp2').waypoint(function() {
    $('.wp2').addClass('animated fadeInUp');
  }, {
    offset: '75%'
  });

  $('.wp3').waypoint(function() {
    $('.wp3').addClass('animated fadeInUpD');
  }, {
    offset: '75%'
  });

});

我希望找出解决这个问题的方法,并让第二和第三航点在正确的偏移位置 (75%) 开火。如果您需要更多信息,请告诉我。谢谢。

【问题讨论】:

    标签: javascript jquery html twitter-bootstrap jquery-waypoints


    【解决方案1】:

    Flexslider 有一个回调 API,您可以在其中执行各种操作后的函数:https://github.com/woothemes/FlexSlider/wiki/FlexSlider-Properties

    我会检查after 回调,可能还有start 回调并从那里调用刷新。例如:

    $('#secondSlider').flexslider({
      animation: "slide",
      directionNav: false,
      controlNav: false,
      after: function() {
        $.waypoints('refresh');
      }
    });
    

    【讨论】:

    • 嘿伙计,非常感谢您指出这一点。我通过使用start 回调调用了刷新,它就像一个梦一样工作。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 1970-01-01
    相关资源
    最近更新 更多