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.
- package/README.md +320 -231
- package/dist/core/count/index.d.ts +52 -0
- package/dist/core/count/index.d.ts.map +1 -0
- package/dist/core/index.d.ts +15 -97
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/textToParticle/index.d.ts +103 -0
- package/dist/core/textToParticle/index.d.ts.map +1 -0
- package/dist/count/core/count/index.d.ts +52 -0
- package/dist/count/core/count/index.d.ts.map +1 -0
- package/dist/count/core/index.d.ts +18 -0
- package/dist/count/core/index.d.ts.map +1 -0
- package/dist/count/core/textToParticle/index.d.ts +103 -0
- package/dist/count/core/textToParticle/index.d.ts.map +1 -0
- package/dist/count/index.cjs +1 -0
- package/dist/count/index.d.ts +16 -0
- package/dist/count/index.d.ts.map +1 -0
- package/dist/count/index.mjs +1 -0
- package/dist/count/index.umd.d.ts +7 -0
- package/dist/count/index.umd.d.ts.map +1 -0
- package/dist/count/react/MasonEffect.d.ts +32 -0
- package/dist/count/react/MasonEffect.d.ts.map +1 -0
- package/dist/count/react/count/Count.d.ts +19 -0
- package/dist/count/react/count/Count.d.ts.map +1 -0
- package/dist/count/react/count/index.d.ts +5 -0
- package/dist/count/react/count/index.d.ts.map +1 -0
- package/dist/count/react/index.d.ts +12 -0
- package/dist/count/react/index.d.ts.map +1 -0
- package/dist/count/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/count/react/textToParticle/index.d.ts +4 -0
- package/dist/count/react/textToParticle/index.d.ts.map +1 -0
- package/dist/count/svelte/count/index.d.ts +2 -0
- package/dist/count/svelte/count/index.d.ts.map +1 -0
- package/dist/count/svelte/index.d.ts +8 -0
- package/dist/count/svelte/index.d.ts.map +1 -0
- package/dist/count/svelte/textToParticle/index.d.ts +2 -0
- package/dist/count/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/count/vue/count/index.d.ts +2 -0
- package/dist/count/vue/count/index.d.ts.map +1 -0
- package/dist/count/vue/index.d.ts +8 -0
- package/dist/count/vue/index.d.ts.map +1 -0
- package/dist/count/vue/textToParticle/index.d.ts +2 -0
- package/dist/count/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/react/core/count/index.d.ts +51 -0
- package/dist/react/core/index.d.ts +15 -97
- package/dist/react/core/textToParticle/index.d.ts +102 -0
- package/dist/react/count/Count.d.ts +19 -0
- package/dist/react/count/Count.d.ts.map +1 -0
- package/dist/react/count/core/count/index.d.ts +52 -0
- package/dist/react/count/core/count/index.d.ts.map +1 -0
- package/dist/react/count/core/index.d.ts +18 -0
- package/dist/react/count/core/index.d.ts.map +1 -0
- package/dist/react/count/core/textToParticle/index.d.ts +103 -0
- package/dist/react/count/core/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/index.cjs +1 -0
- package/dist/react/count/index.d.ts +16 -0
- package/dist/react/count/index.d.ts.map +1 -0
- package/dist/react/count/index.mjs +1 -0
- package/dist/react/count/index.umd.d.ts +7 -0
- package/dist/react/count/index.umd.d.ts.map +1 -0
- package/dist/react/count/react/MasonEffect.d.ts +32 -0
- package/dist/react/count/react/MasonEffect.d.ts.map +1 -0
- package/dist/react/count/react/count/Count.d.ts +19 -0
- package/dist/react/count/react/count/Count.d.ts.map +1 -0
- package/dist/react/count/react/count/index.d.ts +5 -0
- package/dist/react/count/react/count/index.d.ts.map +1 -0
- package/dist/react/count/react/index.d.ts +12 -0
- package/dist/react/count/react/index.d.ts.map +1 -0
- package/dist/react/count/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/count/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/count/react/textToParticle/index.d.ts +4 -0
- package/dist/react/count/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/svelte/count/index.d.ts +2 -0
- package/dist/react/count/svelte/count/index.d.ts.map +1 -0
- package/dist/react/count/svelte/index.d.ts +8 -0
- package/dist/react/count/svelte/index.d.ts.map +1 -0
- package/dist/react/count/svelte/textToParticle/index.d.ts +2 -0
- package/dist/react/count/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/react/count/vue/count/index.d.ts +2 -0
- package/dist/react/count/vue/count/index.d.ts.map +1 -0
- package/dist/react/count/vue/index.d.ts +8 -0
- package/dist/react/count/vue/index.d.ts.map +1 -0
- package/dist/react/count/vue/textToParticle/index.d.ts +2 -0
- package/dist/react/count/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/react/index.cjs +12 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.mjs +2 -1
- package/dist/react/react/count/Count.d.ts +18 -0
- package/dist/react/react/count/index.d.ts +4 -0
- package/dist/react/react/index.d.ts +11 -2
- package/dist/react/react/textToParticle/TextToParticle.d.ts +14 -0
- package/dist/react/react/textToParticle/index.d.ts +3 -0
- package/dist/react/svelte/count/index.d.ts +1 -0
- package/dist/react/svelte/index.d.ts +5 -3
- package/dist/react/svelte/textToParticle/index.d.ts +1 -0
- package/dist/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/textToParticle/core/count/index.d.ts +52 -0
- package/dist/react/textToParticle/core/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/core/index.d.ts +18 -0
- package/dist/react/textToParticle/core/index.d.ts.map +1 -0
- package/dist/react/textToParticle/core/textToParticle/index.d.ts +103 -0
- package/dist/react/textToParticle/core/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/index.cjs +1 -0
- package/dist/react/textToParticle/index.d.ts +16 -0
- package/dist/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/index.mjs +1 -0
- package/dist/react/textToParticle/index.umd.d.ts +7 -0
- package/dist/react/textToParticle/index.umd.d.ts.map +1 -0
- package/dist/react/textToParticle/react/MasonEffect.d.ts +32 -0
- package/dist/react/textToParticle/react/MasonEffect.d.ts.map +1 -0
- package/dist/react/textToParticle/react/count/Count.d.ts +19 -0
- package/dist/react/textToParticle/react/count/Count.d.ts.map +1 -0
- package/dist/react/textToParticle/react/count/index.d.ts +5 -0
- package/dist/react/textToParticle/react/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/react/index.d.ts +12 -0
- package/dist/react/textToParticle/react/index.d.ts.map +1 -0
- package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/react/textToParticle/react/textToParticle/index.d.ts +4 -0
- package/dist/react/textToParticle/react/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/count/index.d.ts +2 -0
- package/dist/react/textToParticle/svelte/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/index.d.ts +8 -0
- package/dist/react/textToParticle/svelte/index.d.ts.map +1 -0
- package/dist/react/textToParticle/svelte/textToParticle/index.d.ts +2 -0
- package/dist/react/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/count/index.d.ts +2 -0
- package/dist/react/textToParticle/vue/count/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/index.d.ts +8 -0
- package/dist/react/textToParticle/vue/index.d.ts.map +1 -0
- package/dist/react/textToParticle/vue/textToParticle/index.d.ts +2 -0
- package/dist/react/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/react/vue/count/index.d.ts +1 -0
- package/dist/react/vue/index.d.ts +5 -3
- package/dist/react/vue/textToParticle/index.d.ts +1 -0
- package/dist/svelte/count/index.cjs +1 -0
- package/dist/svelte/count/index.d.ts +163 -0
- package/dist/svelte/count/index.mjs +659 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.d.ts +88 -29
- package/dist/svelte/index.mjs +402 -8
- package/dist/svelte/textToParticle/index.cjs +1 -0
- package/dist/svelte/textToParticle/index.d.ts +163 -0
- package/dist/svelte/textToParticle/index.mjs +924 -0
- package/dist/textToParticle/core/count/index.d.ts +52 -0
- package/dist/textToParticle/core/count/index.d.ts.map +1 -0
- package/dist/textToParticle/core/index.d.ts +18 -0
- package/dist/textToParticle/core/index.d.ts.map +1 -0
- package/dist/textToParticle/core/textToParticle/index.d.ts +103 -0
- package/dist/textToParticle/core/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/index.cjs +1 -0
- package/dist/textToParticle/index.d.ts +16 -0
- package/dist/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/index.mjs +1 -0
- package/dist/textToParticle/index.umd.d.ts +7 -0
- package/dist/textToParticle/index.umd.d.ts.map +1 -0
- package/dist/textToParticle/react/MasonEffect.d.ts +32 -0
- package/dist/textToParticle/react/MasonEffect.d.ts.map +1 -0
- package/dist/textToParticle/react/count/Count.d.ts +19 -0
- package/dist/textToParticle/react/count/Count.d.ts.map +1 -0
- package/dist/textToParticle/react/count/index.d.ts +5 -0
- package/dist/textToParticle/react/count/index.d.ts.map +1 -0
- package/dist/textToParticle/react/index.d.ts +12 -0
- package/dist/textToParticle/react/index.d.ts.map +1 -0
- package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts +15 -0
- package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -0
- package/dist/textToParticle/react/textToParticle/index.d.ts +4 -0
- package/dist/textToParticle/react/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/count/index.d.ts +2 -0
- package/dist/textToParticle/svelte/count/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/index.d.ts +8 -0
- package/dist/textToParticle/svelte/index.d.ts.map +1 -0
- package/dist/textToParticle/svelte/textToParticle/index.d.ts +2 -0
- package/dist/textToParticle/svelte/textToParticle/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/count/index.d.ts +2 -0
- package/dist/textToParticle/vue/count/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/index.d.ts +8 -0
- package/dist/textToParticle/vue/index.d.ts.map +1 -0
- package/dist/textToParticle/vue/textToParticle/index.d.ts +2 -0
- package/dist/textToParticle/vue/textToParticle/index.d.ts.map +1 -0
- package/dist/vue/count/index.cjs +1 -0
- package/dist/vue/count/index.d.ts +163 -0
- package/dist/vue/count/index.mjs +286 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.d.ts +88 -29
- package/dist/vue/index.mjs +291 -6
- package/dist/vue/textToParticle/index.cjs +1 -0
- package/dist/vue/textToParticle/index.d.ts +163 -0
- package/dist/vue/textToParticle/index.mjs +554 -0
- package/package.json +54 -5
package/README.md
CHANGED
|
@@ -1,26 +1,65 @@
|
|
|
1
1
|
# MasonEffect 
|
|
2
2
|
|
|
3
|
-
**Release version
|
|
3
|
+
**Release version 2.0.1**
|
|
4
4
|
|
|
5
|
-
A
|
|
5
|
+
A collection of animation effects library. Supports React, Vue, Svelte, and vanilla JavaScript with **Tree-shaking** support.
|
|
6
6
|
|
|
7
|
-
##
|
|
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
|
-
##
|
|
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
|
-
|
|
52
|
+
## 📖 Usage
|
|
16
53
|
|
|
17
|
-
|
|
54
|
+
### TextToParticle Effect
|
|
55
|
+
|
|
56
|
+
#### Vanilla JavaScript
|
|
18
57
|
|
|
19
58
|
```javascript
|
|
20
|
-
import {
|
|
59
|
+
import { TextToParticle } from 'masoneffect/textToParticle';
|
|
21
60
|
|
|
22
61
|
const container = document.getElementById('my-container');
|
|
23
|
-
const effect = new
|
|
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
|
|
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
|
-
####
|
|
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
|
|
83
|
-
import type {
|
|
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<
|
|
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'
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
### Vue 3
|
|
107
|
+
#### Vue 3
|
|
145
108
|
|
|
146
109
|
```vue
|
|
147
110
|
<script setup>
|
|
148
|
-
import
|
|
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
|
-
<
|
|
118
|
+
<TextToParticle
|
|
175
119
|
ref="effectRef"
|
|
176
120
|
text="Hello Vue"
|
|
177
|
-
|
|
121
|
+
particle-color="#00ff88"
|
|
178
122
|
:max-particles="2000"
|
|
179
|
-
@ready="onReady"
|
|
180
123
|
/>
|
|
181
|
-
|
|
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
|
-
|
|
129
|
+
#### Svelte
|
|
193
130
|
|
|
194
131
|
```svelte
|
|
195
132
|
<script lang="ts">
|
|
196
|
-
import
|
|
197
|
-
|
|
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
|
|
233
|
-
<
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 📚 API Reference
|
|
252
255
|
|
|
253
|
-
|
|
256
|
+
### TextToParticle
|
|
254
257
|
|
|
255
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
279
|
+
#### Methods
|
|
277
280
|
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
|
|
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
|
-
|
|
300
|
-
|
|
348
|
+
// Vue
|
|
349
|
+
import Count from 'masoneffect/vue/count';
|
|
350
|
+
import TextToParticle from 'masoneffect/vue/textToParticle';
|
|
301
351
|
|
|
302
|
-
|
|
303
|
-
|
|
352
|
+
// Svelte
|
|
353
|
+
import Count from 'masoneffect/svelte/count';
|
|
354
|
+
import TextToParticle from 'masoneffect/svelte/textToParticle';
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
304
358
|
|
|
305
|
-
|
|
306
|
-
Destroys the instance and cleans up resources.
|
|
359
|
+
## 🔄 Backward Compatibility
|
|
307
360
|
|
|
308
|
-
|
|
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
|
-
-
|
|
315
|
-
-
|
|
316
|
-
-
|
|
317
|
-
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
-
|
|
321
|
-
-
|
|
322
|
-
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
|
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
|
-
|
|
413
|
+
---
|
|
341
414
|
|
|
342
|
-
|
|
415
|
+
## 📦 CDN Usage (UMD)
|
|
343
416
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
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)
|