Advertisement
artemsemkin

Kinsey template: Update ScrollTrigger when content container dimensions are changed

Jan 25th, 2024 (edited)
1,405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Update ScrollTrigger when content container
  3.  * dimensions are changed
  4.  */
  5. const ro = new ResizeObserver(debounce(() => {
  6.   ScrollTrigger.refresh();
  7.   console.log('Refresh triggers');
  8. }, 250));
  9.  
  10. document.addEventListener('arts/barba/transition/start', () => {
  11.   ro.unobserve(window.$pageContent[0]);
  12. });
  13.  
  14. document.addEventListener('DOMContentLoaded', () => {
  15.   ro.observe(window.$pageContent[0]);
  16. });
  17.  
  18. ro.observe(window.$pageContent[0]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement