masoneffect 0.1.21 → 0.1.22

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 (2) hide show
  1. package/README.md +82 -50
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # MasonEffect ![npm](https://img.shields.io/npm/dw/masoneffect)
2
2
 
3
+ **Release version 1.0.22**
4
+
3
5
  A library that provides particle morphing effects. It can be used with React, Vue, and vanilla JavaScript.
4
6
 
5
7
  ## Installation
@@ -25,13 +27,14 @@ const effect = new MasonEffect(container, {
25
27
  });
26
28
 
27
29
  // Change text
28
- effect.morph('New Text');
30
+ effect.morph({ text: 'New Text' });
29
31
 
30
32
  // Change text along with other properties
31
33
  effect.morph({
32
34
  text: 'New Text',
33
35
  particleColor: '#ff00ff',
34
36
  maxParticles: 3000,
37
+ pointSize: 1.0,
35
38
  });
36
39
 
37
40
  // Return particles to initial position
@@ -41,35 +44,70 @@ effect.scatter();
41
44
  #### Using CDN (UMD)
42
45
 
43
46
  ```html
44
- <script src="https://cdn.jsdelivr.net/npm/masoneffect@0.1.18/dist/index.umd.min.js"></script>
47
+ <script src="https://cdn.jsdelivr.net/npm/masoneffect@1.0.22/dist/index.umd.min.js"></script>
45
48
  <script>
46
49
  const container = document.getElementById('my-container');
47
50
  const effect = new MasonEffect(container, {
48
51
  text: 'Hello World',
49
52
  particleColor: '#00ff88',
50
53
  maxParticles: 2000,
54
+ onReady: (instance) => {
55
+ console.log('MasonEffect ready!', instance);
56
+ }
51
57
  });
52
58
 
53
59
  // Change text
54
- effect.morph({ text: 'New Text' });
60
+ effect.morph({ text: 'Morphed!' });
55
61
 
56
62
  // Return particles to initial position
57
63
  effect.scatter();
64
+
65
+ // Change text with random selection
66
+ const texts = ['Hello', 'World', 'Mason', 'Effect', 'Particles'];
67
+ const randomText = texts[Math.floor(Math.random() * texts.length)];
68
+ effect.morph({ text: randomText });
58
69
  </script>
59
70
  ```
60
71
 
61
72
  ### React
62
73
 
63
- ```jsx
74
+ ```tsx
64
75
  import React, { useRef } from 'react';
65
76
  import MasonEffect from 'masoneffect/react';
77
+ import type { MasonEffectRef } from 'masoneffect/react';
66
78
 
67
79
  function App() {
68
- const effectRef = useRef(null);
80
+ const effectRef = useRef<MasonEffectRef>(null);
81
+
82
+ const handleMorph = () => {
83
+ // Change text
84
+ effectRef.current?.morph({ text: 'Morphed!' });
85
+ };
86
+
87
+ const handleScatter = () => {
88
+ // Return particles to initial position
89
+ effectRef.current?.scatter();
90
+ };
91
+
92
+ const handleChangeText = () => {
93
+ const texts = ['Hello', 'World', 'Mason', 'Effect', 'Particles'];
94
+ const randomText = texts[Math.floor(Math.random() * texts.length)];
95
+ effectRef.current?.morph({ text: randomText });
96
+ };
97
+
98
+ const handleChangeWithOptions = () => {
99
+ // Change text along with other properties
100
+ effectRef.current?.morph({
101
+ text: 'New Text',
102
+ particleColor: '#ff00ff',
103
+ maxParticles: 3000,
104
+ pointSize: 1.0,
105
+ });
106
+ };
69
107
 
70
108
  return (
71
- <div style={{ width: '100%', height: '70vh', display: 'flex', flexDirection: 'column' }}>
72
- <div style={{ flex: 1, position: 'relative' }}>
109
+ <div style={{ width: '100%', height: '70vh', background: '#000', display: 'flex', flexDirection: 'column' }}>
110
+ <div style={{ flex: 1, position: 'relative', minHeight: 400 }}>
73
111
  <MasonEffect
74
112
  ref={effectRef}
75
113
  text="Hello React"
@@ -81,23 +119,16 @@ function App() {
81
119
  />
82
120
  </div>
83
121
  <div style={{ padding: '20px', display: 'flex', gap: '10px' }}>
84
- <button onClick={() => effectRef.current?.morph('New Text')}>
85
- Morph
86
- </button>
87
- <button onClick={() => effectRef.current?.morph({
88
- text: 'Hello',
89
- particleColor: '#ff00ff',
90
- maxParticles: 3000
91
- })}>
92
- Morph with Options
93
- </button>
94
- <button onClick={() => effectRef.current?.scatter()}>
95
- Scatter
96
- </button>
122
+ <button onClick={handleMorph}>Morph</button>
123
+ <button onClick={handleScatter}>Scatter</button>
124
+ <button onClick={handleChangeText}>Change Text</button>
125
+ <button onClick={handleChangeWithOptions}>Change with Options</button>
97
126
  </div>
98
127
  </div>
99
128
  );
100
129
  }
130
+
131
+ export default App;
101
132
  ```
102
133
 
103
134
  **⚠️ 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).
@@ -105,21 +136,6 @@ function App() {
105
136
  ### Vue 3
106
137
 
107
138
  ```vue
108
- <template>
109
- <div style="width: 100%; height: 70vh">
110
- <MasonEffect
111
- ref="effectRef"
112
- text="Hello Vue"
113
- particle-color="#00ff88"
114
- :max-particles="2000"
115
- @ready="onReady"
116
- />
117
- <button @click="handleMorph">Morph</button>
118
- <button @click="handleMorphWithOptions">Morph with Options</button>
119
- <button @click="handleScatter">Scatter</button>
120
- </div>
121
- </template>
122
-
123
139
  <script setup>
124
140
  import { ref } from 'vue';
125
141
  import MasonEffect from 'masoneffect/vue';
@@ -127,25 +143,40 @@ import MasonEffect from 'masoneffect/vue';
127
143
  const effectRef = ref(null);
128
144
 
129
145
  const handleMorph = () => {
130
- effectRef.value?.morph('New Text');
131
- };
132
-
133
- const handleMorphWithOptions = () => {
134
- effectRef.value?.morph({
135
- text: 'Hello',
136
- particleColor: '#ff00ff',
137
- maxParticles: 3000,
138
- });
146
+ effectRef.value?.morph();
139
147
  };
140
148
 
141
149
  const handleScatter = () => {
142
150
  effectRef.value?.scatter();
143
151
  };
144
152
 
153
+ const handleChangeText = () => {
154
+ const texts = ['Hello', 'World', 'Mason', 'Effect'];
155
+ const randomText = texts[Math.floor(Math.random() * texts.length)];
156
+ effectRef.value?.morph(randomText);
157
+ };
158
+
145
159
  const onReady = (instance) => {
146
160
  console.log('Ready!', instance);
147
161
  };
148
162
  </script>
163
+
164
+ <template>
165
+ <div style="width: 100%; height: 70vh; background: #000">
166
+ <MasonEffect
167
+ ref="effectRef"
168
+ text="Hello Vue"
169
+ :particle-color="'#00ff88'"
170
+ :max-particles="2000"
171
+ @ready="onReady"
172
+ />
173
+ <div style="padding: 20px; display: flex; gap: 10px">
174
+ <button @click="handleMorph">Morph</button>
175
+ <button @click="handleScatter">Scatter</button>
176
+ <button @click="handleChangeText">Change Text</button>
177
+ </div>
178
+ </div>
179
+ </template>
149
180
  ```
150
181
 
151
182
  ## API
@@ -176,12 +207,12 @@ const onReady = (instance) => {
176
207
  #### `morph(textOrOptions?: string | Partial<MasonEffectOptions>)`
177
208
  Morphs particles into text form. This method is debounced to prevent excessive calls (default: 150ms delay).
178
209
 
179
- **Using string:**
210
+ **Using string (legacy support):**
180
211
  ```javascript
181
212
  effect.morph('New Text');
182
213
  ```
183
214
 
184
- **Using object (change text along with other properties):**
215
+ **Using object (recommended - change text along with other properties):**
185
216
  ```javascript
186
217
  effect.morph({
187
218
  text: 'New Text',
@@ -237,11 +268,12 @@ npm run serve
237
268
 
238
269
  Running the build will generate the following files:
239
270
 
240
- - **Development**: `dist/index.js`, `dist/index.esm.js`, `dist/index.umd.js` (with source maps)
241
- - **Production**: `dist/index.min.js`, `dist/index.esm.min.js`, `dist/index.umd.min.js` (obfuscated and optimized)
242
- - **React component**: `dist/react/MasonEffect.min.js` (obfuscated)
271
+ - **Core library**: `dist/index.mjs` (ESM), `dist/index.cjs` (CommonJS), `dist/index.d.ts` (TypeScript types)
272
+ - **React component**: `dist/react/index.mjs`, `dist/react/index.cjs`, `dist/react/index.d.ts`
273
+ - **Vue component**: `dist/vue/index.mjs`, `dist/vue/index.cjs`, `dist/vue/index.d.ts`
274
+ - **UMD build**: `dist/index.umd.min.js` (for CDN usage)
243
275
 
244
- 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).
276
+ 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.
245
277
 
246
278
  ## License
247
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "masoneffect",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "파티클 모핑 효과를 제공하는 라이브러리 - React, Vue, 바닐라 JS 지원",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",