【问题标题】:Waypoints - Trigger function for THIS element and not others with same class nameWaypoints - 触发此元素的功能,而不是其他具有相同类名的元素
【发布时间】:2019-08-15 16:27:43
【问题描述】:

我试图在每次看到课程时播放动画。我正在使用 Waypoints,网站是水平滚动的。我的代码淡出班级照片。我希望它在每张照片出现时触发。目前,当第一张照片在视野中时,它会触发所有照片淡出。

不知道怎么写,所以一次只发生一个。

var waypoint = new Waypoint({
    element: document.getElementsByClassName('photo'),
    handler: function(direction) {
        $(this.element).animate({"opacity":"0"}, 100);
    },
    context: document.getElementsByClassName('horizontal_scroll'),
    horizontal: true,
    offset: '50%'
});

【问题讨论】:

    标签: horizontal-scrolling jquery-waypoints


    【解决方案1】:

    在尝试了几次不同的迭代后,我得到了它:

    $(".photo_wide").waypoint(function(e) {
        $(this.element).animate({"opacity":"0"}, 100);
        }, {
        context: document.getElementsByClassName('horizontal_scroll'),
        horizontal: true,
        offset: "50%"
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 2018-09-17
      • 1970-01-01
      • 2018-01-15
      相关资源
      最近更新 更多