【问题标题】:Animate jquery reel via scroll通过滚动动画 jquery 卷轴
【发布时间】:2019-06-24 01:30:48
【问题描述】:

我正在开发一个滚动应用程序——请求的功能之一是在用户滚动时为 jquery 卷轴设置动画——

我尝试触发播放 - 并在帧上停止功能 - 并将其链接到 scrollTop - 但它没有做任何事情。

http://jsfiddle.net/dxf17mbn/

var threesixty = $('#image').reel({
  image: 'http://test.vostrel.net/jquery.reel/example/object-movie-clockwise-sprite/f1-reel.jpg',
  speed: 0,
  frames: 35,
  cw: true,
  throwable: 1.2
});



console.log("threesixty", threesixty);

var $win = $(window);
$win.on('scroll', function() {
  var top = $win.scrollTop() / 3;

  console.log("top", top)

  var fraction = top / 3;

  $('#image')
    .trigger('play')
    .bind('frameChange', function() {
        console.log("frame change--")
      if ($(this).reel('frame') == 47) {
        $(this).trigger('stop');
      }
    });

});

【问题讨论】:

    标签: jquery scroll 360-degrees


    【解决方案1】:

    在对特定插件提出问题时,请务必提及,甚至提供指向其 API 的链接。

    只需将触发的事件从 play 更改为 stepRight 即可。您希望同时使用stepRightstepLeft,具体取决于用户是向上还是向下滚动。

    我还会从 scroll 回调中删除 frameChange 侦听器,因为您最终会为此事件添加大量重复的侦听器。

    【讨论】:

    • 谢谢它已经开始工作了——你如何检测滚动方向——jsfiddle.net/6513uLdm
    • jsfiddle.net/6513uLdm/1 -- 这看起来不错。我想这里唯一要考虑的是它是否在滚动期间覆盖了足够的帧 - 如果 stepRight 应该被触发两次?
    • 我很高兴你知道了。用传统的鼠标滚轮滚动肯定会触发不止一个滴答声。如果您使用滚动条,在移动设备中上下滑动或使用超级滚动鼠标,应该会更流畅
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    • 1970-01-01
    • 2011-01-08
    • 1970-01-01
    • 2011-11-08
    • 1970-01-01
    相关资源
    最近更新 更多