Jquery Waypoints Refresh

↘锁芯ラ 提交于 2019-11-29 07:28:45

Do not, do not, do not ever use the fixed position element as the waypoint. See all of the following closed issues on GitHub: #64, #44, #32, #26, #24, #13, #10, #4.

This is easily the most misunderstood thing about Waypoints, and is absolutely my fault in not communicating how Waypoints works well enough. I plan to make this much clearer in the next iteration of the plugin.

For anybody wondering: Waypoints works by looking at an element's page offset. But a fixed position element's page offset is constantly changing as the user scrolls. So whenever refresh is called, be it manually, by adding another waypoint, or by resizing the browser, the location of that waypoint changes to match wherever the user is at in the page scroll at the time. What you want is a normal static position element that doesn't leave the document flow to be the waypoint. In the example I give on the Waypoints project site, the waypoint is a wrapper element that stays in place, while the nav it wraps gains and loses fixed positioning via CSS. It's very easy for somebody that doesn't understand page offsets and CSS to do what the OP has done here, as it looks intuitive. Again this is something that will be addressed more directly in the documentation/examples in the future.

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