partycles 1.0.0 → 1.1.3

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 (157) hide show
  1. package/README.md +27 -1
  2. package/dist/animations/animations/aurora.d.ts.map +1 -1
  3. package/dist/animations/animations/balloons.d.ts.map +1 -1
  4. package/dist/animations/animations/bubbles.d.ts.map +1 -1
  5. package/dist/animations/animations/coins.d.ts.map +1 -1
  6. package/dist/animations/animations/confetti.d.ts.map +1 -1
  7. package/dist/animations/animations/crystals.d.ts.map +1 -1
  8. package/dist/animations/animations/fireflies.d.ts.map +1 -1
  9. package/dist/animations/animations/fireworks.d.ts.map +1 -1
  10. package/dist/animations/animations/galaxy.d.ts.map +1 -1
  11. package/dist/animations/animations/glitch.d.ts.map +1 -1
  12. package/dist/animations/animations/index.d.ts.map +1 -1
  13. package/dist/animations/animations/leaves.d.ts.map +1 -1
  14. package/dist/animations/animations/magicdust.d.ts.map +1 -1
  15. package/dist/animations/animations/paint.d.ts.map +1 -1
  16. package/dist/animations/animations/petals.d.ts.map +1 -1
  17. package/dist/animations/animations/snow.d.ts.map +1 -1
  18. package/dist/animations/animations/sparkles.d.ts.map +1 -1
  19. package/dist/animations/animations/stars.d.ts.map +1 -1
  20. package/dist/animations/aurora.d.ts.map +1 -1
  21. package/dist/animations/balloons.d.ts.map +1 -1
  22. package/dist/animations/bubbles.d.ts.map +1 -1
  23. package/dist/animations/bubbles.esm.js +10 -3
  24. package/dist/animations/bubbles.esm.js.map +1 -1
  25. package/dist/animations/bubbles.js +10 -3
  26. package/dist/animations/bubbles.js.map +1 -1
  27. package/dist/animations/coins.d.ts.map +1 -1
  28. package/dist/animations/confetti.d.ts.map +1 -1
  29. package/dist/animations/confetti.esm.js +20 -3
  30. package/dist/animations/confetti.esm.js.map +1 -1
  31. package/dist/animations/confetti.js +20 -3
  32. package/dist/animations/confetti.js.map +1 -1
  33. package/dist/animations/crystals.d.ts.map +1 -1
  34. package/dist/animations/emoji.esm.js +3 -3
  35. package/dist/animations/emoji.esm.js.map +1 -1
  36. package/dist/animations/emoji.js +3 -3
  37. package/dist/animations/emoji.js.map +1 -1
  38. package/dist/animations/fireflies.d.ts.map +1 -1
  39. package/dist/animations/fireworks.d.ts.map +1 -1
  40. package/dist/animations/fireworks.esm.js +11 -3
  41. package/dist/animations/fireworks.esm.js.map +1 -1
  42. package/dist/animations/fireworks.js +11 -3
  43. package/dist/animations/fireworks.js.map +1 -1
  44. package/dist/animations/galaxy.d.ts.map +1 -1
  45. package/dist/animations/glitch.d.ts.map +1 -1
  46. package/dist/animations/hearts.esm.js +2 -2
  47. package/dist/animations/hearts.esm.js.map +1 -1
  48. package/dist/animations/hearts.js +2 -2
  49. package/dist/animations/hearts.js.map +1 -1
  50. package/dist/animations/index.d.ts +1 -0
  51. package/dist/animations/index.d.ts.map +1 -1
  52. package/dist/animations/leaves.d.ts.map +1 -1
  53. package/dist/animations/magicdust.d.ts.map +1 -1
  54. package/dist/animations/mobileOptimizations.d.ts +6 -0
  55. package/dist/animations/mobileOptimizations.d.ts.map +1 -0
  56. package/dist/animations/paint.d.ts.map +1 -1
  57. package/dist/animations/petals.d.ts.map +1 -1
  58. package/dist/animations/snow.d.ts.map +1 -1
  59. package/dist/animations/snow.esm.js +4 -2
  60. package/dist/animations/snow.esm.js.map +1 -1
  61. package/dist/animations/snow.js +4 -2
  62. package/dist/animations/snow.js.map +1 -1
  63. package/dist/animations/sparkles.d.ts.map +1 -1
  64. package/dist/animations/sparkles.esm.js +4 -2
  65. package/dist/animations/sparkles.esm.js.map +1 -1
  66. package/dist/animations/sparkles.js +4 -2
  67. package/dist/animations/sparkles.js.map +1 -1
  68. package/dist/animations/stars.d.ts.map +1 -1
  69. package/dist/animations/stars.esm.js +4 -2
  70. package/dist/animations/stars.esm.js.map +1 -1
  71. package/dist/animations/stars.js +4 -2
  72. package/dist/animations/stars.js.map +1 -1
  73. package/dist/animations/useReward.d.ts.map +1 -1
  74. package/dist/animations/utils.d.ts.map +1 -1
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.esm.js +230 -60
  78. package/dist/index.esm.js.map +1 -1
  79. package/dist/index.js +230 -58
  80. package/dist/index.js.map +1 -1
  81. package/dist/mobileOptimizations.d.ts +6 -0
  82. package/dist/mobileOptimizations.d.ts.map +1 -0
  83. package/dist/useReward.d.ts.map +1 -1
  84. package/dist/utils.d.ts.map +1 -1
  85. package/package.json +13 -2
  86. package/dist/animations/animations/bees.d.ts +0 -8
  87. package/dist/animations/animations/bees.d.ts.map +0 -1
  88. package/dist/animations/animations/butterflies.d.ts +0 -8
  89. package/dist/animations/animations/butterflies.d.ts.map +0 -1
  90. package/dist/animations/animations/candy.d.ts +0 -8
  91. package/dist/animations/animations/candy.d.ts.map +0 -1
  92. package/dist/animations/animations/champagne.d.ts +0 -8
  93. package/dist/animations/animations/champagne.d.ts.map +0 -1
  94. package/dist/animations/animations/dandelion.d.ts +0 -8
  95. package/dist/animations/animations/dandelion.d.ts.map +0 -1
  96. package/dist/animations/animations/dice.d.ts +0 -8
  97. package/dist/animations/animations/dice.d.ts.map +0 -1
  98. package/dist/animations/animations/donuts.d.ts +0 -8
  99. package/dist/animations/animations/donuts.d.ts.map +0 -1
  100. package/dist/animations/animations/dragons.d.ts +0 -8
  101. package/dist/animations/animations/dragons.d.ts.map +0 -1
  102. package/dist/animations/animations/ghosts.d.ts +0 -8
  103. package/dist/animations/animations/ghosts.d.ts.map +0 -1
  104. package/dist/animations/animations/levelup.d.ts +0 -8
  105. package/dist/animations/animations/levelup.d.ts.map +0 -1
  106. package/dist/animations/animations/lightning.d.ts +0 -8
  107. package/dist/animations/animations/lightning.d.ts.map +0 -1
  108. package/dist/animations/animations/matrix.d.ts +0 -8
  109. package/dist/animations/animations/matrix.d.ts.map +0 -1
  110. package/dist/animations/animations/music.d.ts +0 -8
  111. package/dist/animations/animations/music.d.ts.map +0 -1
  112. package/dist/animations/animations/pixels.d.ts +0 -8
  113. package/dist/animations/animations/pixels.d.ts.map +0 -1
  114. package/dist/animations/animations/pizza.d.ts +0 -8
  115. package/dist/animations/animations/pizza.d.ts.map +0 -1
  116. package/dist/animations/animations/popcorn.d.ts +0 -8
  117. package/dist/animations/animations/popcorn.d.ts.map +0 -1
  118. package/dist/animations/animations/rain.d.ts +0 -8
  119. package/dist/animations/animations/rain.d.ts.map +0 -1
  120. package/dist/animations/animations/runes.d.ts +0 -8
  121. package/dist/animations/animations/runes.d.ts.map +0 -1
  122. package/dist/animations/bees.d.ts +0 -8
  123. package/dist/animations/bees.d.ts.map +0 -1
  124. package/dist/animations/butterflies.d.ts +0 -8
  125. package/dist/animations/butterflies.d.ts.map +0 -1
  126. package/dist/animations/candy.d.ts +0 -8
  127. package/dist/animations/candy.d.ts.map +0 -1
  128. package/dist/animations/champagne.d.ts +0 -8
  129. package/dist/animations/champagne.d.ts.map +0 -1
  130. package/dist/animations/dandelion.d.ts +0 -8
  131. package/dist/animations/dandelion.d.ts.map +0 -1
  132. package/dist/animations/dice.d.ts +0 -8
  133. package/dist/animations/dice.d.ts.map +0 -1
  134. package/dist/animations/donuts.d.ts +0 -8
  135. package/dist/animations/donuts.d.ts.map +0 -1
  136. package/dist/animations/dragons.d.ts +0 -8
  137. package/dist/animations/dragons.d.ts.map +0 -1
  138. package/dist/animations/ghosts.d.ts +0 -8
  139. package/dist/animations/ghosts.d.ts.map +0 -1
  140. package/dist/animations/levelup.d.ts +0 -8
  141. package/dist/animations/levelup.d.ts.map +0 -1
  142. package/dist/animations/lightning.d.ts +0 -8
  143. package/dist/animations/lightning.d.ts.map +0 -1
  144. package/dist/animations/matrix.d.ts +0 -8
  145. package/dist/animations/matrix.d.ts.map +0 -1
  146. package/dist/animations/music.d.ts +0 -8
  147. package/dist/animations/music.d.ts.map +0 -1
  148. package/dist/animations/pixels.d.ts +0 -8
  149. package/dist/animations/pixels.d.ts.map +0 -1
  150. package/dist/animations/pizza.d.ts +0 -8
  151. package/dist/animations/pizza.d.ts.map +0 -1
  152. package/dist/animations/popcorn.d.ts +0 -8
  153. package/dist/animations/popcorn.d.ts.map +0 -1
  154. package/dist/animations/rain.d.ts +0 -8
  155. package/dist/animations/rain.d.ts.map +0 -1
  156. package/dist/animations/runes.d.ts +0 -8
  157. package/dist/animations/runes.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useRef, useCallback, useEffect } from 'react';
1
+ import React, { useState, useRef, useEffect, useCallback } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
 
4
4
  const randomInRange = (min, max) => {
@@ -11,7 +11,7 @@ const generateId = () => {
11
11
  return Math.random().toString(36).substring(2, 9);
12
12
  };
13
13
  const getRandomColor = (colors) => {
14
- return colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff';
14
+ return (colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff');
15
15
  };
16
16
  const createParticleStyle = (particle, containerRect) => {
17
17
  return {
@@ -26,9 +26,26 @@ const createParticleStyle = (particle, containerRect) => {
26
26
  };
27
27
  };
28
28
 
29
- const defaultColors$3 = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];
29
+ const defaultColors$3 = [
30
+ '#f44336',
31
+ '#e91e63',
32
+ '#9c27b0',
33
+ '#673ab7',
34
+ '#3f51b5',
35
+ '#2196f3',
36
+ '#03a9f4',
37
+ '#00bcd4',
38
+ '#009688',
39
+ '#4caf50',
40
+ '#8bc34a',
41
+ '#cddc39',
42
+ '#ffeb3b',
43
+ '#ffc107',
44
+ '#ff9800',
45
+ '#ff5722',
46
+ ];
30
47
  const createConfettiParticles = (origin, config) => {
31
- const { particleCount = 50, startVelocity = 20, colors = defaultColors$3, elementSize = 20 } = config;
48
+ const { particleCount = 50, startVelocity = 20, colors = defaultColors$3, elementSize = 20, } = config;
32
49
  const particles = [];
33
50
  for (let i = 0; i < particleCount; i++) {
34
51
  const angle = randomInRange(0, 360);
@@ -60,7 +77,7 @@ const renderConfettiParticle = (particle) => {
60
77
  };
61
78
 
62
79
  const createSparkleParticles = (origin, config) => {
63
- const { particleCount = 35, spread = 120, startVelocity = 15, elementSize = 25, colors = ['#FFD700', '#FFFFFF'] } = config;
80
+ const { particleCount = 35, spread = 120, startVelocity = 15, elementSize = 25, colors = ['#FFD700', '#FFFFFF'], } = config;
64
81
  const particles = [];
65
82
  for (let i = 0; i < particleCount; i++) {
66
83
  const velocityScale = startVelocity / 45; // Scale based on default
@@ -74,7 +91,9 @@ const createSparkleParticles = (origin, config) => {
74
91
  opacity: 0,
75
92
  size: randomInRange(elementSize * 0.4, elementSize * 1.2),
76
93
  rotation: randomInRange(0, 360),
77
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
94
+ color: colors[Math.floor(Math.random() * colors.length)] ||
95
+ colors[0] ||
96
+ '#ffffff',
78
97
  });
79
98
  }
80
99
  return particles;
@@ -90,7 +109,7 @@ const renderSparkleParticle = (particle) => {
90
109
 
91
110
  const heartColors = ['#ff1744', '#e91e63', '#ff4569', '#ff6b6b', '#ee5a70'];
92
111
  const createHeartParticles = (origin, config) => {
93
- const { particleCount = 25, startVelocity = 12, colors = heartColors, elementSize = 30 } = config;
112
+ const { particleCount = 25, startVelocity = 12, colors = heartColors, elementSize = 30, } = config;
94
113
  const particles = [];
95
114
  for (let i = 0; i < particleCount; i++) {
96
115
  const angle = randomInRange(-45, -135);
@@ -118,9 +137,17 @@ const renderHeartParticle = (particle) => {
118
137
  React.createElement("path", { d: "M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" })));
119
138
  };
120
139
 
121
- const fireworkColors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff', '#ffffff'];
140
+ const fireworkColors = [
141
+ '#ff0000',
142
+ '#00ff00',
143
+ '#0000ff',
144
+ '#ffff00',
145
+ '#ff00ff',
146
+ '#00ffff',
147
+ '#ffffff',
148
+ ];
122
149
  const createFireworkParticles = (origin, config) => {
123
- const { particleCount = 60, startVelocity = 25, colors = fireworkColors, elementSize = 8 } = config;
150
+ const { particleCount = 60, startVelocity = 25, colors = fireworkColors, elementSize = 8, } = config;
124
151
  const particles = [];
125
152
  for (let i = 0; i < particleCount; i++) {
126
153
  const angle = (360 / particleCount) * i + randomInRange(-5, 5);
@@ -157,9 +184,14 @@ const renderFireworkParticle = (particle) => {
157
184
  } }));
158
185
  };
159
186
 
160
- const bubbleColors = ['rgba(66, 165, 245, 0.4)', 'rgba(41, 182, 246, 0.4)', 'rgba(38, 198, 218, 0.4)', 'rgba(129, 212, 250, 0.4)'];
187
+ const bubbleColors = [
188
+ 'rgba(66, 165, 245, 0.4)',
189
+ 'rgba(41, 182, 246, 0.4)',
190
+ 'rgba(38, 198, 218, 0.4)',
191
+ 'rgba(129, 212, 250, 0.4)',
192
+ ];
161
193
  const createBubbleParticles = (origin, config) => {
162
- const { particleCount = 30, spread = 80, startVelocity = 8, colors = bubbleColors, elementSize = 40 } = config;
194
+ const { particleCount = 30, spread = 80, startVelocity = 8, colors = bubbleColors, elementSize = 40, } = config;
163
195
  const particles = [];
164
196
  for (let i = 0; i < particleCount; i++) {
165
197
  particles.push({
@@ -172,7 +204,9 @@ const createBubbleParticles = (origin, config) => {
172
204
  opacity: 0.7,
173
205
  size: randomInRange(elementSize * 0.4, elementSize * 1.2),
174
206
  rotation: 0,
175
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
207
+ color: colors[Math.floor(Math.random() * colors.length)] ||
208
+ colors[0] ||
209
+ '#ffffff',
176
210
  });
177
211
  }
178
212
  return particles;
@@ -194,7 +228,7 @@ const renderBubbleParticle = (particle) => {
194
228
 
195
229
  const starColors = ['#FFD700', '#FFA500', '#FF6347', '#FFE4B5'];
196
230
  const createStarParticles = (origin, config) => {
197
- const { particleCount = 40, startVelocity = 18, colors = starColors, elementSize = 30 } = config;
231
+ const { particleCount = 40, startVelocity = 18, colors = starColors, elementSize = 30, } = config;
198
232
  const particles = [];
199
233
  for (let i = 0; i < particleCount; i++) {
200
234
  const angle = randomInRange(0, 360);
@@ -209,7 +243,9 @@ const createStarParticles = (origin, config) => {
209
243
  opacity: 1,
210
244
  size: randomInRange(elementSize * 0.5, elementSize * 1.3),
211
245
  rotation: randomInRange(0, 360),
212
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
246
+ color: colors[Math.floor(Math.random() * colors.length)] ||
247
+ colors[0] ||
248
+ '#ffffff',
213
249
  });
214
250
  }
215
251
  return particles;
@@ -223,7 +259,7 @@ const renderStarParticle = (particle) => {
223
259
 
224
260
  const snowColors = ['#FFFFFF', '#F0F8FF', '#F5F5F5', '#FAFAFA'];
225
261
  const createSnowParticles = (origin, config) => {
226
- const { particleCount = 50, spread = 200, startVelocity = 3, colors = snowColors, elementSize = 15 } = config;
262
+ const { particleCount = 50, spread = 200, startVelocity = 3, colors = snowColors, elementSize = 15, } = config;
227
263
  const particles = [];
228
264
  for (let i = 0; i < particleCount; i++) {
229
265
  // Spread particles across the width, starting from above viewport
@@ -239,7 +275,9 @@ const createSnowParticles = (origin, config) => {
239
275
  opacity: randomInRange(0.4, 0.9),
240
276
  size: randomInRange(elementSize * 0.3, elementSize),
241
277
  rotation: randomInRange(0, 360),
242
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
278
+ color: colors[Math.floor(Math.random() * colors.length)] ||
279
+ colors[0] ||
280
+ '#ffffff',
243
281
  });
244
282
  }
245
283
  return particles;
@@ -266,7 +304,7 @@ const happyEmojis = ['😊', '😄', '🥰', '😍', '🤗', '😘', '😁', '
266
304
  const natureEmojis = ['🌸', '🌺', '🌻', '🌹', '🌷', '🌼', '🍀', '🌿'];
267
305
  const foodEmojis = ['🍕', '🍔', '🍟', '🌮', '🍿', '🍩', '🍪', '🧁'];
268
306
  const createEmojiParticles = (origin, config) => {
269
- const { particleCount = 30, spread = 100, startVelocity = 15, elementSize = 35, emojis = defaultEmojis } = config;
307
+ const { particleCount = 30, spread = 100, startVelocity = 15, elementSize = 35, emojis = defaultEmojis, } = config;
270
308
  const particles = [];
271
309
  for (let i = 0; i < particleCount; i++) {
272
310
  const angle = randomInRange(-45, -135);
@@ -282,7 +320,7 @@ const createEmojiParticles = (origin, config) => {
282
320
  size: randomInRange(elementSize * 0.7, elementSize * 1.3),
283
321
  rotation: randomInRange(-45, 45),
284
322
  color: '', // Not used for emojis
285
- element: emojis[Math.floor(Math.random() * emojis.length)]
323
+ element: emojis[Math.floor(Math.random() * emojis.length)],
286
324
  });
287
325
  }
288
326
  return particles;
@@ -302,12 +340,12 @@ const emojiPresets = {
302
340
  happy: happyEmojis,
303
341
  nature: natureEmojis,
304
342
  food: foodEmojis,
305
- default: defaultEmojis
343
+ default: defaultEmojis,
306
344
  };
307
345
 
308
346
  const coinColors = ['#FFD700', '#FFA500', '#FFB300', '#FFC700'];
309
347
  const createCoinParticles = (origin, config) => {
310
- const { particleCount = 30, spread = 70, startVelocity = 25, colors = coinColors, elementSize = 25 } = config;
348
+ const { particleCount = 30, spread = 70, startVelocity = 25, colors = coinColors, elementSize = 25, } = config;
311
349
  const particles = [];
312
350
  for (let i = 0; i < particleCount; i++) {
313
351
  const angle = randomInRange(-spread / 2, spread / 2) * (Math.PI / 180);
@@ -322,7 +360,9 @@ const createCoinParticles = (origin, config) => {
322
360
  opacity: 1,
323
361
  size: randomInRange(elementSize * 0.8, elementSize * 1.2),
324
362
  rotation: randomInRange(0, 360),
325
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
363
+ color: colors[Math.floor(Math.random() * colors.length)] ||
364
+ colors[0] ||
365
+ '#ffffff',
326
366
  });
327
367
  }
328
368
  return particles;
@@ -361,7 +401,7 @@ const renderCoinParticle = (particle) => {
361
401
 
362
402
  const petalColors = ['#FFB6C1', '#FFC0CB', '#FF69B4', '#FF1493', '#FFF0F5'];
363
403
  const createPetalParticles = (origin, config) => {
364
- const { particleCount = 40, spread = 100, startVelocity = 8, colors = petalColors, elementSize = 20 } = config;
404
+ const { particleCount = 40, spread = 100, startVelocity = 8, colors = petalColors, elementSize = 20, } = config;
365
405
  const particles = [];
366
406
  for (let i = 0; i < particleCount; i++) {
367
407
  const angle = randomInRange(-spread / 2, spread / 2) * (Math.PI / 180);
@@ -376,7 +416,9 @@ const createPetalParticles = (origin, config) => {
376
416
  opacity: randomInRange(0.7, 1),
377
417
  size: randomInRange(elementSize * 0.7, elementSize * 1.3),
378
418
  rotation: randomInRange(0, 360),
379
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
419
+ color: colors[Math.floor(Math.random() * colors.length)] ||
420
+ colors[0] ||
421
+ '#ffffff',
380
422
  });
381
423
  }
382
424
  return particles;
@@ -417,9 +459,17 @@ const renderPetalParticle = (particle) => {
417
459
  } })));
418
460
  };
419
461
 
420
- const auroraColors = ['#00ff88', '#00ffaa', '#00ddff', '#0099ff', '#0066ff', '#9933ff', '#ff00ff'];
462
+ const auroraColors = [
463
+ '#00ff88',
464
+ '#00ffaa',
465
+ '#00ddff',
466
+ '#0099ff',
467
+ '#0066ff',
468
+ '#9933ff',
469
+ '#ff00ff',
470
+ ];
421
471
  const createAuroraParticles = (origin, config) => {
422
- const { particleCount = 15, spread = 200, startVelocity = 3, colors = auroraColors, elementSize = 100 } = config;
472
+ const { particleCount = 15, spread = 200, startVelocity = 3, colors = auroraColors, elementSize = 100, } = config;
423
473
  const particles = [];
424
474
  for (let i = 0; i < particleCount; i++) {
425
475
  const angle = (i / particleCount) * spread - spread / 2;
@@ -434,7 +484,9 @@ const createAuroraParticles = (origin, config) => {
434
484
  opacity: 0,
435
485
  size: randomInRange(elementSize * 0.8, elementSize * 1.2),
436
486
  rotation: randomInRange(-15, 15),
437
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
487
+ color: colors[Math.floor(Math.random() * colors.length)] ||
488
+ colors[0] ||
489
+ '#ffffff',
438
490
  });
439
491
  }
440
492
  return particles;
@@ -476,7 +528,7 @@ const renderAuroraParticle = (particle) => {
476
528
 
477
529
  const fireflyColors = ['#FFFF99', '#FFFFCC', '#FFFF66', '#FFFFAA'];
478
530
  const createFireflyParticles = (origin, config) => {
479
- const { particleCount = 20, spread = 150, startVelocity = 2, colors = fireflyColors, elementSize = 8 } = config;
531
+ const { particleCount = 20, spread = 150, startVelocity = 2, colors = fireflyColors, elementSize = 8, } = config;
480
532
  const particles = [];
481
533
  for (let i = 0; i < particleCount; i++) {
482
534
  const angle = randomInRange(0, 360) * (Math.PI / 180);
@@ -491,7 +543,9 @@ const createFireflyParticles = (origin, config) => {
491
543
  opacity: 0,
492
544
  size: randomInRange(elementSize * 0.6, elementSize),
493
545
  rotation: randomInRange(0, 360), // Used for blink timing
494
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
546
+ color: colors[Math.floor(Math.random() * colors.length)] ||
547
+ colors[0] ||
548
+ '#ffffff',
495
549
  });
496
550
  }
497
551
  return particles;
@@ -541,9 +595,16 @@ const renderFireflyParticle = (particle) => {
541
595
  } })));
542
596
  };
543
597
 
544
- const paintColors = ['#FF006E', '#FB5607', '#FFBE0B', '#8338EC', '#3A86FF', '#06FFB4'];
598
+ const paintColors = [
599
+ '#FF006E',
600
+ '#FB5607',
601
+ '#FFBE0B',
602
+ '#8338EC',
603
+ '#3A86FF',
604
+ '#06FFB4',
605
+ ];
545
606
  const createPaintParticles = (origin, config) => {
546
- const { particleCount = 25, spread = 120, startVelocity = 35, colors = paintColors, elementSize = 30 } = config;
607
+ const { particleCount = 25, spread = 120, startVelocity = 35, colors = paintColors, elementSize = 30, } = config;
547
608
  const particles = [];
548
609
  for (let i = 0; i < particleCount; i++) {
549
610
  const angle = randomInRange(-spread / 2, spread / 2) * (Math.PI / 180);
@@ -561,7 +622,9 @@ const createPaintParticles = (origin, config) => {
561
622
  ? randomInRange(elementSize * 1.5, elementSize * 2.5)
562
623
  : randomInRange(elementSize * 0.3, elementSize),
563
624
  rotation: randomInRange(0, 360),
564
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
625
+ color: colors[Math.floor(Math.random() * colors.length)] ||
626
+ colors[0] ||
627
+ '#ffffff',
565
628
  });
566
629
  }
567
630
  return particles;
@@ -580,7 +643,7 @@ const renderPaintParticle = (particle) => {
580
643
  transform: `
581
644
  scaleX(${stretch})
582
645
  scaleY(${squish})
583
- rotate(${Math.atan2(particle.vy, particle.vx) * 180 / Math.PI}deg)
646
+ rotate(${(Math.atan2(particle.vy, particle.vx) * 180) / Math.PI}deg)
584
647
  `,
585
648
  } },
586
649
  React.createElement("div", { style: {
@@ -624,9 +687,17 @@ const renderPaintParticle = (particle) => {
624
687
  } }))));
625
688
  };
626
689
 
627
- const balloonColors = ['#FF006E', '#FB5607', '#FFBE0B', '#8338EC', '#3A86FF', '#06FFB4', '#FF4081'];
690
+ const balloonColors = [
691
+ '#FF006E',
692
+ '#FB5607',
693
+ '#FFBE0B',
694
+ '#8338EC',
695
+ '#3A86FF',
696
+ '#06FFB4',
697
+ '#FF4081',
698
+ ];
628
699
  const createBalloonParticles = (origin, config) => {
629
- const { particleCount = 15, spread = 80, startVelocity = 10, colors = balloonColors, elementSize = 35 } = config;
700
+ const { particleCount = 15, spread = 80, startVelocity = 10, colors = balloonColors, elementSize = 35, } = config;
630
701
  const particles = [];
631
702
  for (let i = 0; i < particleCount; i++) {
632
703
  const angle = randomInRange(-spread / 2, spread / 2) * (Math.PI / 180);
@@ -641,7 +712,9 @@ const createBalloonParticles = (origin, config) => {
641
712
  opacity: 0.9,
642
713
  size: randomInRange(elementSize * 0.8, elementSize * 1.2),
643
714
  rotation: randomInRange(-10, 10),
644
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
715
+ color: colors[Math.floor(Math.random() * colors.length)] ||
716
+ colors[0] ||
717
+ '#ffffff',
645
718
  });
646
719
  }
647
720
  return particles;
@@ -707,9 +780,17 @@ const renderBalloonParticle = (particle) => {
707
780
  React.createElement("path", { d: `M1 0 Q ${1 + Math.sin(particle.life * 0.1) * 3} ${particle.size} 1 ${particle.size * 2}`, stroke: particle.color, strokeWidth: "1.5", fill: "none", opacity: "0.4" }))));
708
781
  };
709
782
 
710
- const galaxyColors = ['#FFFFFF', '#FFF9C4', '#BBDEFB', '#C5CAE9', '#D1C4E9', '#FFE082', '#FFCCBC'];
783
+ const galaxyColors = [
784
+ '#FFFFFF',
785
+ '#FFF9C4',
786
+ '#BBDEFB',
787
+ '#C5CAE9',
788
+ '#D1C4E9',
789
+ '#FFE082',
790
+ '#FFCCBC',
791
+ ];
711
792
  const createGalaxyParticles = (origin, config) => {
712
- const { particleCount = 60, spread = 200, startVelocity = 15, colors = galaxyColors, elementSize = 8 } = config;
793
+ const { particleCount = 60, spread = 200, startVelocity = 15, colors = galaxyColors, elementSize = 8, } = config;
713
794
  const particles = [];
714
795
  for (let i = 0; i < particleCount; i++) {
715
796
  // Create spiral distribution
@@ -737,7 +818,9 @@ const createGalaxyParticles = (origin, config) => {
737
818
  opacity: 0,
738
819
  size: randomInRange(elementSize * 0.3, elementSize) * (1 - progress * 0.5), // Smaller at edges
739
820
  rotation: randomInRange(0, 360),
740
- color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
821
+ color: colors[Math.floor(Math.random() * colors.length)] ||
822
+ colors[0] ||
823
+ '#ffffff',
741
824
  });
742
825
  }
743
826
  return particles;
@@ -855,8 +938,7 @@ const renderGlitchParticle = (particle) => {
855
938
  g: channel === 'g' ? 255 : 0,
856
939
  b: channel === 'b' ? 255 : 0,
857
940
  };
858
- const mixBlendMode = channel === 'r' ? 'screen' :
859
- channel === 'g' ? 'multiply' : 'difference';
941
+ const mixBlendMode = channel === 'r' ? 'screen' : channel === 'g' ? 'multiply' : 'difference';
860
942
  return (React.createElement("div", { key: particle.id, style: {
861
943
  width: `${width}px`,
862
944
  height: `${height}px`,
@@ -867,9 +949,18 @@ const renderGlitchParticle = (particle) => {
867
949
  } }));
868
950
  };
869
951
 
870
- const defaultColors$2 = ['#9C27B0', '#E91E63', '#FF00FF', '#00FFFF', '#FFD700', '#FF69B4', '#DA70D6', '#9370DB'];
952
+ const defaultColors$2 = [
953
+ '#9C27B0',
954
+ '#E91E63',
955
+ '#FF00FF',
956
+ '#00FFFF',
957
+ '#FFD700',
958
+ '#FF69B4',
959
+ '#DA70D6',
960
+ '#9370DB',
961
+ ];
871
962
  const createMagicDustParticles = (origin, config) => {
872
- const { particleCount = 40, startVelocity = 8, colors = defaultColors$2, elementSize = 12 } = config;
963
+ const { particleCount = 40, startVelocity = 8, colors = defaultColors$2, elementSize = 12, } = config;
873
964
  const particles = [];
874
965
  for (let i = 0; i < particleCount; i++) {
875
966
  // Create particles in a circular pattern with some randomness
@@ -940,9 +1031,18 @@ const renderMagicDustParticle = (particle) => {
940
1031
  } }))));
941
1032
  };
942
1033
 
943
- const defaultColors$1 = ['#FF1493', '#00CED1', '#FFD700', '#FF69B4', '#7B68EE', '#00FA9A', '#FF6347', '#4169E1'];
1034
+ const defaultColors$1 = [
1035
+ '#FF1493',
1036
+ '#00CED1',
1037
+ '#FFD700',
1038
+ '#FF69B4',
1039
+ '#7B68EE',
1040
+ '#00FA9A',
1041
+ '#FF6347',
1042
+ '#4169E1',
1043
+ ];
944
1044
  const createCrystalParticles = (origin, config) => {
945
- const { particleCount = 15, startVelocity = 15, colors = defaultColors$1, elementSize = 25 } = config;
1045
+ const { particleCount = 15, startVelocity = 15, colors = defaultColors$1, elementSize = 25, } = config;
946
1046
  const particles = [];
947
1047
  for (let i = 0; i < particleCount; i++) {
948
1048
  // Crystals explode outward and fall with gravity
@@ -1014,9 +1114,16 @@ const renderCrystalParticle = (particle) => {
1014
1114
  } })));
1015
1115
  };
1016
1116
 
1017
- const defaultColors = ['#D2691E', '#CD853F', '#8B4513', '#A0522D', '#FF8C00', '#FF6347'];
1117
+ const defaultColors = [
1118
+ '#D2691E',
1119
+ '#CD853F',
1120
+ '#8B4513',
1121
+ '#A0522D',
1122
+ '#FF8C00',
1123
+ '#FF6347',
1124
+ ];
1018
1125
  const createLeafParticles = (origin, config) => {
1019
- const { particleCount = 10, colors = defaultColors, elementSize = 25 } = config;
1126
+ const { particleCount = 10, colors = defaultColors, elementSize = 25, } = config;
1020
1127
  const particles = [];
1021
1128
  for (let i = 0; i < particleCount; i++) {
1022
1129
  particles.push({
@@ -1030,9 +1137,9 @@ const createLeafParticles = (origin, config) => {
1030
1137
  size: randomInRange(elementSize * 0.6, elementSize),
1031
1138
  // Encode tumble phase (0-360), sway phase (0-360), and sway amount (20-40) + rotation speed (-3 to 3)
1032
1139
  rotation: Math.floor(randomInRange(0, 360)) +
1033
- (Math.floor(randomInRange(0, 360)) * 1000) +
1034
- (Math.floor(randomInRange(20, 40)) * 1000000) +
1035
- ((Math.floor(randomInRange(-3, 3)) + 3) * 100000000),
1140
+ Math.floor(randomInRange(0, 360)) * 1000 +
1141
+ Math.floor(randomInRange(20, 40)) * 1000000 +
1142
+ (Math.floor(randomInRange(-3, 3)) + 3) * 100000000,
1036
1143
  color: getRandomColor(colors),
1037
1144
  });
1038
1145
  }
@@ -1043,10 +1150,10 @@ const renderLeafParticle = (particle) => {
1043
1150
  const tumblePhase = particle.rotation % 1000;
1044
1151
  const swayPhase = Math.floor((particle.rotation % 1000000) / 1000);
1045
1152
  const swayAmount = Math.floor((particle.rotation % 100000000) / 1000000);
1046
- const rotationSpeed = (Math.floor(particle.rotation / 100000000) - 3);
1153
+ const rotationSpeed = Math.floor(particle.rotation / 100000000) - 3;
1047
1154
  // Calculate tumbling and swaying
1048
- const tumble = Math.sin((Date.now() * 0.002 + tumblePhase) * Math.PI / 180) * 30;
1049
- const swayX = Math.sin((Date.now() * 0.001 + swayPhase) * Math.PI / 180) * swayAmount;
1155
+ const tumble = Math.sin(((Date.now() * 0.002 + tumblePhase) * Math.PI) / 180) * 30;
1156
+ const swayX = Math.sin(((Date.now() * 0.001 + swayPhase) * Math.PI) / 180) * swayAmount;
1050
1157
  const rotation = (Date.now() * rotationSpeed * 0.01 + tumble) % 360;
1051
1158
  return (React.createElement("div", { key: particle.id, style: {
1052
1159
  width: `${particle.size}px`,
@@ -1150,12 +1257,60 @@ const animations = {
1150
1257
  },
1151
1258
  };
1152
1259
 
1260
+ const isMobileDevice = () => {
1261
+ if (typeof window === 'undefined')
1262
+ return false;
1263
+ // Check user agent
1264
+ const userAgent = navigator.userAgent ||
1265
+ navigator.vendor ||
1266
+ window.opera ||
1267
+ '';
1268
+ const isMobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
1269
+ // Check viewport width
1270
+ const isMobileWidth = window.innerWidth <= 768;
1271
+ // Check touch support
1272
+ const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
1273
+ return isMobileUA || (isMobileWidth && hasTouch);
1274
+ };
1275
+ const optimizeConfigForMobile = (config) => {
1276
+ var _a, _b, _c;
1277
+ if (!isMobileDevice())
1278
+ return config;
1279
+ return Object.assign(Object.assign({}, config), {
1280
+ // Reduce particle count by 40%
1281
+ particleCount: Math.floor((config.particleCount || 50) * 0.6),
1282
+ // Reduce element size by 20%
1283
+ elementSize: Math.floor((config.elementSize || 20) * 0.8),
1284
+ // Reduce lifetime by 20%
1285
+ lifetime: Math.floor((config.lifetime || 150) * 0.8),
1286
+ // Simplify physics
1287
+ physics: Object.assign(Object.assign({}, config.physics), {
1288
+ // Reduce precision for mobile
1289
+ gravity: Math.round((((_a = config.physics) === null || _a === void 0 ? void 0 : _a.gravity) || 0) * 100) / 100, wind: Math.round((((_b = config.physics) === null || _b === void 0 ? void 0 : _b.wind) || 0) * 100) / 100, friction: Math.round((((_c = config.physics) === null || _c === void 0 ? void 0 : _c.friction) || 0.98) * 100) / 100 }) });
1290
+ };
1291
+ // Frame skipping for mobile
1292
+ const shouldSkipFrame = (frameCount) => {
1293
+ if (!isMobileDevice())
1294
+ return false;
1295
+ // Skip every 3rd frame on mobile
1296
+ return frameCount % 3 === 0;
1297
+ };
1298
+
1153
1299
  const useReward = (elementId, animationType, config) => {
1154
1300
  const [isAnimating, setIsAnimating] = useState(false);
1155
1301
  const animationFrameRef = useRef();
1156
1302
  const particlesRef = useRef([]);
1157
1303
  const containerRef = useRef(null);
1158
1304
  const rootRef = useRef(null);
1305
+ const isTabVisible = useRef(true);
1306
+ // Monitor tab visibility
1307
+ useEffect(() => {
1308
+ const handleVisibilityChange = () => {
1309
+ isTabVisible.current = !document.hidden;
1310
+ };
1311
+ document.addEventListener('visibilitychange', handleVisibilityChange);
1312
+ return () => document.removeEventListener('visibilitychange', handleVisibilityChange);
1313
+ }, []);
1159
1314
  const animate = useCallback(() => {
1160
1315
  var _a, _b, _c, _d, _e, _f;
1161
1316
  const element = document.getElementById(elementId);
@@ -1171,8 +1326,12 @@ const useReward = (elementId, animationType, config) => {
1171
1326
  console.error(`Animation type "${animationType}" not found`);
1172
1327
  return;
1173
1328
  }
1329
+ // Apply mobile performance optimizations
1330
+ const optimizedConfig = config
1331
+ ? optimizeConfigForMobile(config)
1332
+ : undefined;
1174
1333
  // Create particles
1175
- particlesRef.current = animationHandler.createParticles(origin, config || {});
1334
+ particlesRef.current = animationHandler.createParticles(origin, optimizedConfig || {});
1176
1335
  // Create container
1177
1336
  const container = document.createElement('div');
1178
1337
  container.style.position = 'fixed';
@@ -1189,12 +1348,21 @@ const useReward = (elementId, animationType, config) => {
1189
1348
  rootRef.current = root;
1190
1349
  const containerRect = container.getBoundingClientRect();
1191
1350
  // Default gravity varies by animation type
1192
- const defaultGravity = animationType === 'bubbles' ? -0.1 : animationType === 'snow' ? 0.05 : 0.35;
1351
+ const defaultGravity = animationType === 'bubbles'
1352
+ ? -0.1
1353
+ : animationType === 'snow'
1354
+ ? 0.05
1355
+ : 0.35;
1193
1356
  const gravity = (_b = (_a = config === null || config === void 0 ? void 0 : config.physics) === null || _a === void 0 ? void 0 : _a.gravity) !== null && _b !== void 0 ? _b : defaultGravity;
1194
1357
  const friction = (_d = (_c = config === null || config === void 0 ? void 0 : config.physics) === null || _c === void 0 ? void 0 : _c.friction) !== null && _d !== void 0 ? _d : 0.98;
1195
1358
  const wind = (_f = (_e = config === null || config === void 0 ? void 0 : config.physics) === null || _e === void 0 ? void 0 : _e.wind) !== null && _f !== void 0 ? _f : 0;
1359
+ // Track frame count for mobile optimization
1360
+ let frameCount = 0;
1196
1361
  const updateParticles = () => {
1197
1362
  let activeParticles = 0;
1363
+ frameCount++;
1364
+ // Skip frame rendering on mobile to improve performance
1365
+ const skipFrame = shouldSkipFrame(frameCount);
1198
1366
  particlesRef.current = particlesRef.current.map((particle) => {
1199
1367
  if (particle.life <= 0)
1200
1368
  return particle;
@@ -1222,13 +1390,13 @@ const useReward = (elementId, animationType, config) => {
1222
1390
  }
1223
1391
  return particle;
1224
1392
  });
1225
- // Render particles
1226
- if (rootRef.current) {
1393
+ // Render particles (skip rendering on mobile for some frames)
1394
+ if (rootRef.current && !skipFrame) {
1227
1395
  rootRef.current.render(React.createElement(React.Fragment, null, particlesRef.current
1228
1396
  .filter((p) => p.life > 0)
1229
1397
  .map((particle) => (React.createElement("div", { key: particle.id, style: createParticleStyle(particle, containerRect) }, animationHandler.renderParticle(particle))))));
1230
1398
  }
1231
- if (activeParticles > 0) {
1399
+ if (activeParticles > 0 && isTabVisible.current) {
1232
1400
  animationFrameRef.current = requestAnimationFrame(updateParticles);
1233
1401
  }
1234
1402
  else {
@@ -1240,7 +1408,8 @@ const useReward = (elementId, animationType, config) => {
1240
1408
  rootRef.current.unmount();
1241
1409
  rootRef.current = null;
1242
1410
  }
1243
- if (containerRef.current && document.body.contains(containerRef.current)) {
1411
+ if (containerRef.current &&
1412
+ document.body.contains(containerRef.current)) {
1244
1413
  document.body.removeChild(containerRef.current);
1245
1414
  containerRef.current = null;
1246
1415
  }
@@ -1265,7 +1434,8 @@ const useReward = (elementId, animationType, config) => {
1265
1434
  rootRef.current.unmount();
1266
1435
  rootRef.current = null;
1267
1436
  }
1268
- if (containerRef.current && document.body.contains(containerRef.current)) {
1437
+ if (containerRef.current &&
1438
+ document.body.contains(containerRef.current)) {
1269
1439
  document.body.removeChild(containerRef.current);
1270
1440
  containerRef.current = null;
1271
1441
  }
@@ -1274,5 +1444,5 @@ const useReward = (elementId, animationType, config) => {
1274
1444
  return { reward, isAnimating };
1275
1445
  };
1276
1446
 
1277
- export { emojiPresets, useReward };
1447
+ export { emojiPresets, isMobileDevice, optimizeConfigForMobile, useReward };
1278
1448
  //# sourceMappingURL=index.esm.js.map