jQuery Waypoints触发一次 [英] jQuery Waypoints Fire Once

查看:247
本文介绍了jQuery Waypoints触发一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 http://imakewebthings.com/jquery-waypoints 和 当用户向下滚动到类为div1的区域时,我需要执行一些操作.但是,我只需要触发一次,而不是每次用户滚动到该位置时都触发​​它. — 仅一次

I am using http://imakewebthings.com/jquery-waypoints and I need to do some action when the user scrolls down to the area with the class div1. However, I need it only fire once and not every time the user scrolls to that location. — only once

$('.div1').waypoint(function(direction) 
{
    alert(CARRY OUT MY ACTION);
});

这仅需要在该部分的第一个滚动中(向上或向下)进行.

This needs to only happen on the first scroll to that section — up or down.

推荐答案

triggerOnce()被替换为destroy(). 只需添加this.destroy().

triggerOnce() is replaced with destroy(). Just add this.destroy().

$('.div1').waypoint(function(direction){
    alert('CARRY OUT MY ACTION')
    this.destroy()
});

有关更多选项,请查看 Waypoint的API .

For more options check the API of Waypoints.

这篇关于jQuery Waypoints触发一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆