masoneffect 0.1.11 โ†’ 0.1.13

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 CHANGED
@@ -12,6 +12,8 @@ npm install masoneffect
12
12
 
13
13
  ### Vanilla JavaScript
14
14
 
15
+ #### Using npm (ES modules)
16
+
15
17
  ```javascript
16
18
  import { MasonEffect } from 'masoneffect';
17
19
 
@@ -36,6 +38,22 @@ effect.morph({
36
38
  effect.scatter();
37
39
  ```
38
40
 
41
+ #### Using CDN (UMD)
42
+
43
+ ```html
44
+ <script src="https://cdn.jsdelivr.net/npm/masoneffect@0.1.11/dist/index.umd.min.js"></script>
45
+ <script>
46
+ const container = document.getElementById('my-container');
47
+ const effect = new MasonEffect(container, {
48
+ text: 'Hello World',
49
+ particleColor: '#00ff88',
50
+ maxParticles: 2000,
51
+ });
52
+
53
+ effect.morph('New Text');
54
+ </script>
55
+ ```
56
+
39
57
  ### React
40
58
 
41
59
  ```jsx
@@ -145,13 +163,14 @@ const onReady = (instance) => {
145
163
  | `width` | `number \| null` | `null` | Canvas width (container size if null) |
146
164
  | `height` | `number \| null` | `null` | Canvas height (container size if null) |
147
165
  | `devicePixelRatio` | `number \| null` | `null` | Device pixel ratio (auto if null) |
166
+ | `debounceDelay` | `number` | `150` | Debounce delay in milliseconds for resize, morph, and updateConfig (set to 0 to disable) |
148
167
  | `onReady` | `function` | `null` | Initialization complete callback |
149
168
  | `onUpdate` | `function` | `null` | Update callback |
150
169
 
151
170
  ### Methods
152
171
 
153
172
  #### `morph(textOrOptions?: string | Partial<MasonEffectOptions>)`
154
- Morphs particles into text form.
173
+ Morphs particles into text form. This method is debounced to prevent excessive calls (default: 150ms delay).
155
174
 
156
175
  **Using string:**
157
176
  ```javascript
@@ -169,11 +188,13 @@ effect.morph({
169
188
  });
170
189
  ```
171
190
 
191
+ **Note**: Multiple rapid calls will be debounced, and only the last call will be executed after the delay period.
192
+
172
193
  #### `scatter()`
173
194
  Returns particles to their initial position. Each particle returns to the position where it was first created.
174
195
 
175
196
  #### `updateConfig(config: Partial<MasonEffectOptions>)`
176
- Updates the configuration.
197
+ Updates the configuration. This method is debounced to prevent excessive calls (default: 150ms delay).
177
198
 
178
199
  #### `destroy()`
179
200
  Destroys the instance and cleans up resources.
@@ -184,10 +205,13 @@ Destroys the instance and cleans up resources.
184
205
  - ๐Ÿ–ฑ๏ธ Mouse interaction support (repel/attract)
185
206
  - ๐Ÿ“ฑ Responsive design
186
207
  - โšก High-performance Canvas rendering
187
- - ๐Ÿ”ง Supports React, Vue, and vanilla JS
208
+ - ๐Ÿ”ง Supports React, Vue, and vanilla JS (including CDN)
188
209
  - ๐ŸŽฏ Includes TypeScript type definitions
189
210
  - ๐Ÿ’พ Automatic obfuscation and optimization in production builds
190
211
  - ๐Ÿ”„ Scatter effect that returns to initial position
212
+ - ๐Ÿ‘๏ธ **IntersectionObserver**: Automatically pauses animation when not visible (saves resources)
213
+ - โฑ๏ธ **Debouncing**: Prevents excessive calls on resize, morph, and updateConfig methods
214
+ - ๐ŸŽ›๏ธ **Configurable debounce delay**: Adjust or disable debouncing via `debounceDelay` option
191
215
 
192
216
  ## Development
193
217
 
@@ -209,11 +233,11 @@ npm run serve
209
233
 
210
234
  Running the build will generate the following files:
211
235
 
212
- - **Development**: `dist/index.js`, `dist/index.esm.js` (with source maps)
213
- - **Production**: `dist/index.min.js`, `dist/index.esm.min.js` (obfuscated and optimized)
236
+ - **Development**: `dist/index.js`, `dist/index.esm.js`, `dist/index.umd.js` (with source maps)
237
+ - **Production**: `dist/index.min.js`, `dist/index.esm.min.js`, `dist/index.umd.min.js` (obfuscated and optimized)
214
238
  - **React component**: `dist/react/MasonEffect.min.js` (obfuscated)
215
239
 
216
- When installed via npm, min files are automatically used. For more details, see the [Build Guide](./BUILD.md).
240
+ When installed via npm, min files are automatically used. The UMD files (`index.umd.min.js`) can be used directly in browsers via CDN or script tags. For more details, see the [Build Guide](./BUILD.md).
217
241
 
218
242
  ## License
219
243
 
package/dist/index.esm.js CHANGED
@@ -3,6 +3,19 @@
3
3
  * ๋ฐ”๋‹๋ผ JS ์ฝ”์–ด ํด๋ž˜์Šค
4
4
  */
5
5
 
6
+ // ๋””๋ฐ”์šด์Šค ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
7
+ function debounce(func, wait) {
8
+ let timeout;
9
+ return function executedFunction(...args) {
10
+ const later = () => {
11
+ clearTimeout(timeout);
12
+ func.apply(this, args);
13
+ };
14
+ clearTimeout(timeout);
15
+ timeout = setTimeout(later, wait);
16
+ };
17
+ }
18
+
6
19
  class MasonEffect {
7
20
  constructor(container, options = {}) {
8
21
  // ์ปจํ…Œ์ด๋„ˆ ์š”์†Œ
@@ -51,14 +64,24 @@ class MasonEffect {
51
64
  this.mouse = { x: 0, y: 0, down: false };
52
65
  this.animationId = null;
53
66
  this.isRunning = false;
67
+ this.isVisible = false;
68
+ this.intersectionObserver = null;
54
69
 
55
- // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ
56
- this.handleResize = this.handleResize.bind(this);
70
+ // ๋””๋ฐ”์šด์Šค ์„ค์ • (ms)
71
+ this.debounceDelay = options.debounceDelay ?? 150; // ๊ธฐ๋ณธ 150ms
72
+
73
+ // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ (๋””๋ฐ”์šด์Šค ์ ์šฉ ์ „์— ๋ฐ”์ธ๋”ฉ)
74
+ const boundHandleResize = this.handleResize.bind(this);
75
+ this.handleResize = debounce(boundHandleResize, this.debounceDelay);
57
76
  this.handleMouseMove = this.handleMouseMove.bind(this);
58
77
  this.handleMouseLeave = this.handleMouseLeave.bind(this);
59
78
  this.handleMouseDown = this.handleMouseDown.bind(this);
60
79
  this.handleMouseUp = this.handleMouseUp.bind(this);
61
80
 
81
+ // morph์™€ updateConfig๋ฅผ ์œ„ํ•œ ๋””๋ฐ”์šด์Šค๋œ ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ
82
+ this._debouncedMorph = debounce(this._morphInternal.bind(this), this.debounceDelay);
83
+ this._debouncedUpdateConfig = debounce(this._updateConfigInternal.bind(this), this.debounceDelay);
84
+
62
85
  // ์ดˆ๊ธฐํ™”
63
86
  this.init();
64
87
  }
@@ -66,13 +89,48 @@ class MasonEffect {
66
89
  init() {
67
90
  this.resize();
68
91
  this.setupEventListeners();
69
- this.start();
70
-
92
+ this.setupIntersectionObserver();
93
+
71
94
  if (this.config.onReady) {
72
95
  this.config.onReady(this);
73
96
  }
74
97
  }
75
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
+ // ์ด๋ฏธ ์„ค์ •๋˜์–ด ์žˆ๋‹ค๋ฉด ๋‹ค์‹œ ๋งŒ๋“ค์ง€ ์•Š์Œ
108
+ if (this.intersectionObserver) {
109
+ return;
110
+ }
111
+
112
+ this.intersectionObserver = new IntersectionObserver(
113
+ (entries) => {
114
+ for (const entry of entries) {
115
+ if (entry.target !== this.container) continue;
116
+
117
+ if (entry.isIntersecting) {
118
+ this.isVisible = true;
119
+ this.start();
120
+ } else {
121
+ this.isVisible = false;
122
+ this.stop();
123
+ }
124
+ }
125
+ },
126
+ {
127
+ threshold: 0.1, // 10% ์ด์ƒ ๋ณด์ผ ๋•Œ ๋™์ž‘
128
+ }
129
+ );
130
+
131
+ this.intersectionObserver.observe(this.container);
132
+ }
133
+
76
134
  resize() {
77
135
  const width = this.config.width || this.container.clientWidth || window.innerWidth;
78
136
  const height = this.config.height || this.container.clientHeight || window.innerHeight * 0.7;
@@ -202,6 +260,12 @@ class MasonEffect {
202
260
  }
203
261
 
204
262
  morph(textOrOptions = null) {
263
+ // ์ฆ‰์‹œ ์‹คํ–‰์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ (์˜ˆ: ์ดˆ๊ธฐํ™” ์‹œ)๋ฅผ ์œ„ํ•ด ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ ์ง์ ‘ ํ˜ธ์ถœ
264
+ // ์ผ๋ฐ˜์ ์ธ ๊ฒฝ์šฐ์—๋Š” ๋””๋ฐ”์šด์Šค ์ ์šฉ
265
+ this._debouncedMorph(textOrOptions);
266
+ }
267
+
268
+ _morphInternal(textOrOptions = null) {
205
269
  // W์™€ H๊ฐ€ 0์ด๋ฉด resize ๋จผ์ € ์‹คํ–‰
206
270
  if (this.W === 0 || this.H === 0) {
207
271
  this.resize();
@@ -332,6 +396,11 @@ class MasonEffect {
332
396
 
333
397
  // ์„ค์ • ์—…๋ฐ์ดํŠธ
334
398
  updateConfig(newConfig) {
399
+ // ๋””๋ฐ”์šด์Šค ์ ์šฉ
400
+ this._debouncedUpdateConfig(newConfig);
401
+ }
402
+
403
+ _updateConfigInternal(newConfig) {
335
404
  this.config = { ...this.config, ...newConfig };
336
405
  if (newConfig.text) {
337
406
  this.buildTargets();
@@ -342,11 +411,19 @@ class MasonEffect {
342
411
  destroy() {
343
412
  this.stop();
344
413
  this.removeEventListeners();
414
+ if (this.intersectionObserver) {
415
+ this.intersectionObserver.disconnect();
416
+ this.intersectionObserver = null;
417
+ }
345
418
  if (this.canvas && this.canvas.parentNode) {
346
419
  this.canvas.parentNode.removeChild(this.canvas);
347
420
  }
348
421
  }
349
422
  }
350
423
 
424
+ /**
425
+ * MasonEffect - ๋ฉ”์ธ ์—”ํŠธ๋ฆฌ ํฌ์ธํŠธ
426
+ */
427
+
351
428
  export { MasonEffect, MasonEffect as default };
352
429
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/core/index.js"],"sourcesContent":["/**\n * MasonEffect - ํŒŒํ‹ฐํด ๋ชจํ•‘ ํšจ๊ณผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ\n * ๋ฐ”๋‹๋ผ JS ์ฝ”์–ด ํด๋ž˜์Šค\n */\n\nexport class MasonEffect {\n constructor(container, options = {}) {\n // ์ปจํ…Œ์ด๋„ˆ ์š”์†Œ\n this.container = typeof container === 'string' \n ? document.querySelector(container) \n : container;\n \n if (!this.container) {\n throw new Error('Container element not found');\n }\n\n // ์„ค์ •๊ฐ’๋“ค\n this.config = {\n text: options.text || 'mason effect',\n densityStep: options.densityStep ?? 2,\n maxParticles: options.maxParticles ?? 3200,\n pointSize: options.pointSize ?? 0.5,\n ease: options.ease ?? 0.05,\n repelRadius: options.repelRadius ?? 150,\n repelStrength: options.repelStrength ?? 1,\n particleColor: options.particleColor || '#fff',\n fontFamily: options.fontFamily || 'Inter, system-ui, Arial',\n fontSize: options.fontSize || null, // null์ด๋ฉด ์ž๋™ ๊ณ„์‚ฐ\n width: options.width || null, // null์ด๋ฉด ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ\n height: options.height || null, // null์ด๋ฉด ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ\n devicePixelRatio: options.devicePixelRatio ?? null, // null์ด๋ฉด ์ž๋™\n onReady: options.onReady || null,\n onUpdate: options.onUpdate || null,\n };\n\n // ์บ”๋ฒ„์Šค ์ƒ์„ฑ\n this.canvas = document.createElement('canvas');\n this.ctx = this.canvas.getContext('2d');\n this.container.appendChild(this.canvas);\n this.canvas.style.display = 'block';\n\n // ์˜คํ”„์Šคํฌ๋ฆฐ ์บ”๋ฒ„์Šค (ํ…์ŠคํŠธ ๋ Œ๋”๋ง์šฉ)\n this.offCanvas = document.createElement('canvas');\n this.offCtx = this.offCanvas.getContext('2d');\n\n // ์ƒํƒœ\n this.W = 0;\n this.H = 0;\n this.DPR = this.config.devicePixelRatio || Math.min(window.devicePixelRatio || 1, 1.8);\n this.particles = [];\n this.mouse = { x: 0, y: 0, down: false };\n this.animationId = null;\n this.isRunning = false;\n\n // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ\n this.handleResize = this.handleResize.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n\n // ์ดˆ๊ธฐํ™”\n this.init();\n }\n\n init() {\n this.resize();\n this.setupEventListeners();\n this.start();\n \n if (this.config.onReady) {\n this.config.onReady(this);\n }\n }\n\n resize() {\n const width = this.config.width || this.container.clientWidth || window.innerWidth;\n const height = this.config.height || this.container.clientHeight || window.innerHeight * 0.7;\n \n this.W = Math.floor(width * this.DPR);\n this.H = Math.floor(height * this.DPR);\n \n this.canvas.width = this.W;\n this.canvas.height = this.H;\n this.canvas.style.width = width + 'px';\n this.canvas.style.height = height + 'px';\n\n this.buildTargets();\n if (!this.particles.length) {\n this.initParticles();\n }\n }\n\n buildTargets() {\n const text = this.config.text;\n this.offCanvas.width = this.W;\n this.offCanvas.height = this.H;\n this.offCtx.clearRect(0, 0, this.offCanvas.width, this.offCanvas.height);\n\n const base = Math.min(this.W, this.H);\n const fontSize = this.config.fontSize || Math.max(80, Math.floor(base * 0.18));\n this.offCtx.fillStyle = '#ffffff';\n this.offCtx.textAlign = 'center';\n this.offCtx.textBaseline = 'middle';\n this.offCtx.font = `400 ${fontSize}px ${this.config.fontFamily}`;\n\n // ๊ธ€์ž ๊ฐ„๊ฒฉ ๊ณ„์‚ฐ ๋ฐ ๊ทธ๋ฆฌ๊ธฐ\n const chars = text.split('');\n const spacing = fontSize * 0.05;\n const totalWidth = this.offCtx.measureText(text).width + spacing * (chars.length - 1);\n let x = this.W / 2 - totalWidth / 2;\n \n for (const ch of chars) {\n this.offCtx.fillText(ch, x + this.offCtx.measureText(ch).width / 2, this.H / 2);\n x += this.offCtx.measureText(ch).width + spacing;\n }\n\n // ํ”ฝ์…€ ์ƒ˜ํ”Œ๋ง\n const step = Math.max(2, this.config.densityStep);\n const img = this.offCtx.getImageData(0, 0, this.W, this.H).data;\n const targets = [];\n \n for (let y = 0; y < this.H; y += step) {\n for (let x = 0; x < this.W; x += step) {\n const i = (y * this.W + x) * 4;\n if (img[i] + img[i + 1] + img[i + 2] > 600) {\n targets.push({ x, y });\n }\n }\n }\n\n // ํŒŒํ‹ฐํด ์ˆ˜ ์ œํ•œ\n while (targets.length > this.config.maxParticles) {\n targets.splice(Math.floor(Math.random() * targets.length), 1);\n }\n\n // ํŒŒํ‹ฐํด ์ˆ˜ ์กฐ์ •\n if (this.particles.length < targets.length) {\n const need = targets.length - this.particles.length;\n for (let i = 0; i < need; i++) {\n this.particles.push(this.makeParticle());\n }\n } else if (this.particles.length > targets.length) {\n this.particles.length = targets.length;\n }\n\n // ๋ชฉํ‘œ ์ขŒํ‘œ ํ• ๋‹น\n for (let i = 0; i < this.particles.length; i++) {\n const p = this.particles[i];\n const t = targets[i];\n p.tx = t.x;\n p.ty = t.y;\n }\n }\n\n makeParticle() {\n // ์บ”๋ฒ„์Šค ์ „์ฒด์— ๊ณจ๊ณ ๋ฃจ ๋ถ„ํฌ (์—ฌ๋ฐฑ ์—†์ด)\n const sx = Math.random() * this.W;\n const sy = Math.random() * this.H;\n return {\n x: sx,\n y: sy,\n vx: 0,\n vy: 0,\n tx: sx,\n ty: sy,\n initialX: sx, // ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ (scatter ์‹œ ๋Œ์•„๊ฐˆ ์œ„์น˜)\n initialY: sy,\n j: Math.random() * Math.PI * 2,\n };\n }\n\n initParticles() {\n // ์บ”๋ฒ„์Šค ์ „์ฒด์— ๊ณจ๊ณ ๋ฃจ ๋ถ„ํฌ (์—ฌ๋ฐฑ ์—†์ด)\n for (const p of this.particles) {\n const sx = Math.random() * this.W;\n const sy = Math.random() * this.H;\n p.x = sx;\n p.y = sy;\n p.vx = p.vy = 0;\n // ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ (scatter ์‹œ ๋Œ์•„๊ฐˆ ์œ„์น˜)\n p.initialX = sx;\n p.initialY = sy;\n }\n }\n\n scatter() {\n // ๊ฐ ํŒŒํ‹ฐํด์„ ์ดˆ๊ธฐ ์œ„์น˜๋กœ ๋Œ์•„๊ฐ€๋„๋ก ์„ค์ •\n for (const p of this.particles) {\n // ์ดˆ๊ธฐ ์œ„์น˜๊ฐ€ ์ €์žฅ๋˜์–ด ์žˆ์œผ๋ฉด ๊ทธ ์œ„์น˜๋กœ, ์—†์œผ๋ฉด ํ˜„์žฌ ์œ„์น˜ ์œ ์ง€\n if (p.initialX !== undefined && p.initialY !== undefined) {\n p.tx = p.initialX;\n p.ty = p.initialY;\n } else {\n // ์ดˆ๊ธฐ ์œ„์น˜๊ฐ€ ์—†์œผ๋ฉด ํ˜„์žฌ ์œ„์น˜๋ฅผ ์ดˆ๊ธฐ ์œ„์น˜๋กœ ์ €์žฅ\n p.initialX = p.x;\n p.initialY = p.y;\n p.tx = p.initialX;\n p.ty = p.initialY;\n }\n }\n }\n\n morph(textOrOptions = null) {\n // W์™€ H๊ฐ€ 0์ด๋ฉด resize ๋จผ์ € ์‹คํ–‰\n if (this.W === 0 || this.H === 0) {\n this.resize();\n }\n \n if (typeof textOrOptions === 'string') {\n // ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ: ๊ธฐ์กด ๋™์ž‘ ์œ ์ง€\n this.config.text = textOrOptions;\n this.buildTargets();\n } else if (textOrOptions && typeof textOrOptions === 'object') {\n // ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ: ํ…์ŠคํŠธ์™€ ํ•จ๊ป˜ ๋‹ค๋ฅธ ์„ค์ •๋„ ๋ณ€๊ฒฝ\n const needsRebuild = textOrOptions.text !== undefined;\n this.config = { ...this.config, ...textOrOptions };\n if (needsRebuild) {\n this.buildTargets();\n }\n } else {\n // null์ด๊ฑฐ๋‚˜ undefined์ธ ๊ฒฝ์šฐ: ํ˜„์žฌ ํ…์ŠคํŠธ๋กœ ์žฌ๋นŒ๋“œ\n this.buildTargets();\n }\n }\n\n update() {\n this.ctx.clearRect(0, 0, this.W, this.H);\n\n for (const p of this.particles) {\n // ๋ชฉํ‘œ ์ขŒํ‘œ๋กœ ๋‹น๊ธฐ๋Š” ํž˜\n let ax = (p.tx - p.x) * this.config.ease;\n let ay = (p.ty - p.y) * this.config.ease;\n\n // ๋งˆ์šฐ์Šค ๋ฐ˜๋ฐœ/ํก์ž…\n if (this.mouse.x || this.mouse.y) {\n const dx = p.x - this.mouse.x;\n const dy = p.y - this.mouse.y;\n const d2 = dx * dx + dy * dy;\n const r = this.config.repelRadius * this.DPR;\n if (d2 < r * r) {\n const d = Math.sqrt(d2) + 0.0001;\n const f = (this.mouse.down ? -1 : 1) * this.config.repelStrength * (1 - d / r);\n ax += (dx / d) * f * 6.0;\n ay += (dy / d) * f * 6.0;\n }\n }\n\n // ์ง„๋™ ํšจ๊ณผ\n p.j += 2;\n ax += Math.cos(p.j) * 0.05;\n ay += Math.sin(p.j * 1.3) * 0.05;\n\n // ์†๋„์™€ ์œ„์น˜ ์—…๋ฐ์ดํŠธ\n p.vx = (p.vx + ax) * Math.random();\n p.vy = (p.vy + ay) * Math.random();\n p.x += p.vx;\n p.y += p.vy;\n }\n\n // ํŒŒํ‹ฐํด ๊ทธ๋ฆฌ๊ธฐ\n this.ctx.fillStyle = this.config.particleColor;\n const r = this.config.pointSize * this.DPR;\n for (const p of this.particles) {\n this.ctx.beginPath();\n this.ctx.arc(p.x, p.y, r, 0, Math.PI * 2);\n this.ctx.fill();\n }\n\n if (this.config.onUpdate) {\n this.config.onUpdate(this);\n }\n }\n\n animate() {\n if (!this.isRunning) return;\n this.update();\n this.animationId = requestAnimationFrame(() => this.animate());\n }\n\n start() {\n if (this.isRunning) return;\n this.isRunning = true;\n this.animate();\n }\n\n stop() {\n this.isRunning = false;\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationId = null;\n }\n }\n\n setupEventListeners() {\n window.addEventListener('resize', this.handleResize);\n this.canvas.addEventListener('mousemove', this.handleMouseMove);\n this.canvas.addEventListener('mouseleave', this.handleMouseLeave);\n this.canvas.addEventListener('mousedown', this.handleMouseDown);\n window.addEventListener('mouseup', this.handleMouseUp);\n }\n\n removeEventListeners() {\n window.removeEventListener('resize', this.handleResize);\n this.canvas.removeEventListener('mousemove', this.handleMouseMove);\n this.canvas.removeEventListener('mouseleave', this.handleMouseLeave);\n this.canvas.removeEventListener('mousedown', this.handleMouseDown);\n window.removeEventListener('mouseup', this.handleMouseUp);\n }\n\n handleResize() {\n this.resize();\n }\n\n handleMouseMove(e) {\n const rect = this.canvas.getBoundingClientRect();\n this.mouse.x = (e.clientX - rect.left) * this.DPR;\n this.mouse.y = (e.clientY - rect.top) * this.DPR;\n }\n\n handleMouseLeave() {\n this.mouse.x = this.mouse.y = 0;\n }\n\n handleMouseDown() {\n this.mouse.down = true;\n }\n\n handleMouseUp() {\n this.mouse.down = false;\n }\n\n // ์„ค์ • ์—…๋ฐ์ดํŠธ\n updateConfig(newConfig) {\n this.config = { ...this.config, ...newConfig };\n if (newConfig.text) {\n this.buildTargets();\n }\n }\n\n // ํŒŒ๊ดด ๋ฐ ์ •๋ฆฌ\n destroy() {\n this.stop();\n this.removeEventListeners();\n if (this.canvas && this.canvas.parentNode) {\n this.canvas.parentNode.removeChild(this.canvas);\n }\n }\n}\n\n// ๊ธฐ๋ณธ export\nexport default MasonEffect;\n\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;;AAEO,MAAM,WAAW,CAAC;AACzB,EAAE,WAAW,CAAC,SAAS,EAAE,OAAO,GAAG,EAAE,EAAE;AACvC;AACA,IAAI,IAAI,CAAC,SAAS,GAAG,OAAO,SAAS,KAAK,QAAQ;AAClD,QAAQ,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC;AACzC,QAAQ,SAAS;AACjB;AACA,IAAI,IAAI,CAAC,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IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;AACrD,IAAI;AACJ,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/core/index.js","../src/index.js"],"sourcesContent":["/**\n * MasonEffect - ํŒŒํ‹ฐํด ๋ชจํ•‘ ํšจ๊ณผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ\n * ๋ฐ”๋‹๋ผ JS ์ฝ”์–ด ํด๋ž˜์Šค\n */\n\n// ๋””๋ฐ”์šด์Šค ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜\nfunction debounce(func, wait) {\n let timeout;\n return function executedFunction(...args) {\n const later = () => {\n clearTimeout(timeout);\n func.apply(this, args);\n };\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n}\n\nexport class MasonEffect {\n constructor(container, options = {}) {\n // ์ปจํ…Œ์ด๋„ˆ ์š”์†Œ\n this.container = typeof container === 'string' \n ? document.querySelector(container) \n : container;\n \n if (!this.container) {\n throw new Error('Container element not found');\n }\n\n // ์„ค์ •๊ฐ’๋“ค\n this.config = {\n text: options.text || 'mason effect',\n densityStep: options.densityStep ?? 2,\n maxParticles: options.maxParticles ?? 3200,\n pointSize: options.pointSize ?? 0.5,\n ease: options.ease ?? 0.05,\n repelRadius: options.repelRadius ?? 150,\n repelStrength: options.repelStrength ?? 1,\n particleColor: options.particleColor || '#fff',\n fontFamily: options.fontFamily || 'Inter, system-ui, Arial',\n fontSize: options.fontSize || null, // null์ด๋ฉด ์ž๋™ ๊ณ„์‚ฐ\n width: options.width || null, // null์ด๋ฉด ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ\n height: options.height || null, // null์ด๋ฉด ์ปจํ…Œ์ด๋„ˆ ํฌ๊ธฐ\n devicePixelRatio: options.devicePixelRatio ?? null, // null์ด๋ฉด ์ž๋™\n onReady: options.onReady || null,\n onUpdate: options.onUpdate || null,\n };\n\n // ์บ”๋ฒ„์Šค ์ƒ์„ฑ\n this.canvas = document.createElement('canvas');\n this.ctx = this.canvas.getContext('2d');\n this.container.appendChild(this.canvas);\n this.canvas.style.display = 'block';\n\n // ์˜คํ”„์Šคํฌ๋ฆฐ ์บ”๋ฒ„์Šค (ํ…์ŠคํŠธ ๋ Œ๋”๋ง์šฉ)\n this.offCanvas = document.createElement('canvas');\n this.offCtx = this.offCanvas.getContext('2d');\n\n // ์ƒํƒœ\n this.W = 0;\n this.H = 0;\n this.DPR = this.config.devicePixelRatio || Math.min(window.devicePixelRatio || 1, 1.8);\n this.particles = [];\n this.mouse = { x: 0, y: 0, down: false };\n this.animationId = null;\n this.isRunning = false;\n this.isVisible = false;\n this.intersectionObserver = null;\n\n // ๋””๋ฐ”์šด์Šค ์„ค์ • (ms)\n this.debounceDelay = options.debounceDelay ?? 150; // ๊ธฐ๋ณธ 150ms\n\n // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ (๋””๋ฐ”์šด์Šค ์ ์šฉ ์ „์— ๋ฐ”์ธ๋”ฉ)\n const boundHandleResize = this.handleResize.bind(this);\n this.handleResize = debounce(boundHandleResize, this.debounceDelay);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n\n // morph์™€ updateConfig๋ฅผ ์œ„ํ•œ ๋””๋ฐ”์šด์Šค๋œ ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ\n this._debouncedMorph = debounce(this._morphInternal.bind(this), this.debounceDelay);\n this._debouncedUpdateConfig = debounce(this._updateConfigInternal.bind(this), this.debounceDelay);\n\n // ์ดˆ๊ธฐํ™”\n this.init();\n }\n\n init() {\n this.resize();\n this.setupEventListeners();\n this.setupIntersectionObserver();\n\n if (this.config.onReady) {\n this.config.onReady(this);\n }\n }\n\n setupIntersectionObserver() {\n // IntersectionObserver๊ฐ€ ์ง€์›๋˜์ง€ ์•Š๋Š” ํ™˜๊ฒฝ์—์„œ๋Š” ํ•ญ์ƒ ์žฌ์ƒ\n if (typeof window === 'undefined' || typeof window.IntersectionObserver === 'undefined') {\n this.isVisible = true;\n this.start();\n return;\n }\n\n // ์ด๋ฏธ ์„ค์ •๋˜์–ด ์žˆ๋‹ค๋ฉด ๋‹ค์‹œ ๋งŒ๋“ค์ง€ ์•Š์Œ\n if (this.intersectionObserver) {\n return;\n }\n\n this.intersectionObserver = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.target !== this.container) continue;\n\n if (entry.isIntersecting) {\n this.isVisible = true;\n this.start();\n } else {\n this.isVisible = false;\n this.stop();\n }\n }\n },\n {\n threshold: 0.1, // 10% ์ด์ƒ ๋ณด์ผ ๋•Œ ๋™์ž‘\n }\n );\n\n this.intersectionObserver.observe(this.container);\n }\n\n resize() {\n const width = this.config.width || this.container.clientWidth || window.innerWidth;\n const height = this.config.height || this.container.clientHeight || window.innerHeight * 0.7;\n \n this.W = Math.floor(width * this.DPR);\n this.H = Math.floor(height * this.DPR);\n \n this.canvas.width = this.W;\n this.canvas.height = this.H;\n this.canvas.style.width = width + 'px';\n this.canvas.style.height = height + 'px';\n\n this.buildTargets();\n if (!this.particles.length) {\n this.initParticles();\n }\n }\n\n buildTargets() {\n const text = this.config.text;\n this.offCanvas.width = this.W;\n this.offCanvas.height = this.H;\n this.offCtx.clearRect(0, 0, this.offCanvas.width, this.offCanvas.height);\n\n const base = Math.min(this.W, this.H);\n const fontSize = this.config.fontSize || Math.max(80, Math.floor(base * 0.18));\n this.offCtx.fillStyle = '#ffffff';\n this.offCtx.textAlign = 'center';\n this.offCtx.textBaseline = 'middle';\n this.offCtx.font = `400 ${fontSize}px ${this.config.fontFamily}`;\n\n // ๊ธ€์ž ๊ฐ„๊ฒฉ ๊ณ„์‚ฐ ๋ฐ ๊ทธ๋ฆฌ๊ธฐ\n const chars = text.split('');\n const spacing = fontSize * 0.05;\n const totalWidth = this.offCtx.measureText(text).width + spacing * (chars.length - 1);\n let x = this.W / 2 - totalWidth / 2;\n \n for (const ch of chars) {\n this.offCtx.fillText(ch, x + this.offCtx.measureText(ch).width / 2, this.H / 2);\n x += this.offCtx.measureText(ch).width + spacing;\n }\n\n // ํ”ฝ์…€ ์ƒ˜ํ”Œ๋ง\n const step = Math.max(2, this.config.densityStep);\n const img = this.offCtx.getImageData(0, 0, this.W, this.H).data;\n const targets = [];\n \n for (let y = 0; y < this.H; y += step) {\n for (let x = 0; x < this.W; x += step) {\n const i = (y * this.W + x) * 4;\n if (img[i] + img[i + 1] + img[i + 2] > 600) {\n targets.push({ x, y });\n }\n }\n }\n\n // ํŒŒํ‹ฐํด ์ˆ˜ ์ œํ•œ\n while (targets.length > this.config.maxParticles) {\n targets.splice(Math.floor(Math.random() * targets.length), 1);\n }\n\n // ํŒŒํ‹ฐํด ์ˆ˜ ์กฐ์ •\n if (this.particles.length < targets.length) {\n const need = targets.length - this.particles.length;\n for (let i = 0; i < need; i++) {\n this.particles.push(this.makeParticle());\n }\n } else if (this.particles.length > targets.length) {\n this.particles.length = targets.length;\n }\n\n // ๋ชฉํ‘œ ์ขŒํ‘œ ํ• ๋‹น\n for (let i = 0; i < this.particles.length; i++) {\n const p = this.particles[i];\n const t = targets[i];\n p.tx = t.x;\n p.ty = t.y;\n }\n }\n\n makeParticle() {\n // ์บ”๋ฒ„์Šค ์ „์ฒด์— ๊ณจ๊ณ ๋ฃจ ๋ถ„ํฌ (์—ฌ๋ฐฑ ์—†์ด)\n const sx = Math.random() * this.W;\n const sy = Math.random() * this.H;\n return {\n x: sx,\n y: sy,\n vx: 0,\n vy: 0,\n tx: sx,\n ty: sy,\n initialX: sx, // ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ (scatter ์‹œ ๋Œ์•„๊ฐˆ ์œ„์น˜)\n initialY: sy,\n j: Math.random() * Math.PI * 2,\n };\n }\n\n initParticles() {\n // ์บ”๋ฒ„์Šค ์ „์ฒด์— ๊ณจ๊ณ ๋ฃจ ๋ถ„ํฌ (์—ฌ๋ฐฑ ์—†์ด)\n for (const p of this.particles) {\n const sx = Math.random() * this.W;\n const sy = Math.random() * this.H;\n p.x = sx;\n p.y = sy;\n p.vx = p.vy = 0;\n // ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ (scatter ์‹œ ๋Œ์•„๊ฐˆ ์œ„์น˜)\n p.initialX = sx;\n p.initialY = sy;\n }\n }\n\n scatter() {\n // ๊ฐ ํŒŒํ‹ฐํด์„ ์ดˆ๊ธฐ ์œ„์น˜๋กœ ๋Œ์•„๊ฐ€๋„๋ก ์„ค์ •\n for (const p of this.particles) {\n // ์ดˆ๊ธฐ ์œ„์น˜๊ฐ€ ์ €์žฅ๋˜์–ด ์žˆ์œผ๋ฉด ๊ทธ ์œ„์น˜๋กœ, ์—†์œผ๋ฉด ํ˜„์žฌ ์œ„์น˜ ์œ ์ง€\n if (p.initialX !== undefined && p.initialY !== undefined) {\n p.tx = p.initialX;\n p.ty = p.initialY;\n } else {\n // ์ดˆ๊ธฐ ์œ„์น˜๊ฐ€ ์—†์œผ๋ฉด ํ˜„์žฌ ์œ„์น˜๋ฅผ ์ดˆ๊ธฐ ์œ„์น˜๋กœ ์ €์žฅ\n p.initialX = p.x;\n p.initialY = p.y;\n p.tx = p.initialX;\n p.ty = p.initialY;\n }\n }\n }\n\n morph(textOrOptions = null) {\n // ์ฆ‰์‹œ ์‹คํ–‰์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ (์˜ˆ: ์ดˆ๊ธฐํ™” ์‹œ)๋ฅผ ์œ„ํ•ด ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ ์ง์ ‘ ํ˜ธ์ถœ\n // ์ผ๋ฐ˜์ ์ธ ๊ฒฝ์šฐ์—๋Š” ๋””๋ฐ”์šด์Šค ์ ์šฉ\n this._debouncedMorph(textOrOptions);\n }\n\n _morphInternal(textOrOptions = null) {\n // W์™€ H๊ฐ€ 0์ด๋ฉด resize ๋จผ์ € ์‹คํ–‰\n if (this.W === 0 || this.H === 0) {\n this.resize();\n }\n \n if (typeof textOrOptions === 'string') {\n // ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ: ๊ธฐ์กด ๋™์ž‘ ์œ ์ง€\n this.config.text = textOrOptions;\n this.buildTargets();\n } else if (textOrOptions && typeof textOrOptions === 'object') {\n // ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ: ํ…์ŠคํŠธ์™€ ํ•จ๊ป˜ ๋‹ค๋ฅธ ์„ค์ •๋„ ๋ณ€๊ฒฝ\n const needsRebuild = textOrOptions.text !== undefined;\n this.config = { ...this.config, ...textOrOptions };\n if (needsRebuild) {\n this.buildTargets();\n }\n } else {\n // null์ด๊ฑฐ๋‚˜ undefined์ธ ๊ฒฝ์šฐ: ํ˜„์žฌ ํ…์ŠคํŠธ๋กœ ์žฌ๋นŒ๋“œ\n this.buildTargets();\n }\n }\n\n update() {\n this.ctx.clearRect(0, 0, this.W, this.H);\n\n for (const p of this.particles) {\n // ๋ชฉํ‘œ ์ขŒํ‘œ๋กœ ๋‹น๊ธฐ๋Š” ํž˜\n let ax = (p.tx - p.x) * this.config.ease;\n let ay = (p.ty - p.y) * this.config.ease;\n\n // ๋งˆ์šฐ์Šค ๋ฐ˜๋ฐœ/ํก์ž…\n if (this.mouse.x || this.mouse.y) {\n const dx = p.x - this.mouse.x;\n const dy = p.y - this.mouse.y;\n const d2 = dx * dx + dy * dy;\n const r = this.config.repelRadius * this.DPR;\n if (d2 < r * r) {\n const d = Math.sqrt(d2) + 0.0001;\n const f = (this.mouse.down ? -1 : 1) * this.config.repelStrength * (1 - d / r);\n ax += (dx / d) * f * 6.0;\n ay += (dy / d) * f * 6.0;\n }\n }\n\n // ์ง„๋™ ํšจ๊ณผ\n p.j += 2;\n ax += Math.cos(p.j) * 0.05;\n ay += Math.sin(p.j * 1.3) * 0.05;\n\n // ์†๋„์™€ ์œ„์น˜ ์—…๋ฐ์ดํŠธ\n p.vx = (p.vx + ax) * Math.random();\n p.vy = (p.vy + ay) * Math.random();\n p.x += p.vx;\n p.y += p.vy;\n }\n\n // ํŒŒํ‹ฐํด ๊ทธ๋ฆฌ๊ธฐ\n this.ctx.fillStyle = this.config.particleColor;\n const r = this.config.pointSize * this.DPR;\n for (const p of this.particles) {\n this.ctx.beginPath();\n this.ctx.arc(p.x, p.y, r, 0, Math.PI * 2);\n this.ctx.fill();\n }\n\n if (this.config.onUpdate) {\n this.config.onUpdate(this);\n }\n }\n\n animate() {\n if (!this.isRunning) return;\n this.update();\n this.animationId = requestAnimationFrame(() => this.animate());\n }\n\n start() {\n if (this.isRunning) return;\n this.isRunning = true;\n this.animate();\n }\n\n stop() {\n this.isRunning = false;\n if (this.animationId) {\n cancelAnimationFrame(this.animationId);\n this.animationId = null;\n }\n }\n\n setupEventListeners() {\n window.addEventListener('resize', this.handleResize);\n this.canvas.addEventListener('mousemove', this.handleMouseMove);\n this.canvas.addEventListener('mouseleave', this.handleMouseLeave);\n this.canvas.addEventListener('mousedown', this.handleMouseDown);\n window.addEventListener('mouseup', this.handleMouseUp);\n }\n\n removeEventListeners() {\n window.removeEventListener('resize', this.handleResize);\n this.canvas.removeEventListener('mousemove', this.handleMouseMove);\n this.canvas.removeEventListener('mouseleave', this.handleMouseLeave);\n this.canvas.removeEventListener('mousedown', this.handleMouseDown);\n window.removeEventListener('mouseup', this.handleMouseUp);\n }\n\n handleResize() {\n this.resize();\n }\n\n handleMouseMove(e) {\n const rect = this.canvas.getBoundingClientRect();\n this.mouse.x = (e.clientX - rect.left) * this.DPR;\n this.mouse.y = (e.clientY - rect.top) * this.DPR;\n }\n\n handleMouseLeave() {\n this.mouse.x = this.mouse.y = 0;\n }\n\n handleMouseDown() {\n this.mouse.down = true;\n }\n\n handleMouseUp() {\n this.mouse.down = false;\n }\n\n // ์„ค์ • ์—…๋ฐ์ดํŠธ\n updateConfig(newConfig) {\n // ๋””๋ฐ”์šด์Šค ์ ์šฉ\n this._debouncedUpdateConfig(newConfig);\n }\n\n _updateConfigInternal(newConfig) {\n this.config = { ...this.config, ...newConfig };\n if (newConfig.text) {\n this.buildTargets();\n }\n }\n\n // ํŒŒ๊ดด ๋ฐ ์ •๋ฆฌ\n destroy() {\n this.stop();\n this.removeEventListeners();\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n this.intersectionObserver = null;\n }\n if (this.canvas && this.canvas.parentNode) {\n this.canvas.parentNode.removeChild(this.canvas);\n }\n }\n}\n\n// ๊ธฐ๋ณธ export\nexport default MasonEffect;\n\n","/**\n * MasonEffect - ๋ฉ”์ธ ์—”ํŠธ๋ฆฌ ํฌ์ธํŠธ\n */\n\nimport MasonEffect from './core/index.js';\n\n// Named export\nexport { MasonEffect };\n\n// Default export (UMD ๋นŒ๋“œ์—์„œ ์ „์—ญ ๋ณ€์ˆ˜๋กœ ์ง์ ‘ ๋…ธ์ถœ๋จ)\n// CDN ์‚ฌ์šฉ ์‹œ: new MasonEffect()๋กœ ์ง์ ‘ ์‚ฌ์šฉ ๊ฐ€๋Šฅ\nexport default MasonEffect;\n\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA,SAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE;AAC9B,EAAE,IAAI,OAAO;AACb,EAAE,OAAO,SAAS,gBAAgB,CAAC,GAAG,IAAI,EAAE;AAC5C,IAAI,MAAM,KAAK,GAAG,MAAM;AACxB,MAAM,YAAY,CAAC,OAAO,CAAC;AAC3B,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC5B,IAAI,CAAC;AACL,IAAI,YAAY,CAAC,OAAO,CAAC;AACzB,IAAI,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;AACrC,EAAE,CAAC;AACH;;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AAC,GAAG,CAAC;AACnC,EAAE;;AAEF,EAAE,eAAe,GAAG;AACpB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI;AAC1B,EAAE;;AAEF,EAAE,aAAa,GAAG;AAClB,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK;AAC3B,EAAE;;AAEF;AACA,EAAE,YAAY,CAAC,SAAS,EAAE;AAC1B;AACA,IAAI,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC;AAC1C,EAAE;;AAEF,EAAE,qBAAqB,CAAC,SAAS,EAAE;AACnC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE;AAClD,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE;AACxB,MAAM,IAAI,CAAC,YAAY,EAAE;AACzB,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,OAAO,GAAG;AACZ,IAAI,IAAI,CAAC,IAAI,EAAE;AACf,IAAI,IAAI,CAAC,oBAAoB,EAAE;AAC/B,IAAI,IAAI,IAAI,CAAC,oBAAoB,EAAE;AACnC,MAAM,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE;AAC5C,MAAM,IAAI,CAAC,oBAAoB,GAAG,IAAI;AACtC,IAAI;AACJ,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;AACrD,IAAI;AACJ,EAAE;AACF;;ACraA;AACA;AACA;;;;"}
@@ -1 +1 @@
1
- class t{constructor(t,s={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw Error("Container element not found");this.config={text:s.text||"mason effect",densityStep:s.densityStep??2,maxParticles:s.maxParticles??3200,pointSize:s.pointSize??.5,ease:s.ease??.05,repelRadius:s.repelRadius??150,repelStrength:s.repelStrength??1,particleColor:s.particleColor||"#fff",fontFamily:s.fontFamily||"Inter, system-ui, Arial",fontSize:s.fontSize||null,width:s.width||null,height:s.height||null,devicePixelRatio:s.devicePixelRatio??null,onReady:s.onReady||null,onUpdate:s.onUpdate||null},this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas"),this.offCtx=this.offCanvas.getContext("2d"),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.handleResize=this.handleResize.bind(this),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.init()}init(){this.resize(),this.setupEventListeners(),this.start(),this.config.onReady&&this.config.onReady(this)}resize(){const t=this.config.width||this.container.clientWidth||window.innerWidth,s=this.config.height||this.container.clientHeight||.7*window.innerHeight;this.W=Math.floor(t*this.DPR),this.H=Math.floor(s*this.DPR),this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=s+"px",this.buildTargets(),this.particles.length||this.initParticles()}buildTargets(){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),l=this.offCtx.getImageData(0,0,this.W,this.H).data,r=[];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);l[i]+l[i+1]+l[i+2]>600&&r.push({x:s,y:t})}for(;r.length>this.config.maxParticles;)r.splice(Math.floor(Math.random()*r.length),1);if(this.particles.length<r.length){const t=r.length-this.particles.length;for(let s=0;t>s;s++)this.particles.push(this.makeParticle())}else this.particles.length>r.length&&(this.particles.length=r.length);for(let t=0;t<this.particles.length;t++){const s=this.particles[t],i=r[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=null){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.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}export{t as MasonEffect,t as default};
1
+ function t(t,s){let i;return function(...h){clearTimeout(i),i=setTimeout(()=>{clearTimeout(i),t.apply(this,h)},s)}}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"),this.ctx=this.canvas.getContext("2d"),this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas"),this.offCtx=this.offCanvas.getContext("2d"),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 h=this.handleResize.bind(this);this.handleResize=t(h,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.t=t(this.i.bind(this),this.debounceDelay),this.h=t(this.o.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;this.W=Math.floor(t*this.DPR),this.H=Math.floor(s*this.DPR),this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=s+"px",this.buildTargets(),this.particles.length||this.initParticles()}buildTargets(){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),l=this.offCtx.getImageData(0,0,this.W,this.H).data,r=[];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);l[i]+l[i+1]+l[i+2]>600&&r.push({x:s,y:t})}for(;r.length>this.config.maxParticles;)r.splice(Math.floor(Math.random()*r.length),1);if(this.particles.length<r.length){const t=r.length-this.particles.length;for(let s=0;t>s;s++)this.particles.push(this.makeParticle())}else this.particles.length>r.length&&(this.particles.length=r.length);for(let t=0;t<this.particles.length;t++){const s=this.particles[t],i=r[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=null){this.t(t)}i(t=null){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.h(t)}o(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)}}export{s as MasonEffect,s as default};
package/dist/index.js CHANGED
@@ -7,6 +7,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
7
7
  * ๋ฐ”๋‹๋ผ JS ์ฝ”์–ด ํด๋ž˜์Šค
8
8
  */
9
9
 
10
+ // ๋””๋ฐ”์šด์Šค ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
11
+ function debounce(func, wait) {
12
+ let timeout;
13
+ return function executedFunction(...args) {
14
+ const later = () => {
15
+ clearTimeout(timeout);
16
+ func.apply(this, args);
17
+ };
18
+ clearTimeout(timeout);
19
+ timeout = setTimeout(later, wait);
20
+ };
21
+ }
22
+
10
23
  class MasonEffect {
11
24
  constructor(container, options = {}) {
12
25
  // ์ปจํ…Œ์ด๋„ˆ ์š”์†Œ
@@ -55,14 +68,24 @@ class MasonEffect {
55
68
  this.mouse = { x: 0, y: 0, down: false };
56
69
  this.animationId = null;
57
70
  this.isRunning = false;
71
+ this.isVisible = false;
72
+ this.intersectionObserver = null;
58
73
 
59
- // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ
60
- this.handleResize = this.handleResize.bind(this);
74
+ // ๋””๋ฐ”์šด์Šค ์„ค์ • (ms)
75
+ this.debounceDelay = options.debounceDelay ?? 150; // ๊ธฐ๋ณธ 150ms
76
+
77
+ // ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ๋ฐ”์ธ๋”ฉ (๋””๋ฐ”์šด์Šค ์ ์šฉ ์ „์— ๋ฐ”์ธ๋”ฉ)
78
+ const boundHandleResize = this.handleResize.bind(this);
79
+ this.handleResize = debounce(boundHandleResize, this.debounceDelay);
61
80
  this.handleMouseMove = this.handleMouseMove.bind(this);
62
81
  this.handleMouseLeave = this.handleMouseLeave.bind(this);
63
82
  this.handleMouseDown = this.handleMouseDown.bind(this);
64
83
  this.handleMouseUp = this.handleMouseUp.bind(this);
65
84
 
85
+ // morph์™€ updateConfig๋ฅผ ์œ„ํ•œ ๋””๋ฐ”์šด์Šค๋œ ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ
86
+ this._debouncedMorph = debounce(this._morphInternal.bind(this), this.debounceDelay);
87
+ this._debouncedUpdateConfig = debounce(this._updateConfigInternal.bind(this), this.debounceDelay);
88
+
66
89
  // ์ดˆ๊ธฐํ™”
67
90
  this.init();
68
91
  }
@@ -70,13 +93,48 @@ class MasonEffect {
70
93
  init() {
71
94
  this.resize();
72
95
  this.setupEventListeners();
73
- this.start();
74
-
96
+ this.setupIntersectionObserver();
97
+
75
98
  if (this.config.onReady) {
76
99
  this.config.onReady(this);
77
100
  }
78
101
  }
79
102
 
103
+ setupIntersectionObserver() {
104
+ // IntersectionObserver๊ฐ€ ์ง€์›๋˜์ง€ ์•Š๋Š” ํ™˜๊ฒฝ์—์„œ๋Š” ํ•ญ์ƒ ์žฌ์ƒ
105
+ if (typeof window === 'undefined' || typeof window.IntersectionObserver === 'undefined') {
106
+ this.isVisible = true;
107
+ this.start();
108
+ return;
109
+ }
110
+
111
+ // ์ด๋ฏธ ์„ค์ •๋˜์–ด ์žˆ๋‹ค๋ฉด ๋‹ค์‹œ ๋งŒ๋“ค์ง€ ์•Š์Œ
112
+ if (this.intersectionObserver) {
113
+ return;
114
+ }
115
+
116
+ this.intersectionObserver = new IntersectionObserver(
117
+ (entries) => {
118
+ for (const entry of entries) {
119
+ if (entry.target !== this.container) continue;
120
+
121
+ if (entry.isIntersecting) {
122
+ this.isVisible = true;
123
+ this.start();
124
+ } else {
125
+ this.isVisible = false;
126
+ this.stop();
127
+ }
128
+ }
129
+ },
130
+ {
131
+ threshold: 0.1, // 10% ์ด์ƒ ๋ณด์ผ ๋•Œ ๋™์ž‘
132
+ }
133
+ );
134
+
135
+ this.intersectionObserver.observe(this.container);
136
+ }
137
+
80
138
  resize() {
81
139
  const width = this.config.width || this.container.clientWidth || window.innerWidth;
82
140
  const height = this.config.height || this.container.clientHeight || window.innerHeight * 0.7;
@@ -206,6 +264,12 @@ class MasonEffect {
206
264
  }
207
265
 
208
266
  morph(textOrOptions = null) {
267
+ // ์ฆ‰์‹œ ์‹คํ–‰์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ (์˜ˆ: ์ดˆ๊ธฐํ™” ์‹œ)๋ฅผ ์œ„ํ•ด ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ ์ง์ ‘ ํ˜ธ์ถœ
268
+ // ์ผ๋ฐ˜์ ์ธ ๊ฒฝ์šฐ์—๋Š” ๋””๋ฐ”์šด์Šค ์ ์šฉ
269
+ this._debouncedMorph(textOrOptions);
270
+ }
271
+
272
+ _morphInternal(textOrOptions = null) {
209
273
  // W์™€ H๊ฐ€ 0์ด๋ฉด resize ๋จผ์ € ์‹คํ–‰
210
274
  if (this.W === 0 || this.H === 0) {
211
275
  this.resize();
@@ -336,6 +400,11 @@ class MasonEffect {
336
400
 
337
401
  // ์„ค์ • ์—…๋ฐ์ดํŠธ
338
402
  updateConfig(newConfig) {
403
+ // ๋””๋ฐ”์šด์Šค ์ ์šฉ
404
+ this._debouncedUpdateConfig(newConfig);
405
+ }
406
+
407
+ _updateConfigInternal(newConfig) {
339
408
  this.config = { ...this.config, ...newConfig };
340
409
  if (newConfig.text) {
341
410
  this.buildTargets();
@@ -346,12 +415,20 @@ class MasonEffect {
346
415
  destroy() {
347
416
  this.stop();
348
417
  this.removeEventListeners();
418
+ if (this.intersectionObserver) {
419
+ this.intersectionObserver.disconnect();
420
+ this.intersectionObserver = null;
421
+ }
349
422
  if (this.canvas && this.canvas.parentNode) {
350
423
  this.canvas.parentNode.removeChild(this.canvas);
351
424
  }
352
425
  }
353
426
  }
354
427
 
428
+ /**
429
+ * MasonEffect - ๋ฉ”์ธ ์—”ํŠธ๋ฆฌ ํฌ์ธํŠธ
430
+ */
431
+
355
432
  exports.MasonEffect = MasonEffect;
356
433
  exports.default = MasonEffect;
357
434
  //# sourceMappingURL=index.js.map