On page refresh the impicit scroll waypoint (if not on top of page) does not get triggered

為{幸葍}努か 提交于 2020-01-06 14:05:47

问题


So I made a timer where it's possible to make an inview that is timed. That is a divs x% must be in view for at least y milliseconds.

For this I've forked https://github.com/imakewebthings/waypoints repo, see here: https://github.com/gaborbernat/waypoints

It all works okay, with a bug: on page refresh, the browser first renders the page, then scrolls where we previously were in the page. At waypoint creation time (page rendered) the vertical, down div in view waypoints gets triggered. However after the immidiate scroll the vertical, down box div out of view waypoint does not.

I've uploaded here a demo of this. http://primeranks.net/yeti/wp/demo.html Look into the console for log messages about messages callled.

The top div has this tracking added. If you load the page and scroll down all works fine. Now navigate to the bottom, and press refresh, the out of view is not called :(

Any ideas what's wrong?

All triggers above the current view gets triggered for in view, but the ones that scroll outside of the view has no out of view.


回答1:


So, I found a fix. The problem was that on waypoint creation the triggers fired. And in my initial implementation first the exit was triggered, then the enter. My fix was to switch the order of the creation, and now it works as expected.



来源:https://stackoverflow.com/questions/29326102/on-page-refresh-the-impicit-scroll-waypoint-if-not-on-top-of-page-does-not-get

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