jquery waypoints fire once

匿名 (未验证) 提交于 2019-12-03 08:42:37

问题:

Doing some quick work using http://imakewebthings.com/jquery-waypoints I need to do some action when the user scrolls down to area class div1 but need it only to be done 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.

回答1:

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

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

For more options check the API of Waypoints.



回答2:

If you pass a second parameter to the waypoint() function, you can include an object of configuration options. Setting the triggerOnce option to true will make the plugin behave the way you'd like.

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


回答3:

In the new API, it seems that there is no triggerOnce option anymore, but still can be used the waypoint.disable() method after the first call



转载请标明出处:jquery waypoints fire once
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!