@svelkit/delay
Version:
> a delay component for [svelte] (part of [svelkit])
3 lines (2 loc) • 3.23 kB
JavaScript
;const internal=require("svelte/internal"),svelte=require("svelte");function create_if_block(o){let i;const c=o[4].default,e=internal.create_slot(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&&internal.update_slot(e,c,t,t[3],r,null,null))},i:function(t){if(i)return;internal.transition_in(e,t),i=!0},o:function(t){internal.transition_out(e,t),i=!1},d:function(t){e&&e.d(t)}};return internal.dispatch_dev("SvelteRegisterBlock",{block:l,id:create_if_block.name,type:"if",source:"(29:0) {#if visible}",ctx:o}),l}function create_fragment(o){let i,c,e=o[0]&&create_if_block(o);const l={c:function(){e&&e.c(),i=internal.empty()},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),internal.insert_dev(t,i,r),c=!0},p:function(t,[r]){t[0]?e?(e.p(t,r),r&1&&internal.transition_in(e,1)):(e=create_if_block(t),e.c(),internal.transition_in(e,1),e.m(i.parentNode,i)):e&&(internal.group_outros(),internal.transition_out(e,1,1,()=>{e=null}),internal.check_outros())},i:function(t){if(c)return;internal.transition_in(e),c=!0},o:function(t){internal.transition_out(e),c=!1},d:function(t){e&&e.d(t),t&&internal.detach_dev(i)}};return internal.dispatch_dev("SvelteRegisterBlock",{block:l,id:create_fragment.name,type:"component",source:"",ctx:o}),l}function instance(o,i,c){let{$$slots:e={},$$scope:l}=i;internal.validate_slots("Delay",e,["default"]);let{show:s=!0}=i,{ms:t=200}=i,r,a;svelte.onDestroy(()=>clearTimeout(a));const u=n=>{clearTimeout(a),c(0,r=!1),n&&(a=setTimeout(()=>{c(0,r=!0)},t))},f=["show","ms"];return Object.keys(i).forEach(n=>{!~f.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:svelte.onDestroy,show:s,ms:t,visible:r,timeoutRef:a,updateDelay:u}),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&&u(s)},[r,s,t,l,e]}class Delay extends internal.SvelteComponentDev{constructor(o){super(o);internal.init(this,o,instance,create_fragment,internal.safe_not_equal,{show:1,ms:2}),internal.dispatch_dev("SvelteRegisterComponent",{component:this,tagName:"Delay",options:o,id:create_fragment.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/>'")}}module.exports=Delay;
//# sourceMappingURL=delay.js.map