Fire resize during scroll, with throttle

PHOTO EMBED

Sat Aug 07 2021 00:39:18 GMT+0000 (Coordinated Universal Time)

Saved by @alexlam #liquid

<script>
var throttleWaiting = false;                 

function throttle (callback, limit) {
    return function () {                      
        if (!throttleWaiting) {                     
            callback.apply(this, arguments);  
            throttleWaiting = true;                  
            setTimeout(function () {          
                throttleWaiting = false;              
            }, limit);
        }
    }
}

  function fireResize() {
      throttle(function(){
       window.dispatchEvent(new Event('resize'));
      }, 250)();
  }
  document.addEventListener('scroll', fireResize, {passive: true});
</script>
content_copyCOPY