masoneffect 1.0.30 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +320 -231
- package/dist/core/count/index.d.ts +52 -0
- package/dist/core/count/index.d.ts.map +1 -0
- package/dist/core/index.d.ts +15 -97
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/textToParticle/index.d.ts +103 -0
- package/dist/core/textToParticle/index.d.ts.map +1 -0
- package/dist/count/core/count/index.d.ts +52 -0
- package/dist/count/core/count/index.d.ts.map +1 -0
- package/dist/count/core/index.d.ts +18 -0
- package/dist/count/core/index.d.ts.map +1 -0
- package/dist/count/core/textToParticle/index.d.ts +103 -0
- package/dist/count/core/textToParticle/index.d.ts.map +1 -0
- package/dist/count/index.cjs +1 -0
- package/dist/count/index.d.ts +16 -0
- package/dist/count/index.d.ts.map +1 -0
- package/dist/count/index.mjs +1 -0
- package/dist/count/index.umd.d.ts +7 -0
- package/dist/count/index.umd.d.ts.map +1 -0
- package/dist/count/react/MasonEffect.d.ts +32 -0
- package/dist/count/react/MasonEffect.d.ts.map +1 -0
- package/dist/count/react/count/Count.d.ts +19 -0
- package/dist/count/react/count/Count.d.ts.map +1 -0
- package/dist/count/react/count/index.d.ts +5 -0
- package/dist/count/react/count/index.d.ts.map +1 -0
- package/dist/count/react/index.d.ts +12 -0
- package/dist/count/react/index.d.ts.map +1 -0
- package/dist/count/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/count/react/textToParticle/index.d.ts +4 -0
- package/dist/count/react/textToParticle/index.d.ts.map +1 -0
- package/dist/count/svelte/count/index.d.ts +2 -0
- package/dist/count/svelte/count/index.d.ts.map +1 -0
- package/dist/count/svelte/index.d.ts +8 -0
- package/dist/count/svelte/index.d.ts.map +1 -0
- package/dist/count/svelte/textToParticle/index.d.ts +2 -0
- package/dist/count/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/count/vue/count/index.d.ts +2 -0
- package/dist/count/vue/count/index.d.ts.map +1 -0
- package/dist/count/vue/index.d.ts +8 -0
- package/dist/count/vue/index.d.ts.map +1 -0
- package/dist/count/vue/textToParticle/index.d.ts +2 -0
- package/dist/count/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/react/core/count/index.d.ts +51 -0
- package/dist/react/core/index.d.ts +15 -97
- package/dist/react/core/textToParticle/index.d.ts +102 -0
- package/dist/react/count/Count.d.ts +19 -0
- package/dist/react/count/Count.d.ts.map +1 -0
- package/dist/react/count/core/count/index.d.ts +52 -0
- package/dist/react/count/core/count/index.d.ts.map +1 -0
- package/dist/react/count/core/index.d.ts +18 -0
- package/dist/react/count/core/index.d.ts.map +1 -0
- package/dist/react/count/core/textToParticle/index.d.ts +103 -0
- package/dist/react/count/core/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/index.cjs +1 -0
- package/dist/react/count/index.d.ts +16 -0
- package/dist/react/count/index.d.ts.map +1 -0
- package/dist/react/count/index.mjs +1 -0
- package/dist/react/count/index.umd.d.ts +7 -0
- package/dist/react/count/index.umd.d.ts.map +1 -0
- package/dist/react/count/react/MasonEffect.d.ts +32 -0
- package/dist/react/count/react/MasonEffect.d.ts.map +1 -0
- package/dist/react/count/react/count/Count.d.ts +19 -0
- package/dist/react/count/react/count/Count.d.ts.map +1 -0
- package/dist/react/count/react/count/index.d.ts +5 -0
- package/dist/react/count/react/count/index.d.ts.map +1 -0
- package/dist/react/count/react/index.d.ts +12 -0
- package/dist/react/count/react/index.d.ts.map +1 -0
- package/dist/react/count/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/count/react/textToParticle/index.d.ts +4 -0
- package/dist/react/count/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/svelte/count/index.d.ts +2 -0
- package/dist/react/count/svelte/count/index.d.ts.map +1 -0
- package/dist/react/count/svelte/index.d.ts +8 -0
- package/dist/react/count/svelte/index.d.ts.map +1 -0
- package/dist/react/count/svelte/textToParticle/index.d.ts +2 -0
- package/dist/react/count/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/vue/count/index.d.ts +2 -0
- package/dist/react/count/vue/count/index.d.ts.map +1 -0
- package/dist/react/count/vue/index.d.ts +8 -0
- package/dist/react/count/vue/index.d.ts.map +1 -0
- package/dist/react/count/vue/textToParticle/index.d.ts +2 -0
- package/dist/react/count/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/react/index.cjs +12 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.mjs +2 -1
- package/dist/react/react/count/Count.d.ts +18 -0
- package/dist/react/react/count/index.d.ts +4 -0
- package/dist/react/react/index.d.ts +11 -2
- package/dist/react/react/textToParticle/TextToParticle.d.ts +14 -0
- package/dist/react/react/textToParticle/index.d.ts +3 -0
- package/dist/react/svelte/count/index.d.ts +1 -0
- package/dist/react/svelte/index.d.ts +5 -3
- package/dist/react/svelte/textToParticle/index.d.ts +1 -0
- package/dist/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/textToParticle/core/count/index.d.ts +52 -0
- package/dist/react/textToParticle/core/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/core/index.d.ts +18 -0
- package/dist/react/textToParticle/core/index.d.ts.map +1 -0
- package/dist/react/textToParticle/core/textToParticle/index.d.ts +103 -0
- package/dist/react/textToParticle/core/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/index.cjs +1 -0
- package/dist/react/textToParticle/index.d.ts +16 -0
- package/dist/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/index.mjs +1 -0
- package/dist/react/textToParticle/index.umd.d.ts +7 -0
- package/dist/react/textToParticle/index.umd.d.ts.map +1 -0
- package/dist/react/textToParticle/react/MasonEffect.d.ts +32 -0
- package/dist/react/textToParticle/react/MasonEffect.d.ts.map +1 -0
- package/dist/react/textToParticle/react/count/Count.d.ts +19 -0
- package/dist/react/textToParticle/react/count/Count.d.ts.map +1 -0
- package/dist/react/textToParticle/react/count/index.d.ts +5 -0
- package/dist/react/textToParticle/react/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/react/index.d.ts +12 -0
- package/dist/react/textToParticle/react/index.d.ts.map +1 -0
- package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/textToParticle/react/textToParticle/index.d.ts +4 -0
- package/dist/react/textToParticle/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/count/index.d.ts +2 -0
- package/dist/react/textToParticle/svelte/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/index.d.ts +8 -0
- package/dist/react/textToParticle/svelte/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/textToParticle/index.d.ts +2 -0
- package/dist/react/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/count/index.d.ts +2 -0
- package/dist/react/textToParticle/vue/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/index.d.ts +8 -0
- package/dist/react/textToParticle/vue/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/textToParticle/index.d.ts +2 -0
- package/dist/react/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/react/vue/count/index.d.ts +1 -0
- package/dist/react/vue/index.d.ts +5 -3
- package/dist/react/vue/textToParticle/index.d.ts +1 -0
- package/dist/svelte/count/index.cjs +1 -0
- package/dist/svelte/count/index.d.ts +163 -0
- package/dist/svelte/count/index.mjs +659 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.d.ts +88 -29
- package/dist/svelte/index.mjs +402 -8
- package/dist/svelte/textToParticle/index.cjs +1 -0
- package/dist/svelte/textToParticle/index.d.ts +163 -0
- package/dist/svelte/textToParticle/index.mjs +924 -0
- package/dist/textToParticle/core/count/index.d.ts +52 -0
- package/dist/textToParticle/core/count/index.d.ts.map +1 -0
- package/dist/textToParticle/core/index.d.ts +18 -0
- package/dist/textToParticle/core/index.d.ts.map +1 -0
- package/dist/textToParticle/core/textToParticle/index.d.ts +103 -0
- package/dist/textToParticle/core/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/index.cjs +1 -0
- package/dist/textToParticle/index.d.ts +16 -0
- package/dist/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/index.mjs +1 -0
- package/dist/textToParticle/index.umd.d.ts +7 -0
- package/dist/textToParticle/index.umd.d.ts.map +1 -0
- package/dist/textToParticle/react/MasonEffect.d.ts +32 -0
- package/dist/textToParticle/react/MasonEffect.d.ts.map +1 -0
- package/dist/textToParticle/react/count/Count.d.ts +19 -0
- package/dist/textToParticle/react/count/Count.d.ts.map +1 -0
- package/dist/textToParticle/react/count/index.d.ts +5 -0
- package/dist/textToParticle/react/count/index.d.ts.map +1 -0
- package/dist/textToParticle/react/index.d.ts +12 -0
- package/dist/textToParticle/react/index.d.ts.map +1 -0
- package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/textToParticle/react/textToParticle/index.d.ts +4 -0
- package/dist/textToParticle/react/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/count/index.d.ts +2 -0
- package/dist/textToParticle/svelte/count/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/index.d.ts +8 -0
- package/dist/textToParticle/svelte/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/textToParticle/index.d.ts +2 -0
- package/dist/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/count/index.d.ts +2 -0
- package/dist/textToParticle/vue/count/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/index.d.ts +8 -0
- package/dist/textToParticle/vue/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/textToParticle/index.d.ts +2 -0
- package/dist/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/vue/count/index.cjs +1 -0
- package/dist/vue/count/index.d.ts +163 -0
- package/dist/vue/count/index.mjs +286 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.d.ts +88 -29
- package/dist/vue/index.mjs +291 -6
- package/dist/vue/textToParticle/index.cjs +1 -0
- package/dist/vue/textToParticle/index.d.ts +163 -0
- package/dist/vue/textToParticle/index.mjs +554 -0
- package/package.json +54 -5
package/dist/svelte/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function h(t){t.forEach(s)}function a(t){return"function"==typeof t}function r(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){t.parentNode&&t.parentNode.removeChild(t)}function c(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let f;function d(t){f=t}const u=[],p=[];let g=[];const m=[],v=Promise.resolve();let x=!1;function y(t){g.push(t)}const w=new Set;let b=0;function $(){if(0!==b)return;const t=f;do{try{for(;b<u.length;){const t=u[b];b++,d(t),M(t.$$)}}catch(e){throw u.length=0,b=0,e}for(d(null),u.length=0,b=0;p.length;)p.pop()();for(let t=0;t<g.length;t+=1){const e=g[t];w.has(e)||(w.add(e),e())}g.length=0}while(u.length);for(;m.length;)m.pop()();x=!1,w.clear(),d(t)}function M(t){if(null!==t.fragment){t.update(),h(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(y)}}const R=new Set;function C(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];g.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),g=e}(i.after_update),h(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function S(t,e){-1===t.$$.dirty[0]&&(u.push(t),x||(x=!0,v.then($)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function P(t,e,i,r,c,u,p=null,g=[-1]){const m=f;d(t);const v=t.$$={fragment:null,ctx:[],props:u,update:n,not_equal:c,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(m?m.$$.context:[])),callbacks:o(),dirty:g,skip_bound:!1,root:e.target||m.$$.root};p&&p(v.root);let x=!1;if(v.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return v.ctx&&c(v.ctx[e],v.ctx[e]=s)&&(!v.skip_bound&&v.bound[e]&&v.bound[e](s),x&&S(t,e)),i}):[],v.update(),x=!0,h(v.before_update),v.fragment=!!r&&r(v.ctx),e.target){if(e.hydrate){const t=(M=e.target,Array.from(M.childNodes));v.fragment&&v.fragment.l(t),t.forEach(l)}else v.fragment&&v.fragment.c();e.intro&&((w=t.$$.fragment)&&w.i&&(R.delete(w),w.i(b))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),y(()=>{const e=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...e):h(e),t.$$.on_mount=[]}),o.forEach(y)}(t,e.target,e.anchor),$()}var w,b,M;d(m)}class _{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){C(this,1),this.$destroy=n}$on(t,e){if(!a(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function z(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class E{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:e.text||"mason effect",densityStep:e.densityStep??2,maxParticles:e.maxParticles??3200,pointSize:e.pointSize??.5,ease:e.ease??.05,repelRadius:e.repelRadius??150,repelStrength:e.repelStrength??1,particleColor:e.particleColor||"#fff",fontFamily:e.fontFamily||"Inter, system-ui, Arial",fontSize:e.fontSize||null,width:e.width||null,height:e.height||null,devicePixelRatio:e.devicePixelRatio??null,onReady:e.onReady||null,onUpdate:e.onUpdate||null},this.canvas=document.createElement("canvas");const i=this.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("Canvas context not available");this.ctx=i,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.isVisible=!1,this.intersectionObserver=null,this.debounceDelay=e.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=z(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=z(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=z(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupIntersectionObserver(),this.config.onReady&&this.config.onReady(this)}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void this.start();this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.start()):(this.isVisible=!1,this.stop()))},{threshold:.1}),this.intersectionObserver.observe(this.container))}resize(){const t=this.config.width||this.container.clientWidth||window.innerWidth,e=this.config.height||this.container.clientHeight||.7*window.innerHeight;if(t<=0||e<=0)return;this.W=Math.floor(t*this.DPR),this.H=Math.floor(e*this.DPR);const i=4096;if(this.W>i||this.H>i){const t=Math.min(i/this.W,i/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,h=.1*t,a=.05*t;let r=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);r=Math.max(r,t)}const l=s.length>0?o*s.length+h*(s.length-1):o;return{width:r,height:l,fits:r<=i&&l<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,h=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(h=n,s=n+1):o=n-1}return h}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const h=t.split("\n"),a=o,r=.1*o,l=.05*o,c=h.length>0?a*h.length+r*(h.length-1):a;let f=this.H/2-c/2+a/2;for(const g of h){if(0===g.length){f+=a+r;continue}const t=g.split(""),e=this.offCtx.measureText(g).width+l*(t.length-1);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,f),i+=this.offCtx.measureText(n).width+l;f+=a+r}const d=Math.max(2,this.config.densityStep),u=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let g=0;g<this.H;g+=d)for(let t=0;t<this.W;t+=d){const e=4*(g*this.W+t);u[e]+u[e+1]+u[e+2]>600&&p.push({x:t,y:g})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let g=0;g<this.particles.length;g++){const t=this.particles[g],e=p[g];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const e of this.particles){let t=(e.tx-e.x)*this.config.ease,i=(e.ty-e.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const n=e.x-this.mouse.x,s=e.y-this.mouse.y,o=n*n+s*s,h=this.config.repelRadius*this.DPR;if(o<h*h){const e=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-e/h);t+=n/e*a*6,i+=s/e*a*6}}e.j+=2,t+=.05*Math.cos(e.j),i+=.05*Math.sin(1.3*e.j),e.vx=(e.vx+t)*Math.random(),e.vy=(e.vy+i)*Math.random(),e.x+=e.vx,e.y+=e.vy}this.ctx.fillStyle=this.config.particleColor;const t=this.config.pointSize*this.DPR;for(const e of this.particles)this.ctx.beginPath(),this.ctx.arc(e.x,e.y,t,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}function D(t){let e;return{c(){var i;i="div",e=document.createElement(i),c(e,"class",t[0]),c(e,"style",t[1])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[21](e)},p(t,[i]){1&i&&c(e,"class",t[0]),2&i&&c(e,"style",t[1])},i:n,o:n,d(i){i&&l(e),t[21](null)}}}function W(t,e,n){let{text:s="mason effect"}=e,{densityStep:o=2}=e,{maxParticles:h=3200}=e,{pointSize:a=.5}=e,{ease:r=.05}=e,{repelRadius:l=150}=e,{repelStrength:c=1}=e,{particleColor:f="#fff"}=e,{fontFamily:d="Inter, system-ui, Arial"}=e,{fontSize:u=null}=e,{width:g=null}=e,{height:m=null}=e,{devicePixelRatio:v=null}=e,{className:x=""}=e,{style:y={}}=e;const w=i.createEventDispatcher();let b,$=null;return i.onMount(()=>{if(!b)return;n(20,$=new E(b,{text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:f,fontFamily:d,fontSize:u,width:g,height:m,devicePixelRatio:v,onReady:t=>{w("ready",t)},onUpdate:t=>{w("update",t)}}))}),i.onDestroy(()=>{$&&($.destroy(),n(20,$=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,h=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,r=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,f=t.particleColor),"fontFamily"in t&&n(11,d=t.fontFamily),"fontSize"in t&&n(12,u=t.fontSize),"width"in t&&n(13,g=t.width),"height"in t&&n(14,m=t.height),"devicePixelRatio"in t&&n(15,v=t.devicePixelRatio),"className"in t&&n(0,x=t.className),"style"in t&&n(1,y=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&$&&$.updateConfig({text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:f,fontFamily:d,fontSize:u,width:g,height:m,devicePixelRatio:v})},[x,y,b,s,o,h,a,r,l,c,f,d,u,g,m,v,function(t){$&&$.morph(t)},function(){$&&$.scatter()},function(t){$&&$.updateConfig(t)},function(){$&&($.destroy(),n(20,$=null))},$,function(t){p[t?"unshift":"push"](()=>{b=t,n(2,b)})}]}module.exports=class extends _{constructor(t){super(),P(this,t,W,D,r,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}};
|
|
1
|
+
"use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function a(t){return"function"==typeof t}function h(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t,e,i){t.insertBefore(e,i||null)}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t){return document.createElement(t)}function d(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let f;function g(t){f=t}const p=[],m=[];let v=[];const x=[],y=Promise.resolve();let b=!1;function $(t){v.push(t)}const w=new Set;let M=0;function C(){if(0!==M)return;const t=f;do{try{for(;M<p.length;){const t=p[M];M++,g(t),R(t.$$)}}catch(e){throw p.length=0,M=0,e}for(g(null),p.length=0,M=0;m.length;)m.pop()();for(let t=0;t<v.length;t+=1){const e=v[t];w.has(e)||(w.add(e),e())}v.length=0}while(p.length);for(;x.length;)x.pop()();b=!1,w.clear(),g(t)}function R(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach($)}}const S=new Set;function V(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];v.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),v=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function O(t,e){-1===t.$$.dirty[0]&&(p.push(t),b||(b=!0,y.then(C)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function P(t,e,i,h,l,u,d=null,p=[-1]){const m=f;g(t);const v=t.$$={fragment:null,ctx:[],props:u,update:n,not_equal:l,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(m?m.$$.context:[])),callbacks:o(),dirty:p,skip_bound:!1,root:e.target||m.$$.root};d&&d(v.root);let x=!1;if(v.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return v.ctx&&l(v.ctx[e],v.ctx[e]=s)&&(!v.skip_bound&&v.bound[e]&&v.bound[e](s),x&&O(t,e)),i}):[],v.update(),x=!0,r(v.before_update),v.fragment=!!h&&h(v.ctx),e.target){if(e.hydrate){const t=(w=e.target,Array.from(w.childNodes));v.fragment&&v.fragment.l(t),t.forEach(c)}else v.fragment&&v.fragment.c();e.intro&&((y=t.$$.fragment)&&y.i&&(S.delete(y),y.i(b))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),$(()=>{const e=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach($)}(t,e.target,e.anchor),C()}var y,b,w;g(m)}class _{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){V(this,1),this.$destroy=n}$on(t,e){if(!a(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function z(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class D{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:e.text||"mason effect",densityStep:e.densityStep??2,maxParticles:e.maxParticles??3200,pointSize:e.pointSize??.5,ease:e.ease??.05,repelRadius:e.repelRadius??150,repelStrength:e.repelStrength??1,particleColor:e.particleColor||"#fff",fontFamily:e.fontFamily||"Inter, system-ui, Arial",fontSize:e.fontSize||null,width:e.width||null,height:e.height||null,devicePixelRatio:e.devicePixelRatio??null,onReady:e.onReady||null,onUpdate:e.onUpdate||null},this.canvas=document.createElement("canvas");const i=this.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("Canvas context not available");this.ctx=i,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.isVisible=!1,this.intersectionObserver=null,this.debounceDelay=e.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=z(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=z(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=z(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupIntersectionObserver(),this.config.onReady&&this.config.onReady(this)}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void this.start();this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.start()):(this.isVisible=!1,this.stop()))},{threshold:.1}),this.intersectionObserver.observe(this.container))}resize(){const t=this.config.width||this.container.clientWidth||window.innerWidth,e=this.config.height||this.container.clientHeight||.7*window.innerHeight;if(t<=0||e<=0)return;this.W=Math.floor(t*this.DPR),this.H=Math.floor(e*this.DPR);const i=4096;if(this.W>i||this.H>i){const t=Math.min(i/this.W,i/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,r=.1*t,a=.05*t;let h=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);h=Math.max(h,t)}const l=s.length>0?o*s.length+r*(s.length-1):o;return{width:h,height:l,fits:h<=i&&l<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,r=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(r=n,s=n+1):o=n-1}return r}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const r=t.split("\n"),a=o,h=.1*o,l=.05*o,c=r.length>0?a*r.length+h*(r.length-1):a;let u=this.H/2-c/2+a/2;for(const p of r){if(0===p.length){u+=a+h;continue}const t=p.split(""),e=this.offCtx.measureText(p).width+l*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,u),i+=this.offCtx.measureText(n).width+l;u+=a+h}const d=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,g=[];for(let p=0;p<this.H;p+=d)for(let t=0;t<this.W;t+=d){const e=4*(p*this.W+t);f[e]+f[e+1]+f[e+2]>600&&g.push({x:t,y:p})}for(;g.length>this.config.maxParticles;)g.splice(Math.floor(Math.random()*g.length),1);if(this.particles.length<g.length){const t=g.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>g.length&&(this.particles.length=g.length);for(let p=0;p<this.particles.length;p++){const t=this.particles[p],e=g[p];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const e of this.particles){let t=(e.tx-e.x)*this.config.ease,i=(e.ty-e.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const n=e.x-this.mouse.x,s=e.y-this.mouse.y,o=n*n+s*s,r=this.config.repelRadius*this.DPR;if(o<r*r){const e=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-e/r);t+=n/e*a*6,i+=s/e*a*6}}e.j+=2,t+=.05*Math.cos(e.j),i+=.05*Math.sin(1.3*e.j),e.vx=(e.vx+t)*Math.random(),e.vy=(e.vy+i)*Math.random(),e.x+=e.vx,e.y+=e.vy}this.ctx.fillStyle=this.config.particleColor;const t=this.config.pointSize*this.DPR;for(const e of this.particles)this.ctx.beginPath(),this.ctx.arc(e.x,e.y,t,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const E={linear:t=>t};class I{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:e.targetValue,duration:e.duration??2e3,startValue:e.startValue??0,enabled:e.enabled??!0,easing:e.easing??E.linear,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.intersectionObserver=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupIntersectionObserver()}setupIntersectionObserver(){"undefined"!=typeof window&&void 0!==window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(t=>{var e;for(const i of t)if(i.target===this.container)if(i.isIntersecting)!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start()),this.config.triggerOnce&&(null==(e=this.intersectionObserver)||e.unobserve(this.container));else if(!this.config.triggerOnce){const t=i.boundingClientRect,e=window.innerHeight,n=window.innerWidth;(t.bottom<=0||t.top>=e||t.right<=0||t.left>=n)&&this.isRunning&&this.reset()}},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&this.start()}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=e=>{null===this.startTime&&(this.startTime=e);const i=e-this.startTime,n=Math.min(i/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),e&&this.config.enabled&&this.start()):e&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}function T(t){let e;return{c(){e=u("div"),d(e,"class",t[0]),d(e,"style",t[1])},m(i,n){l(i,e,n),t[21](e)},p(t,[i]){1&i&&d(e,"class",t[0]),2&i&&d(e,"style",t[1])},i:n,o:n,d(i){i&&c(e),t[21](null)}}}function F(t,e,n){let{text:s="mason effect"}=e,{densityStep:o=2}=e,{maxParticles:r=3200}=e,{pointSize:a=.5}=e,{ease:h=.05}=e,{repelRadius:l=150}=e,{repelStrength:c=1}=e,{particleColor:u="#fff"}=e,{fontFamily:d="Inter, system-ui, Arial"}=e,{fontSize:f=null}=e,{width:g=null}=e,{height:p=null}=e,{devicePixelRatio:v=null}=e,{className:x=""}=e,{style:y={}}=e;const b=i.createEventDispatcher();let $,w=null;return i.onMount(()=>{if(!$)return;n(20,w=new D($,{text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:f,width:g,height:p,devicePixelRatio:v,onReady:t=>{b("ready",t)},onUpdate:t=>{b("update",t)}}))}),i.onDestroy(()=>{w&&(w.destroy(),n(20,w=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,r=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,h=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,u=t.particleColor),"fontFamily"in t&&n(11,d=t.fontFamily),"fontSize"in t&&n(12,f=t.fontSize),"width"in t&&n(13,g=t.width),"height"in t&&n(14,p=t.height),"devicePixelRatio"in t&&n(15,v=t.devicePixelRatio),"className"in t&&n(0,x=t.className),"style"in t&&n(1,y=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&w&&w.updateConfig({text:s,densityStep:o,maxParticles:r,pointSize:a,ease:h,repelRadius:l,repelStrength:c,particleColor:u,fontFamily:d,fontSize:f,width:g,height:p,devicePixelRatio:v})},[x,y,$,s,o,r,a,h,l,c,u,d,f,g,p,v,function(t){w&&w.morph(t)},function(){w&&w.scatter()},function(t){w&&w.updateConfig(t)},function(){w&&(w.destroy(),n(20,w=null))},w,function(t){m[t?"unshift":"push"](()=>{$=t,n(2,$)})}]}class W extends _{constructor(t){super(),P(this,t,F,T,h,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}}function H(t){let e;return{c(){e=u("div"),d(e,"class",t[0]),d(e,"style",t[1])},m(i,n){l(i,e,n),t[18](e)},p(t,[i]){1&i&&d(e,"class",t[0]),2&i&&d(e,"style",t[1])},i:n,o:n,d(i){i&&c(e),t[18](null)}}}function U(t,e,n){let{targetValue:s=0}=e,{duration:o=2e3}=e,{startValue:r=0}=e,{enabled:a=!0}=e,{easing:h=t=>t}=e,{threshold:l=.2}=e,{rootMargin:c="0px 0px -100px 0px"}=e,{triggerOnce:u=!1}=e,{className:d=""}=e,{style:f={}}=e;const g=i.createEventDispatcher();let p,v=null;return i.onMount(()=>{if(!p)return;n(17,v=new I(p,{targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{g("update",t)},onComplete:()=>{g("complete")}}))}),i.onDestroy(()=>{v&&(v.destroy(),n(17,v=null))}),t.$$set=t=>{"targetValue"in t&&n(3,s=t.targetValue),"duration"in t&&n(4,o=t.duration),"startValue"in t&&n(5,r=t.startValue),"enabled"in t&&n(6,a=t.enabled),"easing"in t&&n(7,h=t.easing),"threshold"in t&&n(8,l=t.threshold),"rootMargin"in t&&n(9,c=t.rootMargin),"triggerOnce"in t&&n(10,u=t.triggerOnce),"className"in t&&n(0,d=t.className),"style"in t&&n(1,f=t.style)},t.$$.update=()=>{133112&t.$$.dirty&&v&&v.updateConfig({targetValue:s,duration:o,startValue:r,enabled:a,easing:h,threshold:l,rootMargin:c,triggerOnce:u,onUpdate:t=>{g("update",t)},onComplete:()=>{g("complete")}})},[d,f,p,s,o,r,a,h,l,c,u,function(){v&&v.start()},function(){v&&v.stop()},function(){v&&v.reset()},function(){return v?v.getValue():0},function(t){v&&v.updateConfig(t)},function(){v&&(v.destroy(),n(17,v=null))},v,function(t){m[t?"unshift":"push"](()=>{p=t,n(2,p)})}]}exports.Count=class extends _{constructor(t){super(),P(this,t,U,H,h,{targetValue:3,duration:4,startValue:5,enabled:6,easing:7,threshold:8,rootMargin:9,triggerOnce:10,className:0,style:1,start:11,stop:12,reset:13,getValue:14,updateConfig:15,destroy:16})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get getValue(){return this.$$.ctx[14]}get updateConfig(){return this.$$.ctx[15]}get destroy(){return this.$$.ctx[16]}},exports.MasonEffect=W,exports.TextToParticle=W,exports.default=W;
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -1,8 +1,73 @@
|
|
|
1
|
-
declare class
|
|
1
|
+
export declare class Count {
|
|
2
2
|
container: HTMLElement;
|
|
3
|
-
config: Required<Omit<
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
config: Required<Omit<CountOptions, 'onUpdate' | 'onComplete'>> & {
|
|
4
|
+
onUpdate: CountOptions['onUpdate'];
|
|
5
|
+
onComplete: CountOptions['onComplete'];
|
|
6
|
+
};
|
|
7
|
+
currentValue: number;
|
|
8
|
+
startTime: number | null;
|
|
9
|
+
animationFrameId: number | null;
|
|
10
|
+
intersectionObserver: IntersectionObserver | null;
|
|
11
|
+
isRunning: boolean;
|
|
12
|
+
hasTriggered: boolean;
|
|
13
|
+
constructor(container: HTMLElement | string, options: CountOptions);
|
|
14
|
+
init(): void;
|
|
15
|
+
setupIntersectionObserver(): void;
|
|
16
|
+
start(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
updateDisplay(value: number): void;
|
|
20
|
+
formatNumber(value: number): string;
|
|
21
|
+
updateConfig(newConfig: Partial<CountOptions>): void;
|
|
22
|
+
getValue(): number;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Count - 숫자 카운팅 애니메이션 효과
|
|
28
|
+
* 바닐라 JS 코어 클래스
|
|
29
|
+
*
|
|
30
|
+
* 사용법:
|
|
31
|
+
* import { Count } from 'masoneffect/count';
|
|
32
|
+
*/
|
|
33
|
+
export declare interface CountOptions {
|
|
34
|
+
targetValue: number;
|
|
35
|
+
duration?: number;
|
|
36
|
+
startValue?: number;
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
easing?: (t: number) => number;
|
|
39
|
+
threshold?: number;
|
|
40
|
+
rootMargin?: string;
|
|
41
|
+
triggerOnce?: boolean;
|
|
42
|
+
onUpdate?: (value: number) => void;
|
|
43
|
+
onComplete?: () => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare const easingFunctions: {
|
|
47
|
+
linear: (t: number) => number;
|
|
48
|
+
easeInQuad: (t: number) => number;
|
|
49
|
+
easeOutQuad: (t: number) => number;
|
|
50
|
+
easeInOutQuad: (t: number) => number;
|
|
51
|
+
easeOutCubic: (t: number) => number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export declare interface Particle {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
vx: number;
|
|
58
|
+
vy: number;
|
|
59
|
+
tx: number;
|
|
60
|
+
ty: number;
|
|
61
|
+
initialX?: number;
|
|
62
|
+
initialY?: number;
|
|
63
|
+
j: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class TextToParticle {
|
|
67
|
+
container: HTMLElement;
|
|
68
|
+
config: Required<Omit<TextToParticleOptions, 'onReady' | 'onUpdate' | 'debounceDelay'>> & {
|
|
69
|
+
onReady: TextToParticleOptions['onReady'];
|
|
70
|
+
onUpdate: TextToParticleOptions['onUpdate'];
|
|
6
71
|
};
|
|
7
72
|
canvas: HTMLCanvasElement;
|
|
8
73
|
ctx: CanvasRenderingContext2D;
|
|
@@ -22,9 +87,9 @@ declare class MasonEffect {
|
|
|
22
87
|
isVisible: boolean;
|
|
23
88
|
intersectionObserver: IntersectionObserver | null;
|
|
24
89
|
debounceDelay: number;
|
|
25
|
-
_debouncedMorph: (textOrOptions?: string | Partial<
|
|
26
|
-
_debouncedUpdateConfig: (newConfig: Partial<
|
|
27
|
-
constructor(container: HTMLElement | string, options?:
|
|
90
|
+
_debouncedMorph: (textOrOptions?: string | Partial<TextToParticleOptions> | null) => void;
|
|
91
|
+
_debouncedUpdateConfig: (newConfig: Partial<TextToParticleOptions>) => void;
|
|
92
|
+
constructor(container: HTMLElement | string, options?: TextToParticleOptions);
|
|
28
93
|
init(): void;
|
|
29
94
|
setupIntersectionObserver(): void;
|
|
30
95
|
resize(): void;
|
|
@@ -46,8 +111,8 @@ declare class MasonEffect {
|
|
|
46
111
|
makeParticle(): Particle;
|
|
47
112
|
initParticles(): void;
|
|
48
113
|
scatter(): void;
|
|
49
|
-
morph(textOrOptions?: string | Partial<
|
|
50
|
-
_morphInternal(textOrOptions?: string | Partial<
|
|
114
|
+
morph(textOrOptions?: string | Partial<TextToParticleOptions> | null): void;
|
|
115
|
+
_morphInternal(textOrOptions?: string | Partial<TextToParticleOptions> | null): void;
|
|
51
116
|
update(): void;
|
|
52
117
|
animate(): void;
|
|
53
118
|
start(): void;
|
|
@@ -59,18 +124,22 @@ declare class MasonEffect {
|
|
|
59
124
|
handleMouseLeave(): void;
|
|
60
125
|
handleMouseDown(): void;
|
|
61
126
|
handleMouseUp(): void;
|
|
62
|
-
updateConfig(newConfig: Partial<
|
|
63
|
-
_updateConfigInternal(newConfig: Partial<
|
|
127
|
+
updateConfig(newConfig: Partial<TextToParticleOptions>): void;
|
|
128
|
+
_updateConfigInternal(newConfig: Partial<TextToParticleOptions>): void;
|
|
64
129
|
destroy(): void;
|
|
65
130
|
}
|
|
66
|
-
export { MasonEffect }
|
|
67
|
-
export
|
|
131
|
+
export { TextToParticle as MasonEffect }
|
|
132
|
+
export { TextToParticle }
|
|
133
|
+
export default TextToParticle;
|
|
68
134
|
|
|
69
135
|
/**
|
|
70
|
-
*
|
|
136
|
+
* TextToParticle - 텍스트를 파티클로 변환하는 효과
|
|
71
137
|
* 바닐라 JS 코어 클래스
|
|
138
|
+
*
|
|
139
|
+
* 사용법:
|
|
140
|
+
* import { TextToParticle } from 'masoneffect/textToParticle';
|
|
72
141
|
*/
|
|
73
|
-
|
|
142
|
+
declare interface TextToParticleOptions {
|
|
74
143
|
text?: string;
|
|
75
144
|
densityStep?: number;
|
|
76
145
|
maxParticles?: number;
|
|
@@ -85,20 +154,10 @@ declare class MasonEffect {
|
|
|
85
154
|
height?: number | null;
|
|
86
155
|
devicePixelRatio?: number | null;
|
|
87
156
|
debounceDelay?: number;
|
|
88
|
-
onReady?: (instance:
|
|
89
|
-
onUpdate?: (instance:
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export declare interface Particle {
|
|
93
|
-
x: number;
|
|
94
|
-
y: number;
|
|
95
|
-
vx: number;
|
|
96
|
-
vy: number;
|
|
97
|
-
tx: number;
|
|
98
|
-
ty: number;
|
|
99
|
-
initialX?: number;
|
|
100
|
-
initialY?: number;
|
|
101
|
-
j: number;
|
|
157
|
+
onReady?: (instance: TextToParticle) => void;
|
|
158
|
+
onUpdate?: (instance: TextToParticle) => void;
|
|
102
159
|
}
|
|
160
|
+
export { TextToParticleOptions as MasonEffectOptions }
|
|
161
|
+
export { TextToParticleOptions }
|
|
103
162
|
|
|
104
163
|
export { }
|
package/dist/svelte/index.mjs
CHANGED
|
@@ -276,7 +276,7 @@ function debounce(func, wait) {
|
|
|
276
276
|
timeout = setTimeout(later, wait);
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
class
|
|
279
|
+
class TextToParticle {
|
|
280
280
|
constructor(container, options = {}) {
|
|
281
281
|
this.container = typeof container === "string" ? document.querySelector(container) : container;
|
|
282
282
|
if (!this.container) {
|
|
@@ -482,7 +482,7 @@ class MasonEffect {
|
|
|
482
482
|
continue;
|
|
483
483
|
}
|
|
484
484
|
const chars = line.split("");
|
|
485
|
-
const totalWidth = this.offCtx.measureText(line).width + spacing * (chars.length - 1);
|
|
485
|
+
const totalWidth = this.offCtx.measureText(line).width + spacing * (chars.length > 0 ? chars.length - 1 : 0);
|
|
486
486
|
let x = this.W / 2 - totalWidth / 2;
|
|
487
487
|
for (const ch of chars) {
|
|
488
488
|
this.offCtx.fillText(ch, x + this.offCtx.measureText(ch).width / 2, startY);
|
|
@@ -686,7 +686,168 @@ class MasonEffect {
|
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
|
|
689
|
+
const easingFunctions = {
|
|
690
|
+
linear: (t) => t
|
|
691
|
+
};
|
|
692
|
+
class Count {
|
|
693
|
+
constructor(container, options) {
|
|
694
|
+
this.container = typeof container === "string" ? document.querySelector(container) : container;
|
|
695
|
+
if (!this.container) {
|
|
696
|
+
throw new Error("Container element not found");
|
|
697
|
+
}
|
|
698
|
+
this.config = {
|
|
699
|
+
targetValue: options.targetValue,
|
|
700
|
+
duration: options.duration ?? 2e3,
|
|
701
|
+
startValue: options.startValue ?? 0,
|
|
702
|
+
enabled: options.enabled ?? true,
|
|
703
|
+
easing: options.easing ?? easingFunctions.linear,
|
|
704
|
+
threshold: options.threshold ?? 0.2,
|
|
705
|
+
rootMargin: options.rootMargin ?? "0px 0px -100px 0px",
|
|
706
|
+
triggerOnce: options.triggerOnce ?? false,
|
|
707
|
+
onUpdate: options.onUpdate || null,
|
|
708
|
+
onComplete: options.onComplete || null
|
|
709
|
+
};
|
|
710
|
+
this.currentValue = this.config.startValue;
|
|
711
|
+
this.startTime = null;
|
|
712
|
+
this.animationFrameId = null;
|
|
713
|
+
this.intersectionObserver = null;
|
|
714
|
+
this.isRunning = false;
|
|
715
|
+
this.hasTriggered = false;
|
|
716
|
+
this.init();
|
|
717
|
+
}
|
|
718
|
+
init() {
|
|
719
|
+
this.updateDisplay(this.config.startValue);
|
|
720
|
+
this.setupIntersectionObserver();
|
|
721
|
+
}
|
|
722
|
+
setupIntersectionObserver() {
|
|
723
|
+
if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
|
|
724
|
+
if (this.config.enabled) {
|
|
725
|
+
this.start();
|
|
726
|
+
}
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
this.intersectionObserver = new IntersectionObserver(
|
|
730
|
+
(entries) => {
|
|
731
|
+
var _a;
|
|
732
|
+
for (const entry of entries) {
|
|
733
|
+
if (entry.target !== this.container) continue;
|
|
734
|
+
if (entry.isIntersecting) {
|
|
735
|
+
if (!this.hasTriggered && this.config.enabled) {
|
|
736
|
+
this.hasTriggered = true;
|
|
737
|
+
this.start();
|
|
738
|
+
}
|
|
739
|
+
if (this.config.triggerOnce) {
|
|
740
|
+
(_a = this.intersectionObserver) == null ? void 0 : _a.unobserve(this.container);
|
|
741
|
+
}
|
|
742
|
+
} else {
|
|
743
|
+
if (!this.config.triggerOnce) {
|
|
744
|
+
const rect = entry.boundingClientRect;
|
|
745
|
+
const viewportHeight = window.innerHeight;
|
|
746
|
+
const viewportWidth = window.innerWidth;
|
|
747
|
+
const isCompletelyOutOfViewport = rect.bottom <= 0 || rect.top >= viewportHeight || rect.right <= 0 || rect.left >= viewportWidth;
|
|
748
|
+
if (isCompletelyOutOfViewport && this.isRunning) {
|
|
749
|
+
this.reset();
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
threshold: this.config.threshold,
|
|
757
|
+
rootMargin: this.config.rootMargin
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
this.intersectionObserver.observe(this.container);
|
|
761
|
+
}
|
|
762
|
+
start() {
|
|
763
|
+
if (this.isRunning) return;
|
|
764
|
+
if (!this.config.enabled) return;
|
|
765
|
+
this.isRunning = true;
|
|
766
|
+
this.startTime = null;
|
|
767
|
+
this.currentValue = this.config.startValue;
|
|
768
|
+
this.updateDisplay(this.currentValue);
|
|
769
|
+
const animate = (currentTime) => {
|
|
770
|
+
if (this.startTime === null) {
|
|
771
|
+
this.startTime = currentTime;
|
|
772
|
+
}
|
|
773
|
+
const elapsed = currentTime - this.startTime;
|
|
774
|
+
const progress = Math.min(elapsed / this.config.duration, 1);
|
|
775
|
+
const easedProgress = this.config.easing(progress);
|
|
776
|
+
this.currentValue = Math.floor(
|
|
777
|
+
this.config.startValue + (this.config.targetValue - this.config.startValue) * easedProgress
|
|
778
|
+
);
|
|
779
|
+
this.updateDisplay(this.currentValue);
|
|
780
|
+
if (this.config.onUpdate) {
|
|
781
|
+
this.config.onUpdate(this.currentValue);
|
|
782
|
+
}
|
|
783
|
+
if (progress < 1) {
|
|
784
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
785
|
+
} else {
|
|
786
|
+
this.currentValue = this.config.targetValue;
|
|
787
|
+
this.updateDisplay(this.currentValue);
|
|
788
|
+
this.isRunning = false;
|
|
789
|
+
if (this.config.onComplete) {
|
|
790
|
+
this.config.onComplete();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
this.animationFrameId = requestAnimationFrame(animate);
|
|
795
|
+
}
|
|
796
|
+
stop() {
|
|
797
|
+
this.isRunning = false;
|
|
798
|
+
if (this.animationFrameId !== null) {
|
|
799
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
800
|
+
this.animationFrameId = null;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
reset() {
|
|
804
|
+
this.stop();
|
|
805
|
+
this.currentValue = this.config.startValue;
|
|
806
|
+
this.updateDisplay(this.currentValue);
|
|
807
|
+
this.hasTriggered = false;
|
|
808
|
+
this.startTime = null;
|
|
809
|
+
}
|
|
810
|
+
updateDisplay(value) {
|
|
811
|
+
this.container.textContent = this.formatNumber(value);
|
|
812
|
+
}
|
|
813
|
+
formatNumber(value) {
|
|
814
|
+
return Math.floor(value).toLocaleString();
|
|
815
|
+
}
|
|
816
|
+
// 설정 업데이트
|
|
817
|
+
updateConfig(newConfig) {
|
|
818
|
+
const wasRunning = this.isRunning;
|
|
819
|
+
this.stop();
|
|
820
|
+
this.config = {
|
|
821
|
+
...this.config,
|
|
822
|
+
...newConfig,
|
|
823
|
+
onUpdate: newConfig.onUpdate !== void 0 ? newConfig.onUpdate : this.config.onUpdate,
|
|
824
|
+
onComplete: newConfig.onComplete !== void 0 ? newConfig.onComplete : this.config.onComplete
|
|
825
|
+
};
|
|
826
|
+
if (newConfig.targetValue !== void 0) {
|
|
827
|
+
this.reset();
|
|
828
|
+
if (wasRunning && this.config.enabled) {
|
|
829
|
+
this.start();
|
|
830
|
+
}
|
|
831
|
+
} else {
|
|
832
|
+
if (wasRunning && this.config.enabled) {
|
|
833
|
+
this.start();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
// 현재 값 가져오기
|
|
838
|
+
getValue() {
|
|
839
|
+
return this.currentValue;
|
|
840
|
+
}
|
|
841
|
+
// 파괴 및 정리
|
|
842
|
+
destroy() {
|
|
843
|
+
this.stop();
|
|
844
|
+
if (this.intersectionObserver) {
|
|
845
|
+
this.intersectionObserver.disconnect();
|
|
846
|
+
this.intersectionObserver = null;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function create_fragment$1(ctx) {
|
|
690
851
|
let div;
|
|
691
852
|
return {
|
|
692
853
|
c() {
|
|
@@ -738,7 +899,7 @@ function create_fragment(ctx) {
|
|
|
738
899
|
}
|
|
739
900
|
};
|
|
740
901
|
}
|
|
741
|
-
function instance_1($$self, $$props, $$invalidate) {
|
|
902
|
+
function instance_1$1($$self, $$props, $$invalidate) {
|
|
742
903
|
let { text = "mason effect" } = $$props;
|
|
743
904
|
let { densityStep = 2 } = $$props;
|
|
744
905
|
let { maxParticles = 3200 } = $$props;
|
|
@@ -780,7 +941,7 @@ function instance_1($$self, $$props, $$invalidate) {
|
|
|
780
941
|
dispatch("update", inst);
|
|
781
942
|
}
|
|
782
943
|
};
|
|
783
|
-
$$invalidate(20, instance = new
|
|
944
|
+
$$invalidate(20, instance = new TextToParticle(container, options));
|
|
784
945
|
});
|
|
785
946
|
onDestroy(() => {
|
|
786
947
|
if (instance) {
|
|
@@ -881,10 +1042,10 @@ function instance_1($$self, $$props, $$invalidate) {
|
|
|
881
1042
|
div_binding
|
|
882
1043
|
];
|
|
883
1044
|
}
|
|
884
|
-
class
|
|
1045
|
+
class TextToParticle_1 extends SvelteComponent {
|
|
885
1046
|
constructor(options) {
|
|
886
1047
|
super();
|
|
887
|
-
init(this, options, instance_1, create_fragment, safe_not_equal, {
|
|
1048
|
+
init(this, options, instance_1$1, create_fragment$1, safe_not_equal, {
|
|
888
1049
|
text: 3,
|
|
889
1050
|
densityStep: 4,
|
|
890
1051
|
maxParticles: 5,
|
|
@@ -919,6 +1080,239 @@ class MasonEffect_1 extends SvelteComponent {
|
|
|
919
1080
|
return this.$$.ctx[19];
|
|
920
1081
|
}
|
|
921
1082
|
}
|
|
1083
|
+
function create_fragment(ctx) {
|
|
1084
|
+
let div;
|
|
1085
|
+
return {
|
|
1086
|
+
c() {
|
|
1087
|
+
div = element("div");
|
|
1088
|
+
attr(
|
|
1089
|
+
div,
|
|
1090
|
+
"class",
|
|
1091
|
+
/*className*/
|
|
1092
|
+
ctx[0]
|
|
1093
|
+
);
|
|
1094
|
+
attr(
|
|
1095
|
+
div,
|
|
1096
|
+
"style",
|
|
1097
|
+
/*style*/
|
|
1098
|
+
ctx[1]
|
|
1099
|
+
);
|
|
1100
|
+
},
|
|
1101
|
+
m(target, anchor) {
|
|
1102
|
+
insert(target, div, anchor);
|
|
1103
|
+
ctx[18](div);
|
|
1104
|
+
},
|
|
1105
|
+
p(ctx2, [dirty]) {
|
|
1106
|
+
if (dirty & /*className*/
|
|
1107
|
+
1) {
|
|
1108
|
+
attr(
|
|
1109
|
+
div,
|
|
1110
|
+
"class",
|
|
1111
|
+
/*className*/
|
|
1112
|
+
ctx2[0]
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
if (dirty & /*style*/
|
|
1116
|
+
2) {
|
|
1117
|
+
attr(
|
|
1118
|
+
div,
|
|
1119
|
+
"style",
|
|
1120
|
+
/*style*/
|
|
1121
|
+
ctx2[1]
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
i: noop,
|
|
1126
|
+
o: noop,
|
|
1127
|
+
d(detaching) {
|
|
1128
|
+
if (detaching) {
|
|
1129
|
+
detach(div);
|
|
1130
|
+
}
|
|
1131
|
+
ctx[18](null);
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
function instance_1($$self, $$props, $$invalidate) {
|
|
1136
|
+
let { targetValue = 0 } = $$props;
|
|
1137
|
+
let { duration = 2e3 } = $$props;
|
|
1138
|
+
let { startValue = 0 } = $$props;
|
|
1139
|
+
let { enabled = true } = $$props;
|
|
1140
|
+
let { easing = (t) => t } = $$props;
|
|
1141
|
+
let { threshold = 0.2 } = $$props;
|
|
1142
|
+
let { rootMargin = "0px 0px -100px 0px" } = $$props;
|
|
1143
|
+
let { triggerOnce = false } = $$props;
|
|
1144
|
+
let { className = "" } = $$props;
|
|
1145
|
+
let { style = {} } = $$props;
|
|
1146
|
+
const dispatch = createEventDispatcher();
|
|
1147
|
+
let container;
|
|
1148
|
+
let instance = null;
|
|
1149
|
+
onMount(() => {
|
|
1150
|
+
if (!container) return;
|
|
1151
|
+
const options = {
|
|
1152
|
+
targetValue,
|
|
1153
|
+
duration,
|
|
1154
|
+
startValue,
|
|
1155
|
+
enabled,
|
|
1156
|
+
easing,
|
|
1157
|
+
threshold,
|
|
1158
|
+
rootMargin,
|
|
1159
|
+
triggerOnce,
|
|
1160
|
+
onUpdate: (value) => {
|
|
1161
|
+
dispatch("update", value);
|
|
1162
|
+
},
|
|
1163
|
+
onComplete: () => {
|
|
1164
|
+
dispatch("complete");
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
$$invalidate(17, instance = new Count(container, options));
|
|
1168
|
+
});
|
|
1169
|
+
onDestroy(() => {
|
|
1170
|
+
if (instance) {
|
|
1171
|
+
instance.destroy();
|
|
1172
|
+
$$invalidate(17, instance = null);
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
function start() {
|
|
1176
|
+
if (instance) {
|
|
1177
|
+
instance.start();
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function stop() {
|
|
1181
|
+
if (instance) {
|
|
1182
|
+
instance.stop();
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
function reset() {
|
|
1186
|
+
if (instance) {
|
|
1187
|
+
instance.reset();
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function getValue() {
|
|
1191
|
+
if (instance) {
|
|
1192
|
+
return instance.getValue();
|
|
1193
|
+
}
|
|
1194
|
+
return 0;
|
|
1195
|
+
}
|
|
1196
|
+
function updateConfig(config) {
|
|
1197
|
+
if (instance) {
|
|
1198
|
+
instance.updateConfig(config);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
function destroy() {
|
|
1202
|
+
if (instance) {
|
|
1203
|
+
instance.destroy();
|
|
1204
|
+
$$invalidate(17, instance = null);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
function div_binding($$value) {
|
|
1208
|
+
binding_callbacks[$$value ? "unshift" : "push"](() => {
|
|
1209
|
+
container = $$value;
|
|
1210
|
+
$$invalidate(2, container);
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
$$self.$$set = ($$props2) => {
|
|
1214
|
+
if ("targetValue" in $$props2) $$invalidate(3, targetValue = $$props2.targetValue);
|
|
1215
|
+
if ("duration" in $$props2) $$invalidate(4, duration = $$props2.duration);
|
|
1216
|
+
if ("startValue" in $$props2) $$invalidate(5, startValue = $$props2.startValue);
|
|
1217
|
+
if ("enabled" in $$props2) $$invalidate(6, enabled = $$props2.enabled);
|
|
1218
|
+
if ("easing" in $$props2) $$invalidate(7, easing = $$props2.easing);
|
|
1219
|
+
if ("threshold" in $$props2) $$invalidate(8, threshold = $$props2.threshold);
|
|
1220
|
+
if ("rootMargin" in $$props2) $$invalidate(9, rootMargin = $$props2.rootMargin);
|
|
1221
|
+
if ("triggerOnce" in $$props2) $$invalidate(10, triggerOnce = $$props2.triggerOnce);
|
|
1222
|
+
if ("className" in $$props2) $$invalidate(0, className = $$props2.className);
|
|
1223
|
+
if ("style" in $$props2) $$invalidate(1, style = $$props2.style);
|
|
1224
|
+
};
|
|
1225
|
+
$$self.$$.update = () => {
|
|
1226
|
+
if ($$self.$$.dirty & /*instance, targetValue, duration, startValue, enabled, easing, threshold, rootMargin, triggerOnce*/
|
|
1227
|
+
133112) {
|
|
1228
|
+
{
|
|
1229
|
+
if (instance) {
|
|
1230
|
+
instance.updateConfig({
|
|
1231
|
+
targetValue,
|
|
1232
|
+
duration,
|
|
1233
|
+
startValue,
|
|
1234
|
+
enabled,
|
|
1235
|
+
easing,
|
|
1236
|
+
threshold,
|
|
1237
|
+
rootMargin,
|
|
1238
|
+
triggerOnce,
|
|
1239
|
+
onUpdate: (value) => {
|
|
1240
|
+
dispatch("update", value);
|
|
1241
|
+
},
|
|
1242
|
+
onComplete: () => {
|
|
1243
|
+
dispatch("complete");
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
return [
|
|
1251
|
+
className,
|
|
1252
|
+
style,
|
|
1253
|
+
container,
|
|
1254
|
+
targetValue,
|
|
1255
|
+
duration,
|
|
1256
|
+
startValue,
|
|
1257
|
+
enabled,
|
|
1258
|
+
easing,
|
|
1259
|
+
threshold,
|
|
1260
|
+
rootMargin,
|
|
1261
|
+
triggerOnce,
|
|
1262
|
+
start,
|
|
1263
|
+
stop,
|
|
1264
|
+
reset,
|
|
1265
|
+
getValue,
|
|
1266
|
+
updateConfig,
|
|
1267
|
+
destroy,
|
|
1268
|
+
instance,
|
|
1269
|
+
div_binding
|
|
1270
|
+
];
|
|
1271
|
+
}
|
|
1272
|
+
class Count_1 extends SvelteComponent {
|
|
1273
|
+
constructor(options) {
|
|
1274
|
+
super();
|
|
1275
|
+
init(this, options, instance_1, create_fragment, safe_not_equal, {
|
|
1276
|
+
targetValue: 3,
|
|
1277
|
+
duration: 4,
|
|
1278
|
+
startValue: 5,
|
|
1279
|
+
enabled: 6,
|
|
1280
|
+
easing: 7,
|
|
1281
|
+
threshold: 8,
|
|
1282
|
+
rootMargin: 9,
|
|
1283
|
+
triggerOnce: 10,
|
|
1284
|
+
className: 0,
|
|
1285
|
+
style: 1,
|
|
1286
|
+
start: 11,
|
|
1287
|
+
stop: 12,
|
|
1288
|
+
reset: 13,
|
|
1289
|
+
getValue: 14,
|
|
1290
|
+
updateConfig: 15,
|
|
1291
|
+
destroy: 16
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
get start() {
|
|
1295
|
+
return this.$$.ctx[11];
|
|
1296
|
+
}
|
|
1297
|
+
get stop() {
|
|
1298
|
+
return this.$$.ctx[12];
|
|
1299
|
+
}
|
|
1300
|
+
get reset() {
|
|
1301
|
+
return this.$$.ctx[13];
|
|
1302
|
+
}
|
|
1303
|
+
get getValue() {
|
|
1304
|
+
return this.$$.ctx[14];
|
|
1305
|
+
}
|
|
1306
|
+
get updateConfig() {
|
|
1307
|
+
return this.$$.ctx[15];
|
|
1308
|
+
}
|
|
1309
|
+
get destroy() {
|
|
1310
|
+
return this.$$.ctx[16];
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
922
1313
|
export {
|
|
923
|
-
|
|
1314
|
+
Count_1 as Count,
|
|
1315
|
+
TextToParticle_1 as MasonEffect,
|
|
1316
|
+
TextToParticle_1 as TextToParticle,
|
|
1317
|
+
TextToParticle_1 as default
|
|
924
1318
|
};
|