-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp-7044a6c4.entry.js
5 lines (5 loc) · 5.04 KB
/
p-7044a6c4.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,c as s,h as e,H as i,g as h}from"./p-0e3693b5.js";import{i as r}from"./p-94175f2e.js";import{h as a}from"./p-3e9fe89f.js";const o=class{constructor(e){t(this,e),this.refreshEvent=s(this,"dwc-refresh",7),this.pullEvent=s(this,"dwc-pull",7),this.dragging=!1,this.startY=0,this.currentY=0,this.loaded=!1,this.height=0,this.disabled=!1,this.iconArrow="dwc:arrow-down",this.iconRefresh="dwc:animated-spinner",this.threshold=80,this.thresholdMax=1/0,this.theme="primary",this.stage="initial",this.textPull="Pull down to refresh",this.textRelease="Release to refresh",this.textRefresh="Refreshing"}onDisabledChanged(t){this.activate(!t)}onStageChanged(t){const s=this.el.parentElement;["pull","release","refresh","initial"].forEach((t=>{s.removeAttribute(`data-refresher-target-${t}`)})),s.setAttribute(`data-refresher-target-${t}`,"")}connectedCallback(){this.el&&this.loaded&&this.activate(!this.disabled)}disconnectedCallback(){this.el&&this.loaded&&this.activate(!1)}componentWillLoad(){this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.activate(!this.disabled)}componentDidLoad(){this.loaded=!0}async finish(){this.startY=0,this.currentY=0,this.dragging=!1,this.stage="initial",this.height=0,this.pullEvent.emit(0)}activate(t){const s=this.el.parentElement;s.removeAttribute("data-refresher-target"),["pull","release","refresh","initial"].forEach((t=>{s.removeAttribute(`data-refresher-target-${t}`)})),t?(s.addEventListener("touchstart",this.handleStart,{passive:!0}),s.addEventListener("mousedown",this.handleStart,{passive:!0}),s.setAttribute("data-refresher-target",""),s.setAttribute(`data-refresher-target-${this.stage}`,"")):(s.removeEventListener("touchstart",this.handleStart),s.removeEventListener("mousedown",this.handleStart),this.finish())}handleStart(t){const s=this.el;if(!s||s&&s.parentElement.scrollTop>0)return;this.dragging=!0,t instanceof MouseEvent?this.startY=t.pageY:t instanceof TouchEvent&&(this.startY=t.touches[0].pageY),this.currentY=this.startY;const e=s.parentElement;e.addEventListener("touchmove",this.handleMove,{passive:!1}),e.addEventListener("mousemove",this.handleMove,{passive:!1}),e.addEventListener("touchend",this.handleEnd),e.addEventListener("mouseup",this.handleEnd),e.addEventListener("touchcancel",this.handleEnd),e.addEventListener("mouseleave",this.handleEnd)}handleMove(t){if(!this.dragging||"refresh"===this.stage)return;if(t instanceof MouseEvent?this.currentY=t.pageY:t instanceof TouchEvent&&(this.currentY=t.touches[0].pageY),this.currentY<this.startY)return;if(t.cancelable&&t.preventDefault(),this.currentY===this.startY&&!this.dragging)return this.stage="initial",this.height=0,void this.pullEvent.emit(0);const s=this.currentY-this.startY;s<this.threshold&&(this.stage="pull",this.height=s,this.pullEvent.emit(s)),s>this.threshold&&s<this.thresholdMax&&(this.stage="release",this.height=s,this.pullEvent.emit(s))}handleEnd(){const t=this.el.parentElement;t.removeEventListener("touchmove",this.handleMove),t.removeEventListener("mousemove",this.handleMove),t.removeEventListener("touchend",this.handleEnd),t.removeEventListener("mouseup",this.handleEnd),t.removeEventListener("touchcancel",this.handleEnd),t.removeEventListener("mouseleave",this.handleEnd),"refresh"!=this.stage&&("release"===this.stage?(this.height=this.threshold,this.pullEvent.emit(this.threshold),this.stage="refresh",this.refreshEvent.emit()):this.finish())}render(){const{src:t,pool:s,name:h}=r(this.iconArrow),{src:o,pool:n,name:c}=r(this.iconRefresh),l="release"===this.stage?this.textRelease:"refresh"===this.stage?this.textRefresh:this.textPull;return e(i,{key:"5c4cdbe77791665269d7efe71bd5493973dcf50a",class:a({"bbj-disabled":this.disabled,"bbj-initial":"initial"===this.stage,"bbj-pull":"pull"===this.stage,"bbj-release":"release"===this.stage,"bbj-refresh":"refresh"===this.stage})},e("div",{key:"dcee55816ad3d349bef61300e34d5936994b2596",part:"control",style:{height:`${this.height}px`}},e("div",{key:"878d2f947eb1585a4bbe7d7eca64f4a7bc0812ae",part:"content"},e("dwc-icon","refresh"!==this.stage?{key:"arrow",part:"icon",src:t,pool:s,name:h}:{key:"spinner",part:"icon",src:o,pool:n,name:c}),e("div",{key:"d9ba5f3c97eaa16b37b3dc7ba9516df2acf022e4",part:"text",innerHTML:l}))))}get el(){return h(this)}static get watchers(){return{disabled:["onDisabledChanged"],stage:["onStageChanged"]}}};o.style=":host{display:block}[part=control]{overflow:hidden}[part=content]{align-items:center;display:flex;flex-direction:column;gap:var(--dwc-space-s);height:100%;justify-content:center;width:100%}[part=icon]{transition:transform 150ms linear}:host([stage=release]) [part=icon]{transform:rotate(180deg)}:host([theme=primary]){color:var(--dwc-color-primary-text)}:host([theme=success]){color:var(--dwc-color-success-text)}:host([theme=warning]){color:var(--dwc-color-warning-text)}:host([theme=danger]){color:var(--dwc-color-danger-text)}:host([theme=info]){color:var(--dwc-color-info-text)}:host([theme=gray]){color:var(--dwc-color-gray-text)}";export{o as dwc_refresher}