masoneffect 0.1.19 → 0.1.21

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/dist/index.js DELETED
@@ -1,412 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /**
6
- * MasonEffect - 파티클 모핑 효과 라이브러리
7
- * 바닐라 JS 코어 클래스
8
- */
9
- // 디바운스 유틸리티 함수
10
- function debounce(func, wait) {
11
- let timeout = null;
12
- return function executedFunction(...args) {
13
- const later = () => {
14
- timeout = null;
15
- func.apply(this, args);
16
- };
17
- if (timeout !== null) {
18
- clearTimeout(timeout);
19
- }
20
- timeout = setTimeout(later, wait);
21
- };
22
- }
23
- class MasonEffect {
24
- constructor(container, options = {}) {
25
- // 컨테이너 요소
26
- this.container = typeof container === 'string'
27
- ? document.querySelector(container)
28
- : container;
29
- if (!this.container) {
30
- throw new Error('Container element not found');
31
- }
32
- // 설정값들
33
- this.config = {
34
- text: options.text || 'mason effect',
35
- densityStep: options.densityStep ?? 2,
36
- maxParticles: options.maxParticles ?? 3200,
37
- pointSize: options.pointSize ?? 0.5,
38
- ease: options.ease ?? 0.05,
39
- repelRadius: options.repelRadius ?? 150,
40
- repelStrength: options.repelStrength ?? 1,
41
- particleColor: options.particleColor || '#fff',
42
- fontFamily: options.fontFamily || 'Inter, system-ui, Arial',
43
- fontSize: options.fontSize || null,
44
- width: options.width || null,
45
- height: options.height || null,
46
- devicePixelRatio: options.devicePixelRatio ?? null,
47
- onReady: options.onReady || null,
48
- onUpdate: options.onUpdate || null,
49
- };
50
- // 캔버스 생성
51
- this.canvas = document.createElement('canvas');
52
- const ctx = this.canvas.getContext('2d');
53
- if (!ctx) {
54
- throw new Error('Canvas context not available');
55
- }
56
- this.ctx = ctx;
57
- this.container.appendChild(this.canvas);
58
- this.canvas.style.display = 'block';
59
- // 오프스크린 캔버스 (텍스트 렌더링용)
60
- this.offCanvas = document.createElement('canvas');
61
- const offCtx = this.offCanvas.getContext('2d');
62
- if (!offCtx) {
63
- throw new Error('Offscreen canvas context not available');
64
- }
65
- this.offCtx = offCtx;
66
- // 상태
67
- this.W = 0;
68
- this.H = 0;
69
- this.DPR = this.config.devicePixelRatio || Math.min(window.devicePixelRatio || 1, 1.8);
70
- this.particles = [];
71
- this.mouse = { x: 0, y: 0, down: false };
72
- this.animationId = null;
73
- this.isRunning = false;
74
- this.isVisible = false;
75
- this.intersectionObserver = null;
76
- // 디바운스 설정 (ms)
77
- this.debounceDelay = options.debounceDelay ?? 150;
78
- // 이벤트 핸들러 바인딩 (디바운스 적용 전에 바인딩)
79
- const boundHandleResize = this.handleResize.bind(this);
80
- this.handleResize = debounce(boundHandleResize, this.debounceDelay);
81
- this.handleMouseMove = this.handleMouseMove.bind(this);
82
- this.handleMouseLeave = this.handleMouseLeave.bind(this);
83
- this.handleMouseDown = this.handleMouseDown.bind(this);
84
- this.handleMouseUp = this.handleMouseUp.bind(this);
85
- // morph와 updateConfig를 위한 디바운스된 내부 메서드
86
- this._debouncedMorph = debounce(this._morphInternal.bind(this), this.debounceDelay);
87
- this._debouncedUpdateConfig = debounce(this._updateConfigInternal.bind(this), this.debounceDelay);
88
- // 초기화
89
- this.init();
90
- }
91
- init() {
92
- this.resize();
93
- this.setupEventListeners();
94
- this.setupIntersectionObserver();
95
- if (this.config.onReady) {
96
- this.config.onReady(this);
97
- }
98
- }
99
- setupIntersectionObserver() {
100
- // IntersectionObserver가 지원되지 않는 환경에서는 항상 재생
101
- if (typeof window === 'undefined' || typeof window.IntersectionObserver === 'undefined') {
102
- this.isVisible = true;
103
- this.start();
104
- return;
105
- }
106
- // 이미 설정되어 있다면 다시 만들지 않음
107
- if (this.intersectionObserver) {
108
- return;
109
- }
110
- this.intersectionObserver = new IntersectionObserver((entries) => {
111
- for (const entry of entries) {
112
- if (entry.target !== this.container)
113
- continue;
114
- if (entry.isIntersecting) {
115
- this.isVisible = true;
116
- this.start();
117
- }
118
- else {
119
- this.isVisible = false;
120
- this.stop();
121
- }
122
- }
123
- }, {
124
- threshold: 0.1, // 10% 이상 보일 때 동작
125
- });
126
- this.intersectionObserver.observe(this.container);
127
- }
128
- resize() {
129
- const width = this.config.width || this.container.clientWidth || window.innerWidth;
130
- const height = this.config.height || this.container.clientHeight || window.innerHeight * 0.7;
131
- // 최소 크기 보장
132
- if (width <= 0 || height <= 0) {
133
- return;
134
- }
135
- this.W = Math.floor(width * this.DPR);
136
- this.H = Math.floor(height * this.DPR);
137
- // 캔버스 크기 제한 (메모리 오류 방지)
138
- // getImageData는 최대 약 268MB (4096x4096x4)까지 지원
139
- const MAX_CANVAS_SIZE = 4096;
140
- if (this.W > MAX_CANVAS_SIZE || this.H > MAX_CANVAS_SIZE) {
141
- const scale = Math.min(MAX_CANVAS_SIZE / this.W, MAX_CANVAS_SIZE / this.H);
142
- this.W = Math.floor(this.W * scale);
143
- this.H = Math.floor(this.H * scale);
144
- this.DPR = this.DPR * scale;
145
- }
146
- this.canvas.width = this.W;
147
- this.canvas.height = this.H;
148
- this.canvas.style.width = width + 'px';
149
- this.canvas.style.height = height + 'px';
150
- // 크기가 유효할 때만 buildTargets 실행
151
- if (this.W > 0 && this.H > 0) {
152
- this.buildTargets();
153
- if (!this.particles.length) {
154
- this.initParticles();
155
- }
156
- }
157
- }
158
- buildTargets() {
159
- // 크기 검증
160
- if (this.W <= 0 || this.H <= 0) {
161
- return;
162
- }
163
- const text = this.config.text;
164
- this.offCanvas.width = this.W;
165
- this.offCanvas.height = this.H;
166
- this.offCtx.clearRect(0, 0, this.offCanvas.width, this.offCanvas.height);
167
- const base = Math.min(this.W, this.H);
168
- const fontSize = this.config.fontSize || Math.max(80, Math.floor(base * 0.18));
169
- this.offCtx.fillStyle = '#ffffff';
170
- this.offCtx.textAlign = 'center';
171
- this.offCtx.textBaseline = 'middle';
172
- this.offCtx.font = `400 ${fontSize}px ${this.config.fontFamily}`;
173
- // 글자 간격 계산 및 그리기
174
- const chars = text.split('');
175
- const spacing = fontSize * 0.05;
176
- const totalWidth = this.offCtx.measureText(text).width + spacing * (chars.length - 1);
177
- let x = this.W / 2 - totalWidth / 2;
178
- for (const ch of chars) {
179
- this.offCtx.fillText(ch, x + this.offCtx.measureText(ch).width / 2, this.H / 2);
180
- x += this.offCtx.measureText(ch).width + spacing;
181
- }
182
- // 픽셀 샘플링
183
- const step = Math.max(2, this.config.densityStep);
184
- const img = this.offCtx.getImageData(0, 0, this.W, this.H).data;
185
- const targets = [];
186
- for (let y = 0; y < this.H; y += step) {
187
- for (let x = 0; x < this.W; x += step) {
188
- const i = (y * this.W + x) * 4;
189
- if (img[i] + img[i + 1] + img[i + 2] > 600) {
190
- targets.push({ x, y });
191
- }
192
- }
193
- }
194
- // 파티클 수 제한
195
- while (targets.length > this.config.maxParticles) {
196
- targets.splice(Math.floor(Math.random() * targets.length), 1);
197
- }
198
- // 파티클 수 조정
199
- if (this.particles.length < targets.length) {
200
- const need = targets.length - this.particles.length;
201
- for (let i = 0; i < need; i++) {
202
- this.particles.push(this.makeParticle());
203
- }
204
- }
205
- else if (this.particles.length > targets.length) {
206
- this.particles.length = targets.length;
207
- }
208
- // 목표 좌표 할당
209
- for (let i = 0; i < this.particles.length; i++) {
210
- const p = this.particles[i];
211
- const t = targets[i];
212
- p.tx = t.x;
213
- p.ty = t.y;
214
- }
215
- }
216
- makeParticle() {
217
- // 캔버스 전체에 골고루 분포 (여백 없이)
218
- const sx = Math.random() * this.W;
219
- const sy = Math.random() * this.H;
220
- return {
221
- x: sx,
222
- y: sy,
223
- vx: 0,
224
- vy: 0,
225
- tx: sx,
226
- ty: sy,
227
- initialX: sx, // 초기 위치 저장 (scatter 시 돌아갈 위치)
228
- initialY: sy,
229
- j: Math.random() * Math.PI * 2,
230
- };
231
- }
232
- initParticles() {
233
- // 캔버스 전체에 골고루 분포 (여백 없이)
234
- for (const p of this.particles) {
235
- const sx = Math.random() * this.W;
236
- const sy = Math.random() * this.H;
237
- p.x = sx;
238
- p.y = sy;
239
- p.vx = p.vy = 0;
240
- // 초기 위치 저장 (scatter 시 돌아갈 위치)
241
- p.initialX = sx;
242
- p.initialY = sy;
243
- }
244
- }
245
- scatter() {
246
- // 각 파티클을 초기 위치로 돌아가도록 설정
247
- for (const p of this.particles) {
248
- // 초기 위치가 저장되어 있으면 그 위치로, 없으면 현재 위치 유지
249
- if (p.initialX !== undefined && p.initialY !== undefined) {
250
- p.tx = p.initialX;
251
- p.ty = p.initialY;
252
- }
253
- else {
254
- // 초기 위치가 없으면 현재 위치를 초기 위치로 저장
255
- p.initialX = p.x;
256
- p.initialY = p.y;
257
- p.tx = p.initialX;
258
- p.ty = p.initialY;
259
- }
260
- }
261
- }
262
- morph(textOrOptions) {
263
- // 즉시 실행이 필요한 경우 (예: 초기화 시)를 위해 내부 메서드 직접 호출
264
- // 일반적인 경우에는 디바운스 적용
265
- this._debouncedMorph(textOrOptions);
266
- }
267
- _morphInternal(textOrOptions) {
268
- // W와 H가 0이면 resize 먼저 실행
269
- if (this.W === 0 || this.H === 0) {
270
- this.resize();
271
- }
272
- if (typeof textOrOptions === 'string') {
273
- // 문자열인 경우: 기존 동작 유지
274
- this.config.text = textOrOptions;
275
- this.buildTargets();
276
- }
277
- else if (textOrOptions && typeof textOrOptions === 'object') {
278
- // 객체인 경우: 텍스트와 함께 다른 설정도 변경
279
- const needsRebuild = textOrOptions.text !== undefined;
280
- this.config = { ...this.config, ...textOrOptions };
281
- if (needsRebuild) {
282
- this.buildTargets();
283
- }
284
- }
285
- else {
286
- // null이거나 undefined인 경우: 현재 텍스트로 재빌드
287
- this.buildTargets();
288
- }
289
- }
290
- update() {
291
- this.ctx.clearRect(0, 0, this.W, this.H);
292
- for (const p of this.particles) {
293
- // 목표 좌표로 당기는 힘
294
- let ax = (p.tx - p.x) * this.config.ease;
295
- let ay = (p.ty - p.y) * this.config.ease;
296
- // 마우스 반발/흡입
297
- if (this.mouse.x || this.mouse.y) {
298
- const dx = p.x - this.mouse.x;
299
- const dy = p.y - this.mouse.y;
300
- const d2 = dx * dx + dy * dy;
301
- const r = this.config.repelRadius * this.DPR;
302
- if (d2 < r * r) {
303
- const d = Math.sqrt(d2) + 0.0001;
304
- const f = (this.mouse.down ? -1 : 1) * this.config.repelStrength * (1 - d / r);
305
- ax += (dx / d) * f * 6.0;
306
- ay += (dy / d) * f * 6.0;
307
- }
308
- }
309
- // 진동 효과
310
- p.j += 2;
311
- ax += Math.cos(p.j) * 0.05;
312
- ay += Math.sin(p.j * 1.3) * 0.05;
313
- // 속도와 위치 업데이트
314
- p.vx = (p.vx + ax) * Math.random();
315
- p.vy = (p.vy + ay) * Math.random();
316
- p.x += p.vx;
317
- p.y += p.vy;
318
- }
319
- // 파티클 그리기
320
- this.ctx.fillStyle = this.config.particleColor;
321
- const r = this.config.pointSize * this.DPR;
322
- for (const p of this.particles) {
323
- this.ctx.beginPath();
324
- this.ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
325
- this.ctx.fill();
326
- }
327
- if (this.config.onUpdate) {
328
- this.config.onUpdate(this);
329
- }
330
- }
331
- animate() {
332
- if (!this.isRunning)
333
- return;
334
- this.update();
335
- this.animationId = requestAnimationFrame(() => this.animate());
336
- }
337
- start() {
338
- if (this.isRunning)
339
- return;
340
- this.isRunning = true;
341
- this.animate();
342
- }
343
- stop() {
344
- this.isRunning = false;
345
- if (this.animationId) {
346
- cancelAnimationFrame(this.animationId);
347
- this.animationId = null;
348
- }
349
- }
350
- setupEventListeners() {
351
- window.addEventListener('resize', this.handleResize);
352
- this.canvas.addEventListener('mousemove', this.handleMouseMove);
353
- this.canvas.addEventListener('mouseleave', this.handleMouseLeave);
354
- this.canvas.addEventListener('mousedown', this.handleMouseDown);
355
- window.addEventListener('mouseup', this.handleMouseUp);
356
- }
357
- removeEventListeners() {
358
- window.removeEventListener('resize', this.handleResize);
359
- this.canvas.removeEventListener('mousemove', this.handleMouseMove);
360
- this.canvas.removeEventListener('mouseleave', this.handleMouseLeave);
361
- this.canvas.removeEventListener('mousedown', this.handleMouseDown);
362
- window.removeEventListener('mouseup', this.handleMouseUp);
363
- }
364
- handleResize() {
365
- this.resize();
366
- }
367
- handleMouseMove(e) {
368
- const rect = this.canvas.getBoundingClientRect();
369
- this.mouse.x = (e.clientX - rect.left) * this.DPR;
370
- this.mouse.y = (e.clientY - rect.top) * this.DPR;
371
- }
372
- handleMouseLeave() {
373
- this.mouse.x = this.mouse.y = 0;
374
- }
375
- handleMouseDown() {
376
- this.mouse.down = true;
377
- }
378
- handleMouseUp() {
379
- this.mouse.down = false;
380
- }
381
- // 설정 업데이트
382
- updateConfig(newConfig) {
383
- // 디바운스 적용
384
- this._debouncedUpdateConfig(newConfig);
385
- }
386
- _updateConfigInternal(newConfig) {
387
- this.config = { ...this.config, ...newConfig };
388
- if (newConfig.text) {
389
- this.buildTargets();
390
- }
391
- }
392
- // 파괴 및 정리
393
- destroy() {
394
- this.stop();
395
- this.removeEventListeners();
396
- if (this.intersectionObserver) {
397
- this.intersectionObserver.disconnect();
398
- this.intersectionObserver = null;
399
- }
400
- if (this.canvas && this.canvas.parentNode) {
401
- this.canvas.parentNode.removeChild(this.canvas);
402
- }
403
- }
404
- }
405
-
406
- /**
407
- * MasonEffect - 메인 엔트리 포인트
408
- */
409
-
410
- exports.MasonEffect = MasonEffect;
411
- exports.default = MasonEffect;
412
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/core/index.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;AAAA;;;AAGG;AAiCH;AACA,SAAS,QAAQ,CACf,IAAO,EACP,IAAY,EAAA;IAEZ,IAAI,OAAO,GAAyC,IAAI;AACxD,IAAA,OAAO,SAAS,gBAAgB,CAAC,GAAG,IAAmB,EAAA;QACrD,MAAM,KAAK,GAAG,MAAK;YACjB,OAAO,GAAG,IAAI;AACd,YAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AACx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CAAC,KAAK,CAAC,IAAI,GAAG,IAAI;IACxB;IAEA,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK;IACzB;;AAGA,IAAA,YAAY,CAAC,SAAsC,EAAA;;AAEjD,QAAA,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC;IACxC;AAEA,IAAA,qBAAqB,CAAC,SAAsC,EAAA;AAC1D,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE;AAC9C,QAAA,IAAI,SAAS,CAAC,IAAI,EAAE;YAClB,IAAI,CAAC,YAAY,EAAE;QACrB;IACF;;IAGA,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,EAAE;QACX,IAAI,CAAC,oBAAoB,EAAE;AAC3B,QAAA,IAAI,IAAI,CAAC,oBAAoB,EAAE;AAC7B,YAAA,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE;AACtC,YAAA,IAAI,CAAC,oBAAoB,GAAG,IAAI;QAClC;QACA,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACzC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;QACjD;IACF;AACD;;AC9fD;;AAEG;;;;;"}
package/dist/index.min.js DELETED
@@ -1 +0,0 @@
1
- function t(t,s){let i=null;return function(...h){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,h)},s)}}Object.defineProperty(exports,"t",{value:!0});class s{constructor(s,i={}){if(this.container="string"==typeof s?document.querySelector(s):s,!this.container)throw Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const h=this.canvas.getContext("2d");if(!h)throw Error("Canvas context not available");this.ctx=h,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const e=this.offCanvas.getContext("2d");if(!e)throw Error("Offscreen canvas context not available");this.offCtx=e,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=i.debounceDelay??150;const o=this.handleResize.bind(this);this.handleResize=t(o,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.i=t(this.h.bind(this),this.debounceDelay),this.o=t(this.l.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 s of t)s.target===this.container&&(s.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,s=this.config.height||this.container.clientHeight||.7*window.innerHeight;if(0>=t||0>=s)return;this.W=Math.floor(t*this.DPR),this.H=Math.floor(s*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=s+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}buildTargets(){if(0>=this.W||0>=this.H)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 s=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*s));this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${i}px ${this.config.fontFamily}`;const h=t.split(""),e=.05*i,o=this.offCtx.measureText(t).width+e*(h.length-1);let n=this.W/2-o/2;for(const t of h)this.offCtx.fillText(t,n+this.offCtx.measureText(t).width/2,this.H/2),n+=this.offCtx.measureText(t).width+e;const a=Math.max(2,this.config.densityStep),r=this.offCtx.getImageData(0,0,this.W,this.H).data,l=[];for(let t=0;t<this.H;t+=a)for(let s=0;s<this.W;s+=a){const i=4*(t*this.W+s);r[i]+r[i+1]+r[i+2]>600&&l.push({x:s,y:t})}for(;l.length>this.config.maxParticles;)l.splice(Math.floor(Math.random()*l.length),1);if(this.particles.length<l.length){const t=l.length-this.particles.length;for(let s=0;t>s;s++)this.particles.push(this.makeParticle())}else this.particles.length>l.length&&(this.particles.length=l.length);for(let t=0;t<this.particles.length;t++){const s=this.particles[t],i=l[t];s.tx=i.x,s.ty=i.y}}makeParticle(){const t=Math.random()*this.W,s=Math.random()*this.H;return{x:t,y:s,vx:0,vy:0,tx:t,ty:s,initialX:t,initialY:s,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const s=Math.random()*this.W,i=Math.random()*this.H;t.x=s,t.y=i,t.vx=t.vy=0,t.initialX=s,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.i(t)}h(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 s=void 0!==t.text;this.config={...this.config,...t},s&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const t of this.particles){let s=(t.tx-t.x)*this.config.ease,i=(t.ty-t.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const h=t.x-this.mouse.x,e=t.y-this.mouse.y,o=h*h+e*e,n=this.config.repelRadius*this.DPR;if(n*n>o){const t=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-t/n);s+=h/t*a*6,i+=e/t*a*6}}t.j+=2,s+=.05*Math.cos(t.j),i+=.05*Math.sin(1.3*t.j),t.vx=(t.vx+s)*Math.random(),t.vy=(t.vy+i)*Math.random(),t.x+=t.vx,t.y+=t.vy}this.ctx.fillStyle=this.config.particleColor;const t=this.config.pointSize*this.DPR;for(const s of this.particles)this.ctx.beginPath(),this.ctx.arc(s.x,s.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 s=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-s.left)*this.DPR,this.mouse.y=(t.clientY-s.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this.o(t)}l(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)}}exports.MasonEffect=s,exports.default=s;