6 lines
1003 B
JavaScript
6 lines
1003 B
JavaScript
;(function(){"use strict";class IPullToRefresh extends HTMLElement{constructor(){super();}
|
|
connectedCallback(){this.dragDistance=150;this.swipeObserver.observe(this);}
|
|
handleEvent(e){requestAnimationFrame(()=>{this.style.setProperty("--_scroll",(window.scrollY>0)?0:window.scrollY);if(window.scrollY<this.dragDistance*-1){document.removeEventListener("scroll",this);document.documentElement.setAttribute("data-ips-pwa-refreshing","");setTimeout(()=>{location.reload();},16);}});}
|
|
setDragDistance(){this.dragDistance=Math.min(150,window.innerHeight*0.25);this.style.setProperty("--_limit",this.dragDistance);}
|
|
swipeObserver=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){document.addEventListener("scroll",this);this.setDragDistance();}else{document.removeEventListener("scroll",this);}});},{threshold:.1})}
|
|
ips.ui.registerWebComponent("pullToRefresh",IPullToRefresh);Debug.log(`Submitted the web component constructor, IPullToRefresh, for ${"pullToRefresh"}`);})();; |