Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// the script name may sound a bit... y'know what...
// but i swear it DESCRIBES EXACTLY what this does!
// it checks whether position sticky is stuck or not!
// believe me JSRT!
(() => {
const observer = new IntersectionObserver(([entry]) => {
entry.target.nextElementSibling.classList.toggle('is-stuck', !entry.isIntersecting);
});
document.querySelectorAll('.sticky-stuck').forEach(el => {
const sentinel = document.createElement('div');
el.parentNode.insertBefore(sentinel, el);
observer.observe(sentinel);
});
})();