mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
2 lines
2.3 KiB
JavaScript
2 lines
2.3 KiB
JavaScript
import{O,P as E,Q as R,R as q,o as S,c as T,V as u,z as p,W as v,X as g,k as W,a as y,Y as $}from"./index.js";function w(o){return o.scrollHeight}function z(o){return o.scrollWidth}function C(o,l){o.scrollTop=o.scrollHeight-l+o.scrollTop}function M(o,l){o.scrollLeft=o.scrollWidth-l+o.scrollLeft}const P=y("div",{class:"loading"},"Loading...",-1),_=y("div",{class:"no-more"},"No more.",-1),j=y("div",{class:"no-results"},"No results.",-1),x=y("div",{class:"error"},"Error.",-1),A=O({__name:"VueEternalLoading",props:{load:{required:!0,type:Function},isInitial:{required:!1,type:Boolean,default:!0},position:{required:!1,type:String,default:"default"},container:{required:!1,type:Object,default:null},margin:{required:!1,type:String,default:void 0}},emits:["update:isInitial"],setup(o,{emit:l}){const n=o,i=E();let s=E("loading"),t=E(n.isInitial),c=0;function d(){$(()=>{var e,r;n.position==="top"?C((e=n.container)!=null?e:document.documentElement,c):n.position==="left"&&M((r=n.container)!=null?r:document.documentElement,c)})}function V(e,r){return e===0?t.value?(I(),"no-results"):(k(),"no-more"):e!==void 0&&r!==void 0&&e<r?(k(),"no-more"):(t.value=!1,d(),f(),"loading")}function k(){t.value=!1,a("no-more"),d()}function I(){t.value=!1,a("no-results"),d()}function B(){t.value=!1,a("error"),d()}function F(){t.value=!0,a("loading"),f()}function h(){a("loading"),f()}function a(e){s.value=e}function L(){i.value&&m.unobserve(i.value)}function f(){i.value&&m.observe(i.value)}function N(){return new IntersectionObserver(([e])=>{var r,b;e.isIntersecting&&(n.position==="top"?c=w((r=n.container)!=null?r:document.documentElement):n.position==="left"&&(c=z((b=n.container)!=null?b:document.documentElement)),L(),n.load({loaded:V,noMore:k,noResults:I,error:B},{isFirstLoad:t.value}))},{root:n.container,threshold:0,rootMargin:n.margin})}let m;return typeof IntersectionObserver<"u"&&R(()=>{m&&L(),m=N(),f()},{flush:"post"}),q(()=>n.isInitial,e=>{e&&F()}),q(t,e=>{e||l("update:isInitial",!1)}),(e,r)=>(S(),T("div",{class:"vue-eternal-loading",ref_key:"rootRef",ref:i},[u(s)==="loading"?p(e.$slots,"loading",v(g({key:0},{isFirstLoad:u(t)})),()=>[P]):u(s)==="no-more"?p(e.$slots,"no-more",v(g({key:1},{retry:h})),()=>[_]):u(s)==="no-results"?p(e.$slots,"no-results",v(g({key:2},{retry:h})),()=>[j]):u(s)==="error"?p(e.$slots,"error",v(g({key:3},{retry:h})),()=>[x]):W("",!0)],512))}});export{A as G};
|