masoneffect 1.0.30 → 2.0.2

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.
Files changed (196) hide show
  1. package/README.md +333 -231
  2. package/dist/core/count/index.d.ts +52 -0
  3. package/dist/core/count/index.d.ts.map +1 -0
  4. package/dist/core/index.d.ts +15 -97
  5. package/dist/core/index.d.ts.map +1 -1
  6. package/dist/core/textToParticle/index.d.ts +103 -0
  7. package/dist/core/textToParticle/index.d.ts.map +1 -0
  8. package/dist/count/core/count/index.d.ts +52 -0
  9. package/dist/count/core/count/index.d.ts.map +1 -0
  10. package/dist/count/core/index.d.ts +18 -0
  11. package/dist/count/core/index.d.ts.map +1 -0
  12. package/dist/count/core/textToParticle/index.d.ts +103 -0
  13. package/dist/count/core/textToParticle/index.d.ts.map +1 -0
  14. package/dist/count/index.cjs +1 -0
  15. package/dist/count/index.d.ts +16 -0
  16. package/dist/count/index.d.ts.map +1 -0
  17. package/dist/count/index.mjs +1 -0
  18. package/dist/count/index.umd.d.ts +7 -0
  19. package/dist/count/index.umd.d.ts.map +1 -0
  20. package/dist/count/react/MasonEffect.d.ts +32 -0
  21. package/dist/count/react/MasonEffect.d.ts.map +1 -0
  22. package/dist/count/react/count/Count.d.ts +19 -0
  23. package/dist/count/react/count/Count.d.ts.map +1 -0
  24. package/dist/count/react/count/index.d.ts +5 -0
  25. package/dist/count/react/count/index.d.ts.map +1 -0
  26. package/dist/count/react/index.d.ts +12 -0
  27. package/dist/count/react/index.d.ts.map +1 -0
  28. package/dist/count/react/textToParticle/TextToParticle.d.ts +15 -0
  29. package/dist/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
  30. package/dist/count/react/textToParticle/index.d.ts +4 -0
  31. package/dist/count/react/textToParticle/index.d.ts.map +1 -0
  32. package/dist/count/svelte/count/index.d.ts +2 -0
  33. package/dist/count/svelte/count/index.d.ts.map +1 -0
  34. package/dist/count/svelte/index.d.ts +8 -0
  35. package/dist/count/svelte/index.d.ts.map +1 -0
  36. package/dist/count/svelte/textToParticle/index.d.ts +2 -0
  37. package/dist/count/svelte/textToParticle/index.d.ts.map +1 -0
  38. package/dist/count/vue/count/index.d.ts +2 -0
  39. package/dist/count/vue/count/index.d.ts.map +1 -0
  40. package/dist/count/vue/index.d.ts +8 -0
  41. package/dist/count/vue/index.d.ts.map +1 -0
  42. package/dist/count/vue/textToParticle/index.d.ts +2 -0
  43. package/dist/count/vue/textToParticle/index.d.ts.map +1 -0
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.d.ts +12 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.mjs +1 -1
  48. package/dist/index.umd.min.js +1 -1
  49. package/dist/react/core/count/index.d.ts +51 -0
  50. package/dist/react/core/index.d.ts +15 -97
  51. package/dist/react/core/textToParticle/index.d.ts +102 -0
  52. package/dist/react/count/Count.d.ts +19 -0
  53. package/dist/react/count/Count.d.ts.map +1 -0
  54. package/dist/react/count/core/count/index.d.ts +52 -0
  55. package/dist/react/count/core/count/index.d.ts.map +1 -0
  56. package/dist/react/count/core/index.d.ts +18 -0
  57. package/dist/react/count/core/index.d.ts.map +1 -0
  58. package/dist/react/count/core/textToParticle/index.d.ts +103 -0
  59. package/dist/react/count/core/textToParticle/index.d.ts.map +1 -0
  60. package/dist/react/count/index.cjs +1 -0
  61. package/dist/react/count/index.d.ts +16 -0
  62. package/dist/react/count/index.d.ts.map +1 -0
  63. package/dist/react/count/index.mjs +1 -0
  64. package/dist/react/count/index.umd.d.ts +7 -0
  65. package/dist/react/count/index.umd.d.ts.map +1 -0
  66. package/dist/react/count/react/MasonEffect.d.ts +32 -0
  67. package/dist/react/count/react/MasonEffect.d.ts.map +1 -0
  68. package/dist/react/count/react/count/Count.d.ts +19 -0
  69. package/dist/react/count/react/count/Count.d.ts.map +1 -0
  70. package/dist/react/count/react/count/index.d.ts +5 -0
  71. package/dist/react/count/react/count/index.d.ts.map +1 -0
  72. package/dist/react/count/react/index.d.ts +12 -0
  73. package/dist/react/count/react/index.d.ts.map +1 -0
  74. package/dist/react/count/react/textToParticle/TextToParticle.d.ts +15 -0
  75. package/dist/react/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
  76. package/dist/react/count/react/textToParticle/index.d.ts +4 -0
  77. package/dist/react/count/react/textToParticle/index.d.ts.map +1 -0
  78. package/dist/react/count/svelte/count/index.d.ts +2 -0
  79. package/dist/react/count/svelte/count/index.d.ts.map +1 -0
  80. package/dist/react/count/svelte/index.d.ts +8 -0
  81. package/dist/react/count/svelte/index.d.ts.map +1 -0
  82. package/dist/react/count/svelte/textToParticle/index.d.ts +2 -0
  83. package/dist/react/count/svelte/textToParticle/index.d.ts.map +1 -0
  84. package/dist/react/count/vue/count/index.d.ts +2 -0
  85. package/dist/react/count/vue/count/index.d.ts.map +1 -0
  86. package/dist/react/count/vue/index.d.ts +8 -0
  87. package/dist/react/count/vue/index.d.ts.map +1 -0
  88. package/dist/react/count/vue/textToParticle/index.d.ts +2 -0
  89. package/dist/react/count/vue/textToParticle/index.d.ts.map +1 -0
  90. package/dist/react/index.cjs +12 -2
  91. package/dist/react/index.d.ts.map +1 -1
  92. package/dist/react/index.mjs +2 -1
  93. package/dist/react/react/count/Count.d.ts +18 -0
  94. package/dist/react/react/count/index.d.ts +4 -0
  95. package/dist/react/react/index.d.ts +11 -2
  96. package/dist/react/react/textToParticle/TextToParticle.d.ts +14 -0
  97. package/dist/react/react/textToParticle/index.d.ts +3 -0
  98. package/dist/react/svelte/count/index.d.ts +1 -0
  99. package/dist/react/svelte/index.d.ts +5 -3
  100. package/dist/react/svelte/textToParticle/index.d.ts +1 -0
  101. package/dist/react/textToParticle/TextToParticle.d.ts +15 -0
  102. package/dist/react/textToParticle/TextToParticle.d.ts.map +1 -0
  103. package/dist/react/textToParticle/core/count/index.d.ts +52 -0
  104. package/dist/react/textToParticle/core/count/index.d.ts.map +1 -0
  105. package/dist/react/textToParticle/core/index.d.ts +18 -0
  106. package/dist/react/textToParticle/core/index.d.ts.map +1 -0
  107. package/dist/react/textToParticle/core/textToParticle/index.d.ts +103 -0
  108. package/dist/react/textToParticle/core/textToParticle/index.d.ts.map +1 -0
  109. package/dist/react/textToParticle/index.cjs +1 -0
  110. package/dist/react/textToParticle/index.d.ts +16 -0
  111. package/dist/react/textToParticle/index.d.ts.map +1 -0
  112. package/dist/react/textToParticle/index.mjs +1 -0
  113. package/dist/react/textToParticle/index.umd.d.ts +7 -0
  114. package/dist/react/textToParticle/index.umd.d.ts.map +1 -0
  115. package/dist/react/textToParticle/react/MasonEffect.d.ts +32 -0
  116. package/dist/react/textToParticle/react/MasonEffect.d.ts.map +1 -0
  117. package/dist/react/textToParticle/react/count/Count.d.ts +19 -0
  118. package/dist/react/textToParticle/react/count/Count.d.ts.map +1 -0
  119. package/dist/react/textToParticle/react/count/index.d.ts +5 -0
  120. package/dist/react/textToParticle/react/count/index.d.ts.map +1 -0
  121. package/dist/react/textToParticle/react/index.d.ts +12 -0
  122. package/dist/react/textToParticle/react/index.d.ts.map +1 -0
  123. package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
  124. package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
  125. package/dist/react/textToParticle/react/textToParticle/index.d.ts +4 -0
  126. package/dist/react/textToParticle/react/textToParticle/index.d.ts.map +1 -0
  127. package/dist/react/textToParticle/svelte/count/index.d.ts +2 -0
  128. package/dist/react/textToParticle/svelte/count/index.d.ts.map +1 -0
  129. package/dist/react/textToParticle/svelte/index.d.ts +8 -0
  130. package/dist/react/textToParticle/svelte/index.d.ts.map +1 -0
  131. package/dist/react/textToParticle/svelte/textToParticle/index.d.ts +2 -0
  132. package/dist/react/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
  133. package/dist/react/textToParticle/vue/count/index.d.ts +2 -0
  134. package/dist/react/textToParticle/vue/count/index.d.ts.map +1 -0
  135. package/dist/react/textToParticle/vue/index.d.ts +8 -0
  136. package/dist/react/textToParticle/vue/index.d.ts.map +1 -0
  137. package/dist/react/textToParticle/vue/textToParticle/index.d.ts +2 -0
  138. package/dist/react/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
  139. package/dist/react/vue/count/index.d.ts +1 -0
  140. package/dist/react/vue/index.d.ts +5 -3
  141. package/dist/react/vue/textToParticle/index.d.ts +1 -0
  142. package/dist/svelte/count/index.cjs +1 -0
  143. package/dist/svelte/count/index.d.ts +163 -0
  144. package/dist/svelte/count/index.mjs +659 -0
  145. package/dist/svelte/index.cjs +1 -1
  146. package/dist/svelte/index.d.ts +88 -29
  147. package/dist/svelte/index.mjs +402 -8
  148. package/dist/svelte/textToParticle/index.cjs +1 -0
  149. package/dist/svelte/textToParticle/index.d.ts +163 -0
  150. package/dist/svelte/textToParticle/index.mjs +924 -0
  151. package/dist/textToParticle/core/count/index.d.ts +52 -0
  152. package/dist/textToParticle/core/count/index.d.ts.map +1 -0
  153. package/dist/textToParticle/core/index.d.ts +18 -0
  154. package/dist/textToParticle/core/index.d.ts.map +1 -0
  155. package/dist/textToParticle/core/textToParticle/index.d.ts +103 -0
  156. package/dist/textToParticle/core/textToParticle/index.d.ts.map +1 -0
  157. package/dist/textToParticle/index.cjs +1 -0
  158. package/dist/textToParticle/index.d.ts +16 -0
  159. package/dist/textToParticle/index.d.ts.map +1 -0
  160. package/dist/textToParticle/index.mjs +1 -0
  161. package/dist/textToParticle/index.umd.d.ts +7 -0
  162. package/dist/textToParticle/index.umd.d.ts.map +1 -0
  163. package/dist/textToParticle/react/MasonEffect.d.ts +32 -0
  164. package/dist/textToParticle/react/MasonEffect.d.ts.map +1 -0
  165. package/dist/textToParticle/react/count/Count.d.ts +19 -0
  166. package/dist/textToParticle/react/count/Count.d.ts.map +1 -0
  167. package/dist/textToParticle/react/count/index.d.ts +5 -0
  168. package/dist/textToParticle/react/count/index.d.ts.map +1 -0
  169. package/dist/textToParticle/react/index.d.ts +12 -0
  170. package/dist/textToParticle/react/index.d.ts.map +1 -0
  171. package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
  172. package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
  173. package/dist/textToParticle/react/textToParticle/index.d.ts +4 -0
  174. package/dist/textToParticle/react/textToParticle/index.d.ts.map +1 -0
  175. package/dist/textToParticle/svelte/count/index.d.ts +2 -0
  176. package/dist/textToParticle/svelte/count/index.d.ts.map +1 -0
  177. package/dist/textToParticle/svelte/index.d.ts +8 -0
  178. package/dist/textToParticle/svelte/index.d.ts.map +1 -0
  179. package/dist/textToParticle/svelte/textToParticle/index.d.ts +2 -0
  180. package/dist/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
  181. package/dist/textToParticle/vue/count/index.d.ts +2 -0
  182. package/dist/textToParticle/vue/count/index.d.ts.map +1 -0
  183. package/dist/textToParticle/vue/index.d.ts +8 -0
  184. package/dist/textToParticle/vue/index.d.ts.map +1 -0
  185. package/dist/textToParticle/vue/textToParticle/index.d.ts +2 -0
  186. package/dist/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
  187. package/dist/vue/count/index.cjs +1 -0
  188. package/dist/vue/count/index.d.ts +163 -0
  189. package/dist/vue/count/index.mjs +286 -0
  190. package/dist/vue/index.cjs +1 -1
  191. package/dist/vue/index.d.ts +88 -29
  192. package/dist/vue/index.mjs +291 -6
  193. package/dist/vue/textToParticle/index.cjs +1 -0
  194. package/dist/vue/textToParticle/index.d.ts +163 -0
  195. package/dist/vue/textToParticle/index.mjs +554 -0
  196. package/package.json +55 -5
package/README.md CHANGED
@@ -1,26 +1,78 @@
1
1
  # MasonEffect ![npm](https://img.shields.io/npm/dy/masoneffect)
2
2
 
3
- **Release version 1.0.30**
3
+ **Release version 2.0.1**
4
4
 
5
- A library that provides particle morphing effects. It can be used with React, Vue, Svelte, and vanilla JavaScript.
5
+ A collection of animation effects library. Supports React, Vue, Svelte, and vanilla JavaScript with **Tree-shaking** support.
6
6
 
7
- ## Installation
7
+ > 🤖 **For AI Agents**: If you are an AI agent (Cursor, GitHub Copilot, ChatGPT, etc.) setting up this package, please read **[AI_SETUP_GUIDE.md](./AI_SETUP_GUIDE.md)** first for automatic environment detection and configuration.
8
+
9
+ ## ✨ Features
10
+
11
+ - 🎯 **Tree-shaking Support**: Import only the effects you need
12
+ - 🎨 **Multiple Effects**: Various animation effects in one package
13
+ - 🔧 **Framework Agnostic**: Works with React, Vue, Svelte, and vanilla JS
14
+ - 📦 **TypeScript**: Full TypeScript support
15
+ - ⚡ **Optimized**: Automatic code splitting and optimization
16
+
17
+ ## 📦 Installation
8
18
 
9
19
  ```bash
10
20
  npm install masoneffect
11
21
  ```
12
22
 
13
- ## Usage
23
+ ### 🤖 AI Agent Guide
24
+
25
+ **⚠️ IMPORTANT FOR AI AGENTS**: Before using this package, read **[AI_SETUP_GUIDE.md](./AI_SETUP_GUIDE.md)** for:
26
+ - Automatic environment detection (framework, TypeScript, build tool)
27
+ - Framework-specific setup guides
28
+ - Effect recommendation logic based on user requests
29
+ - Complete code templates for all frameworks
30
+ - Tree-shaking optimization rules
31
+
32
+ This guide is optimized for AI agents to automatically configure MasonEffect correctly in any project.
33
+
34
+ ## 🎯 Available Effects
35
+
36
+ ### 1. TextToParticle
37
+ Converts text into animated particles with morphing effects.
38
+
39
+ ### 2. Count
40
+ Animated number counting with intersection observer support.
41
+
42
+ ---
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ### Tree-shaking (Recommended)
47
+
48
+ Import only the effects you need:
49
+
50
+ ```typescript
51
+ // ✅ Recommended: Import only what you need
52
+ import { TextToParticle } from 'masoneffect/textToParticle';
53
+ import { Count } from 'masoneffect/count';
54
+ ```
55
+
56
+ ### Legacy Import (Backward Compatible)
57
+
58
+ ```typescript
59
+ // ⚠️ Not recommended: Imports all effects
60
+ import { TextToParticle, Count } from 'masoneffect';
61
+ ```
62
+
63
+ ---
14
64
 
15
- ### Vanilla JavaScript
65
+ ## 📖 Usage
16
66
 
17
- #### Using npm (ES modules)
67
+ ### TextToParticle Effect
68
+
69
+ #### Vanilla JavaScript
18
70
 
19
71
  ```javascript
20
- import { MasonEffect } from 'masoneffect';
72
+ import { TextToParticle } from 'masoneffect/textToParticle';
21
73
 
22
74
  const container = document.getElementById('my-container');
23
- const effect = new MasonEffect(container, {
75
+ const effect = new TextToParticle(container, {
24
76
  text: 'Hello World',
25
77
  particleColor: '#00ff88',
26
78
  maxParticles: 2000,
@@ -29,230 +81,194 @@ const effect = new MasonEffect(container, {
29
81
  // Change text
30
82
  effect.morph({ text: 'New Text' });
31
83
 
32
- // Multi-line text support (use \n for line breaks)
84
+ // Multi-line text support
33
85
  effect.morph({ text: 'Line 1\nLine 2\nLine 3' });
34
86
 
35
- // Change text along with other properties
36
- effect.morph({
37
- text: 'New Text',
38
- particleColor: '#ff00ff',
39
- maxParticles: 3000,
40
- pointSize: 1.0,
41
- });
42
-
43
87
  // Return particles to initial position
44
88
  effect.scatter();
45
89
  ```
46
90
 
47
- #### Using CDN (UMD)
48
-
49
- ```html
50
- <script src="https://cdn.jsdelivr.net/npm/masoneffect@1.0.30/dist/index.umd.min.js"></script>
51
- <script>
52
- const container = document.getElementById('my-container');
53
- const effect = new MasonEffect(container, {
54
- text: 'Hello World',
55
- particleColor: '#00ff88',
56
- maxParticles: 2000,
57
- onReady: (instance) => {
58
- console.log('MasonEffect ready!', instance);
59
- }
60
- });
61
-
62
- // Change text
63
- effect.morph({ text: 'Morphed!' });
64
-
65
- // Multi-line text support
66
- effect.morph({ text: 'Line 1\nLine 2\nLine 3' });
67
-
68
- // Return particles to initial position
69
- effect.scatter();
70
-
71
- // Change text with random selection
72
- const texts = ['Hello', 'World', 'Mason', 'Effect', 'Particles'];
73
- const randomText = texts[Math.floor(Math.random() * texts.length)];
74
- effect.morph({ text: randomText });
75
- </script>
76
- ```
77
-
78
- ### React
91
+ #### React
79
92
 
80
93
  ```tsx
81
94
  import React, { useRef } from 'react';
82
- import MasonEffect from 'masoneffect/react';
83
- import type { MasonEffectRef } from 'masoneffect/react';
95
+ import TextToParticle from 'masoneffect/react/textToParticle';
96
+ import type { TextToParticleRef } from 'masoneffect/react/textToParticle';
84
97
 
85
98
  function App() {
86
- const effectRef = useRef<MasonEffectRef>(null);
87
-
88
- const handleMorph = () => {
89
- // Change text
90
- effectRef.current?.morph({ text: 'Morphed!' });
91
- };
92
-
93
- const handleScatter = () => {
94
- // Return particles to initial position
95
- effectRef.current?.scatter();
96
- };
97
-
98
- const handleChangeText = () => {
99
- const texts = ['Hello', 'World', 'Mason', 'Effect', 'Particles', 'Line 1\nLine 2'];
100
- const randomText = texts[Math.floor(Math.random() * texts.length)];
101
- effectRef.current?.morph({ text: randomText });
102
- };
103
-
104
- const handleChangeWithOptions = () => {
105
- // Change text along with other properties
106
- effectRef.current?.morph({
107
- text: 'New Text',
108
- particleColor: '#ff00ff',
109
- maxParticles: 3000,
110
- pointSize: 1.0,
111
- });
112
- };
99
+ const effectRef = useRef<TextToParticleRef>(null);
113
100
 
114
101
  return (
115
- <div style={{ width: '100%', height: '70vh', background: '#000', display: 'flex', flexDirection: 'column' }}>
116
- <div style={{ flex: 1, position: 'relative', minHeight: 400 }}>
117
- <MasonEffect
118
- ref={effectRef}
119
- text="Hello React"
120
- particleColor="#00ff88"
121
- maxParticles={2000}
122
- onReady={(instance) => {
123
- console.log('Ready!', instance);
124
- }}
125
- />
126
- {/* Multi-line text example */}
127
- {/* <MasonEffect text="Line 1\nLine 2\nLine 3" /> */}
128
- </div>
129
- <div style={{ padding: '20px', display: 'flex', gap: '10px' }}>
130
- <button onClick={handleMorph}>Morph</button>
131
- <button onClick={handleScatter}>Scatter</button>
132
- <button onClick={handleChangeText}>Change Text</button>
133
- <button onClick={handleChangeWithOptions}>Change with Options</button>
134
- </div>
102
+ <div style={{ width: '100%', height: '70vh', background: '#000' }}>
103
+ <TextToParticle
104
+ ref={effectRef}
105
+ text="Hello React"
106
+ particleColor="#00ff88"
107
+ maxParticles={2000}
108
+ onReady={(instance) => {
109
+ console.log('Ready!', instance);
110
+ }}
111
+ />
112
+ <button onClick={() => effectRef.current?.morph({ text: 'Morphed!' })}>
113
+ Morph
114
+ </button>
135
115
  </div>
136
116
  );
137
117
  }
138
-
139
- export default App;
140
118
  ```
141
119
 
142
- **⚠️ Note**: When using the React component, you must specify an explicit size for the container. For more details, see the [React Troubleshooting Guide](./REACT_TROUBLESHOOTING.md).
143
-
144
- ### Vue 3
120
+ #### Vue 3
145
121
 
146
122
  ```vue
147
123
  <script setup>
148
- import { ref } from 'vue';
149
- import MasonEffect from 'masoneffect/vue';
124
+ import TextToParticle from 'masoneffect/vue/textToParticle';
150
125
 
151
126
  const effectRef = ref(null);
152
-
153
- const handleMorph = () => {
154
- effectRef.value?.morph();
155
- };
156
-
157
- const handleScatter = () => {
158
- effectRef.value?.scatter();
159
- };
160
-
161
- const handleChangeText = () => {
162
- const texts = ['Hello', 'World', 'Mason', 'Effect', 'Line 1\nLine 2'];
163
- const randomText = texts[Math.floor(Math.random() * texts.length)];
164
- effectRef.value?.morph({ text: randomText });
165
- };
166
-
167
- const onReady = (instance) => {
168
- console.log('Ready!', instance);
169
- };
170
127
  </script>
171
128
 
172
129
  <template>
173
130
  <div style="width: 100%; height: 70vh; background: #000">
174
- <MasonEffect
131
+ <TextToParticle
175
132
  ref="effectRef"
176
133
  text="Hello Vue"
177
- :particle-color="'#00ff88'"
134
+ particle-color="#00ff88"
178
135
  :max-particles="2000"
179
- @ready="onReady"
180
136
  />
181
- <!-- Multi-line text example -->
182
- <!-- <MasonEffect text="Line 1\nLine 2\nLine 3" /> -->
183
- <div style="padding: 20px; display: flex; gap: 10px">
184
- <button @click="handleMorph">Morph</button>
185
- <button @click="handleScatter">Scatter</button>
186
- <button @click="handleChangeText">Change Text</button>
187
- </div>
137
+ <button @click="effectRef?.morph({ text: 'Morphed!' })">Morph</button>
188
138
  </div>
189
139
  </template>
190
140
  ```
191
141
 
192
- ### Svelte
142
+ #### Svelte
193
143
 
194
144
  ```svelte
195
145
  <script lang="ts">
196
- import MasonEffect from 'masoneffect/svelte';
197
- import type { MasonEffect as MasonEffectType } from 'masoneffect';
198
-
199
- let effectRef: MasonEffect | null = null;
200
-
201
- const handleMorph = () => {
202
- // Change text
203
- effectRef?.morph({ text: 'Morphed!' });
204
- };
205
-
206
- const handleScatter = () => {
207
- // Return particles to initial position
208
- effectRef?.scatter();
209
- };
210
-
211
- const handleChangeText = () => {
212
- const texts = ['Hello', 'World', 'Mason', 'Effect', 'Line 1\nLine 2'];
213
- const randomText = texts[Math.floor(Math.random() * texts.length)];
214
- effectRef?.morph({ text: randomText });
215
- };
216
-
217
- const handleChangeWithOptions = () => {
218
- // Change text along with other properties
219
- effectRef?.morph({
220
- text: 'New Text',
221
- particleColor: '#ff00ff',
222
- maxParticles: 3000,
223
- pointSize: 1.0,
224
- });
225
- };
226
-
227
- const onReady = (instance: MasonEffectType) => {
228
- console.log('Ready!', instance);
229
- };
146
+ import TextToParticle from 'masoneffect/svelte/textToParticle';
147
+
148
+ let effectRef: TextToParticle | null = null;
230
149
  </script>
231
150
 
232
- <div style="width: 100%; height: 70vh; background: #000; display: flex; flex-direction: column">
233
- <div style="flex: 1; position: relative; min-height: 400px">
234
- <MasonEffect
235
- bind:this={effectRef}
236
- text="Hello Svelte"
237
- particleColor="#00ff88"
238
- maxParticles={2000}
239
- on:ready={onReady}
151
+ <div style="width: 100%; height: 70vh; background: #000">
152
+ <TextToParticle
153
+ bind:this={effectRef}
154
+ text="Hello Svelte"
155
+ particleColor="#00ff88"
156
+ maxParticles={2000}
157
+ />
158
+ <button on:click={() => effectRef?.morph({ text: 'Morphed!' })}>
159
+ Morph
160
+ </button>
161
+ </div>
162
+ ```
163
+
164
+ ---
165
+
166
+ ### Count Effect
167
+
168
+ #### Vanilla JavaScript
169
+
170
+ ```javascript
171
+ import { Count, easingFunctions } from 'masoneffect/count';
172
+
173
+ const container = document.getElementById('count-container');
174
+ const count = new Count(container, {
175
+ targetValue: 1000,
176
+ duration: 2000,
177
+ startValue: 0,
178
+ easing: easingFunctions.easeOutCubic,
179
+ onUpdate: (value) => {
180
+ console.log(value);
181
+ },
182
+ onComplete: () => {
183
+ console.log('Complete!');
184
+ }
185
+ });
186
+
187
+ // Start animation
188
+ count.start();
189
+
190
+ // Reset
191
+ count.reset();
192
+ ```
193
+
194
+ #### React
195
+
196
+ ```tsx
197
+ import React, { useRef } from 'react';
198
+ import Count from 'masoneffect/react/count';
199
+ import { easingFunctions } from 'masoneffect/react/count';
200
+ import type { CountRef } from 'masoneffect/react/count';
201
+
202
+ function App() {
203
+ const countRef = useRef<CountRef>(null);
204
+
205
+ return (
206
+ <div>
207
+ <Count
208
+ ref={countRef}
209
+ targetValue={1000}
210
+ duration={2000}
211
+ easing={easingFunctions.easeOutCubic}
212
+ onUpdate={(value) => console.log(value)}
213
+ onComplete={() => console.log('Complete!')}
214
+ style={{ fontSize: '3rem', fontWeight: 'bold' }}
215
+ />
216
+ <button onClick={() => countRef.current?.reset()}>Reset</button>
217
+ <button onClick={() => countRef.current?.start()}>Start</button>
218
+ </div>
219
+ );
220
+ }
221
+ ```
222
+
223
+ #### Vue 3
224
+
225
+ ```vue
226
+ <script setup>
227
+ import Count from 'masoneffect/vue/count';
228
+ import { easingFunctions } from 'masoneffect/vue/count';
229
+ </script>
230
+
231
+ <template>
232
+ <div>
233
+ <Count
234
+ :target-value="1000"
235
+ :duration="2000"
236
+ :easing="easingFunctions.easeOutCubic"
237
+ @update="(value) => console.log(value)"
238
+ @complete="() => console.log('Complete!')"
239
+ style="font-size: 3rem; font-weight: bold"
240
240
  />
241
241
  </div>
242
- <div style="padding: 20px; display: flex; gap: 10px">
243
- <button on:click={handleMorph}>Morph</button>
244
- <button on:click={handleScatter}>Scatter</button>
245
- <button on:click={handleChangeText}>Change Text</button>
246
- <button on:click={handleChangeWithOptions}>Change with Options</button>
247
- </div>
242
+ </template>
243
+ ```
244
+
245
+ #### Svelte
246
+
247
+ ```svelte
248
+ <script lang="ts">
249
+ import Count from 'masoneffect/svelte/count';
250
+ import { easingFunctions } from 'masoneffect/svelte/count';
251
+ </script>
252
+
253
+ <div>
254
+ <Count
255
+ targetValue={1000}
256
+ duration={2000}
257
+ easing={easingFunctions.easeOutCubic}
258
+ on:update={(e) => console.log(e.detail)}
259
+ on:complete={() => console.log('Complete!')}
260
+ style="font-size: 3rem; font-weight: bold"
261
+ />
248
262
  </div>
249
263
  ```
250
264
 
251
- **Note**: In Svelte, you can access component methods using `bind:this`. The component exposes `morph()`, `scatter()`, `updateConfig()`, and `destroy()` methods. Make sure to specify an explicit size for the container.
265
+ ---
252
266
 
253
- ## API
267
+ ## 📚 API Reference
254
268
 
255
- ### Options
269
+ ### TextToParticle
270
+
271
+ #### Options
256
272
 
257
273
  | Option | Type | Default | Description |
258
274
  |--------|------|---------|-------------|
@@ -265,63 +281,133 @@ const onReady = (instance) => {
265
281
  | `repelStrength` | `number` | `1` | Mouse repel strength |
266
282
  | `particleColor` | `string` | `'#fff'` | Particle color |
267
283
  | `fontFamily` | `string` | `'Inter, system-ui, Arial'` | Font family |
268
- | `fontSize` | `number \| null` | `null` | Font size (auto-adjusts to fit container if null, responsive to screen size) |
284
+ | `fontSize` | `number \| null` | `null` | Font size (auto-adjusts if null) |
269
285
  | `width` | `number \| null` | `null` | Canvas width (container size if null) |
270
286
  | `height` | `number \| null` | `null` | Canvas height (container size if null) |
271
287
  | `devicePixelRatio` | `number \| null` | `null` | Device pixel ratio (auto if null) |
272
- | `debounceDelay` | `number` | `150` | Debounce delay in milliseconds for resize, morph, and updateConfig (set to 0 to disable) |
288
+ | `debounceDelay` | `number` | `150` | Debounce delay in milliseconds |
273
289
  | `onReady` | `function` | `null` | Initialization complete callback |
274
290
  | `onUpdate` | `function` | `null` | Update callback |
275
291
 
276
- ### Methods
292
+ #### Methods
277
293
 
278
- #### `morph(textOrOptions?: string | Partial<MasonEffectOptions>)`
279
- Morphs particles into text form. This method is debounced to prevent excessive calls (default: 150ms delay).
294
+ - `morph(textOrOptions?: string | Partial<TextToParticleOptions>)` - Morph particles into text
295
+ - `scatter()` - Return particles to initial position
296
+ - `updateConfig(config: Partial<TextToParticleOptions>)` - Update configuration
297
+ - `destroy()` - Destroy instance and cleanup
280
298
 
281
- **Using string (legacy support):**
282
- ```javascript
283
- effect.morph('New Text');
299
+ ---
300
+
301
+ ### Count
302
+
303
+ #### Options
304
+
305
+ | Option | Type | Default | Description |
306
+ |--------|------|---------|-------------|
307
+ | `targetValue` | `number` | **required** | Target number to count to |
308
+ | `duration` | `number` | `2000` | Animation duration in milliseconds |
309
+ | `startValue` | `number` | `0` | Starting number |
310
+ | `enabled` | `boolean` | `true` | Enable/disable animation |
311
+ | `easing` | `function` | `linear` | Easing function |
312
+ | `threshold` | `number` | `0.2` | IntersectionObserver threshold |
313
+ | `rootMargin` | `string` | `'0px 0px -100px 0px'` | IntersectionObserver rootMargin |
314
+ | `triggerOnce` | `boolean` | `false` | Trigger animation only once |
315
+ | `onUpdate` | `function` | `null` | Update callback (receives current value) |
316
+ | `onComplete` | `function` | `null` | Animation complete callback |
317
+
318
+ #### Methods
319
+
320
+ - `start()` - Start animation
321
+ - `stop()` - Stop animation
322
+ - `reset()` - Reset to start value
323
+ - `getValue()` - Get current value
324
+ - `updateConfig(config: Partial<CountOptions>)` - Update configuration
325
+ - `destroy()` - Destroy instance and cleanup
326
+
327
+ #### Easing Functions
328
+
329
+ ```typescript
330
+ import { easingFunctions } from 'masoneffect/count';
331
+
332
+ // Available easing functions:
333
+ easingFunctions.linear
334
+ easingFunctions.easeInQuad
335
+ easingFunctions.easeOutQuad
336
+ easingFunctions.easeInOutQuad
337
+ easingFunctions.easeOutCubic
284
338
  ```
285
339
 
286
- **Using object (recommended - change text along with other properties):**
287
- ```javascript
288
- effect.morph({
289
- text: 'New Text',
290
- particleColor: '#ff00ff',
291
- maxParticles: 3000,
292
- pointSize: 1.0,
293
- ease: 0.08,
294
- });
340
+ ---
341
+
342
+ ## 🌳 Tree-shaking
343
+
344
+ MasonEffect supports Tree-shaking, allowing you to import only the effects you need:
345
+
346
+ ```typescript
347
+ // ✅ Recommended: Only imports Count (smaller bundle)
348
+ import { Count } from 'masoneffect/count';
349
+
350
+ // ❌ Not recommended: Imports all effects (larger bundle)
351
+ import { Count } from 'masoneffect';
352
+ ```
353
+
354
+ ### Framework-specific imports
355
+
356
+ ```typescript
357
+ // React
358
+ import Count from 'masoneffect/react/count';
359
+ import TextToParticle from 'masoneffect/react/textToParticle';
360
+
361
+ // Vue
362
+ import Count from 'masoneffect/vue/count';
363
+ import TextToParticle from 'masoneffect/vue/textToParticle';
364
+
365
+ // Svelte
366
+ import Count from 'masoneffect/svelte/count';
367
+ import TextToParticle from 'masoneffect/svelte/textToParticle';
295
368
  ```
296
369
 
297
- **Note**: Multiple rapid calls will be debounced, and only the last call will be executed after the delay period.
370
+ ---
371
+
372
+ ## 🔄 Backward Compatibility
373
+
374
+ For backward compatibility, the old API still works:
375
+
376
+ ```typescript
377
+ // Old API (still works)
378
+ import { MasonEffect } from 'masoneffect';
379
+ import MasonEffect from 'masoneffect/react';
298
380
 
299
- #### `scatter()`
300
- Returns particles to their initial position. Each particle returns to the position where it was first created.
381
+ // MasonEffect is an alias for TextToParticle
382
+ const effect = new MasonEffect(container, { text: 'Hello' });
383
+ ```
301
384
 
302
- #### `updateConfig(config: Partial<MasonEffectOptions>)`
303
- Updates the configuration. This method is debounced to prevent excessive calls (default: 150ms delay).
385
+ However, we recommend using the new Tree-shaking-friendly imports for better performance.
304
386
 
305
- #### `destroy()`
306
- Destroys the instance and cleans up resources.
387
+ ---
307
388
 
308
- ## Features
389
+ ## 🎨 Features
309
390
 
391
+ ### TextToParticle
310
392
  - 🎨 Morphing effect that converts text into particles
311
393
  - 🖱️ Mouse interaction support (repel/attract)
312
394
  - 📱 Responsive design
313
395
  - ⚡ High-performance Canvas rendering
314
- - 🔧 Supports React, Vue, Svelte, and vanilla JS (including CDN)
315
- - 🎯 Includes TypeScript type definitions
316
- - 💾 Automatic obfuscation and optimization in production builds
317
- - 🔄 Scatter effect that returns to initial position
318
- - 👁️ **IntersectionObserver**: Automatically pauses animation when not visible (saves resources)
319
- - ⏱️ **Debouncing**: Prevents excessive calls on resize, morph, and updateConfig methods
320
- - 🎛️ **Configurable debounce delay**: Adjust or disable debouncing via `debounceDelay` option
321
- - 📝 **Multi-line text support**: Use `\n` to create line breaks in text
322
- - 🔤 **Auto font size adjustment**: Automatically adjusts font size to fit within the container (responsive to screen size)
323
-
324
- ## Development
396
+ - 👁️ IntersectionObserver: Automatically pauses when not visible
397
+ - ⏱️ Debouncing: Prevents excessive calls
398
+ - 📝 Multi-line text support
399
+ - 🔤 Auto font size adjustment
400
+
401
+ ### Count
402
+ - 🔢 Animated number counting
403
+ - 👁️ IntersectionObserver: Starts when element is visible
404
+ - 🎯 Multiple easing functions
405
+ - ⚡ Smooth animations with requestAnimationFrame
406
+ - 🔄 Reset and restart support
407
+
408
+ ---
409
+
410
+ ## 🛠️ Development
325
411
 
326
412
  ```bash
327
413
  # Install dependencies
@@ -330,25 +416,41 @@ npm install
330
416
  # Development mode (watch)
331
417
  npm run dev
332
418
 
333
- # Build (generate production min files)
419
+ # Build (generate production files)
334
420
  npm run build
335
421
 
336
422
  # Example test server
337
423
  npm run serve
338
424
  ```
339
425
 
340
- ## Build Output
426
+ ---
341
427
 
342
- Running the build will generate the following files:
428
+ ## 📦 CDN Usage (UMD)
343
429
 
344
- - **Core library**: `dist/index.mjs` (ESM), `dist/index.cjs` (CommonJS), `dist/index.d.ts` (TypeScript types)
345
- - **React component**: `dist/react/index.mjs`, `dist/react/index.cjs`, `dist/react/index.d.ts`
346
- - **Vue component**: `dist/vue/index.mjs`, `dist/vue/index.cjs`, `dist/vue/index.d.ts`
347
- - **Svelte component**: `dist/svelte/index.mjs`, `dist/svelte/index.cjs`, `dist/svelte/index.d.ts`
348
- - **UMD build**: `dist/index.umd.min.js` (for CDN usage)
430
+ ```html
431
+ <script src="https://cdn.jsdelivr.net/npm/masoneffect@2.0.1/dist/index.umd.min.js"></script>
432
+ <script>
433
+ // TextToParticle (MasonEffect alias for backward compatibility)
434
+ const container = document.getElementById('my-container');
435
+ const effect = new MasonEffect(container, {
436
+ text: 'Hello World',
437
+ particleColor: '#00ff88',
438
+ });
439
+ </script>
440
+ ```
441
+
442
+ **Note**: CDN version includes all effects. For Tree-shaking, use npm package.
349
443
 
350
- When installed via npm, the appropriate module format is automatically selected based on your bundler. The UMD files (`index.umd.min.js`) can be used directly in browsers via CDN or script tags.
444
+ ---
351
445
 
352
- ## License
446
+ ## 📄 License
353
447
 
354
448
  MIT
449
+
450
+ ---
451
+
452
+ ## 🔗 Links
453
+
454
+ - [GitHub Repository](https://github.com/fe-hyunsu/masoneffect)
455
+ - [Homepage](https://masoneffect.com)
456
+ - [Issues](https://github.com/fe-hyunsu/masoneffect/issues)