masoneffect 1.0.30 → 2.0.1

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