@svelkit/delay
Version:
> a delay component for [svelte] (part of [svelkit])
3 lines (2 loc) • 2.88 kB
JavaScript
import{SvelteComponentDev as b,init as y,safe_not_equal as p,dispatch_dev as f,validate_slots as g,create_slot as D,update_slot as k,transition_in as u,transition_out as m,empty as R,insert_dev as E,group_outros as j,check_outros as S,detach_dev as P}from"svelte/internal";import{onDestroy as _}from"svelte";function d(o){let i;const c=o[4].default,e=D(c,o,o[3],null),l={c:function(){e&&e.c()},m:function(t,r){e&&e.m(t,r),i=!0},p:function(t,r){e&&(e.p&&r&8&&k(e,c,t,t[3],r,null,null))},i:function(t){if(i)return;u(e,t),i=!0},o:function(t){m(e,t),i=!1},d:function(t){e&&e.d(t)}};return f("SvelteRegisterBlock",{block:l,id:d.name,type:"if",source:"(29:0) {#if visible}",ctx:o}),l}function h(o){let i,c,e=o[0]&&d(o);const l={c:function(){e&&e.c(),i=R()},l:function(t){throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option")},m:function(t,r){e&&e.m(t,r),E(t,i,r),c=!0},p:function(t,[r]){t[0]?e?(e.p(t,r),r&1&&u(e,1)):(e=d(t),e.c(),u(e,1),e.m(i.parentNode,i)):e&&(j(),m(e,1,1,()=>{e=null}),S())},i:function(t){if(c)return;u(e),c=!0},o:function(t){m(e),c=!1},d:function(t){e&&e.d(t),t&&P(i)}};return f("SvelteRegisterBlock",{block:l,id:h.name,type:"component",source:"",ctx:o}),l}function N(o,i,c){let{$$slots:e={},$$scope:l}=i;g("Delay",e,["default"]);let{show:s=!0}=i,{ms:t=200}=i,r,a;_(()=>clearTimeout(a));const w=n=>{clearTimeout(a),c(0,r=!1),n&&(a=setTimeout(()=>{c(0,r=!0)},t))},v=["show","ms"];return Object.keys(i).forEach(n=>{!~v.indexOf(n)&&n.slice(0,2)!=="$$"&&console.warn(`<Delay> was created with unknown prop '${n}'`)}),o.$$set=n=>{"show"in n&&c(1,s=n.show),"ms"in n&&c(2,t=n.ms),"$$scope"in n&&c(3,l=n.$$scope)},o.$capture_state=()=>({onDestroy:_,show:s,ms:t,visible:r,timeoutRef:a,updateDelay:w}),o.$inject_state=n=>{"show"in n&&c(1,s=n.show),"ms"in n&&c(2,t=n.ms),"visible"in n&&c(0,r=n.visible),"timeoutRef"in n&&(a=n.timeoutRef)},i&&"$$inject"in i&&o.$inject_state(i.$$inject),o.$$.update=()=>{o.$$.dirty&2&&w(s)},[r,s,t,l,e]}class T extends b{constructor(o){super(o);y(this,o,N,h,p,{show:1,ms:2}),f("SvelteRegisterComponent",{component:this,tagName:"Delay",options:o,id:h.name})}get show(){throw new Error("<Delay>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set show(o){throw new Error("<Delay>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}get ms(){throw new Error("<Delay>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}set ms(o){throw new Error("<Delay>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'")}}export default T;
//# sourceMappingURL=delay.js.map