This does the trick (and if you're copying my code, you'll need the tween.js library included in your scripts), but I also needed to add the if (running) since I'm starting the rAF call on every click, otherwise the rAF call keeps running and in this instance, it racks up every time I click. ![]() offsetHeight // when the page scrolls, do as little as possible, in this // case we're just registering a rAF callback to `checkSticky` getElementById ( 'sticky-header' ) // then record the current position, so when we cross the // boundary the `sticky` class can be toggled var boundary = stickyHeaderRef. get the sticky element with the id of `sticky-header`. Note that I'm applying the sticky class to the body element, I'll explain in a moment. Here's the documented code to track and apply the sticky class to fix the position of the navigation element.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |