partycles 1.1.4 → 1.1.5
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 +60 -1
- package/dist/animations/animations/coins.d.ts +3 -1
- package/dist/animations/animations/coins.d.ts.map +1 -1
- package/dist/animations/animations/hearts.d.ts +3 -1
- package/dist/animations/animations/hearts.d.ts.map +1 -1
- package/dist/animations/coins.d.ts +3 -1
- package/dist/animations/coins.d.ts.map +1 -1
- package/dist/animations/hearts.d.ts +3 -1
- package/dist/animations/hearts.d.ts.map +1 -1
- package/dist/animations/hearts.esm.js +7 -1
- package/dist/animations/hearts.esm.js.map +1 -1
- package/dist/animations/hearts.js +7 -1
- package/dist/animations/hearts.js.map +1 -1
- package/dist/animations/types.d.ts +9 -0
- package/dist/animations/types.d.ts.map +1 -1
- package/dist/animations/useReward.d.ts.map +1 -1
- package/dist/index.esm.js +45 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useReward.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -133,8 +133,14 @@ const createHeartParticles = (origin, config) => {
|
|
133
133
|
return particles;
|
134
134
|
};
|
135
135
|
const renderHeartParticle = (particle) => {
|
136
|
-
|
136
|
+
var _a, _b;
|
137
|
+
// Calculate pulse effect if enabled
|
138
|
+
const pulse = ((_b = (_a = particle.config) === null || _a === void 0 ? void 0 : _a.effects) === null || _b === void 0 ? void 0 : _b.pulse)
|
139
|
+
? 1 + Math.sin(particle.life * 0.2) * 0.1
|
140
|
+
: 1;
|
141
|
+
return (React.createElement("svg", { key: particle.id, width: particle.size * pulse, height: particle.size * pulse, viewBox: "0 0 24 24", fill: particle.color, style: {
|
137
142
|
filter: `drop-shadow(0 0 ${particle.size * 0.15}px ${particle.color})`,
|
143
|
+
transition: 'width 0.1s ease-out, height 0.1s ease-out',
|
138
144
|
} },
|
139
145
|
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" })));
|
140
146
|
};
|
@@ -370,14 +376,21 @@ const createCoinParticles = (origin, config) => {
|
|
370
376
|
return particles;
|
371
377
|
};
|
372
378
|
const renderCoinParticle = (particle) => {
|
373
|
-
|
379
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
380
|
+
const spinSpeed = ((_b = (_a = particle.config) === null || _a === void 0 ? void 0 : _a.effects) === null || _b === void 0 ? void 0 : _b.spin3D) ? 8 : 2; // Faster spin with 3D effect
|
374
381
|
const currentRotation = particle.rotation + (120 - particle.life) * spinSpeed;
|
382
|
+
// 3D effect: scale X based on rotation to simulate perspective
|
383
|
+
const scaleX = ((_d = (_c = particle.config) === null || _c === void 0 ? void 0 : _c.effects) === null || _d === void 0 ? void 0 : _d.spin3D)
|
384
|
+
? Math.abs(Math.cos((currentRotation * Math.PI) / 180))
|
385
|
+
: 1;
|
375
386
|
return (React.createElement("div", { key: particle.id, style: {
|
376
387
|
width: `${particle.size}px`,
|
377
388
|
height: `${particle.size}px`,
|
378
389
|
background: `radial-gradient(ellipse at 30% 30%, ${particle.color}, #B8860B)`,
|
379
390
|
borderRadius: '50%',
|
380
|
-
transform:
|
391
|
+
transform: ((_f = (_e = particle.config) === null || _e === void 0 ? void 0 : _e.effects) === null || _f === void 0 ? void 0 : _f.spin3D)
|
392
|
+
? `rotateY(${currentRotation}deg) scaleX(${scaleX})`
|
393
|
+
: `rotate(${currentRotation}deg)`,
|
381
394
|
transformStyle: 'preserve-3d',
|
382
395
|
boxShadow: `
|
383
396
|
inset -2px -2px 4px rgba(0, 0, 0, 0.3),
|
@@ -387,6 +400,7 @@ const renderCoinParticle = (particle) => {
|
|
387
400
|
border: `1px solid ${particle.color}`,
|
388
401
|
position: 'relative',
|
389
402
|
overflow: 'hidden',
|
403
|
+
backfaceVisibility: 'hidden',
|
390
404
|
} },
|
391
405
|
React.createElement("div", { style: {
|
392
406
|
position: 'absolute',
|
@@ -398,6 +412,8 @@ const renderCoinParticle = (particle) => {
|
|
398
412
|
color: '#B8860B',
|
399
413
|
textShadow: '1px 1px 1px rgba(0, 0, 0, 0.3)',
|
400
414
|
fontFamily: 'Arial, sans-serif',
|
415
|
+
opacity: ((_h = (_g = particle.config) === null || _g === void 0 ? void 0 : _g.effects) === null || _h === void 0 ? void 0 : _h.spin3D) && scaleX < 0.3 ? 0 : 1,
|
416
|
+
transition: 'opacity 0.1s',
|
401
417
|
} }, "$")));
|
402
418
|
};
|
403
419
|
|
@@ -1333,7 +1349,8 @@ const useReward = (elementId, animationType, config) => {
|
|
1333
1349
|
? optimizeConfigForMobile(config)
|
1334
1350
|
: undefined;
|
1335
1351
|
// Create particles
|
1336
|
-
particlesRef.current = animationHandler.createParticles(origin, optimizedConfig || {})
|
1352
|
+
particlesRef.current = animationHandler.createParticles(origin, optimizedConfig || {}).map(particle => (Object.assign(Object.assign({}, particle), { config: optimizedConfig || config // Store config in particle for render functions
|
1353
|
+
})));
|
1337
1354
|
// Create container
|
1338
1355
|
const container = document.createElement('div');
|
1339
1356
|
container.style.position = 'fixed';
|
@@ -1378,6 +1395,22 @@ const useReward = (elementId, animationType, config) => {
|
|
1378
1395
|
particle.vy *= friction;
|
1379
1396
|
particle.rotation += particle.vx * 2;
|
1380
1397
|
particle.life -= 1.2;
|
1398
|
+
// Apply optional effects
|
1399
|
+
const effects = config === null || config === void 0 ? void 0 : config.effects;
|
1400
|
+
// Flutter effect for confetti
|
1401
|
+
if ((effects === null || effects === void 0 ? void 0 : effects.flutter) && animationType === 'confetti') {
|
1402
|
+
particle.x += Math.sin(particle.life * 0.1) * 0.5;
|
1403
|
+
particle.rotation += Math.sin(particle.life * 0.05) * 2;
|
1404
|
+
}
|
1405
|
+
// Wind drift for snow/leaves
|
1406
|
+
if ((effects === null || effects === void 0 ? void 0 : effects.windDrift) && (animationType === 'snow' || animationType === 'leaves')) {
|
1407
|
+
particle.x += Math.sin(particle.life * 0.05 + particle.id.charCodeAt(0)) * 0.8;
|
1408
|
+
}
|
1409
|
+
// Wobble effect for bubbles
|
1410
|
+
if ((effects === null || effects === void 0 ? void 0 : effects.wobble) && animationType === 'bubbles') {
|
1411
|
+
particle.x += Math.sin(particle.life * 0.08) * 0.3;
|
1412
|
+
particle.y += Math.cos(particle.life * 0.08) * 0.2;
|
1413
|
+
}
|
1381
1414
|
// Special opacity handling for sparkles
|
1382
1415
|
if (animationType === 'sparkles') {
|
1383
1416
|
if (particle.life > 70) {
|
@@ -1386,6 +1419,14 @@ const useReward = (elementId, animationType, config) => {
|
|
1386
1419
|
else if (particle.life < 30) {
|
1387
1420
|
particle.opacity = particle.life / 30;
|
1388
1421
|
}
|
1422
|
+
// Twinkle effect
|
1423
|
+
if (effects === null || effects === void 0 ? void 0 : effects.twinkle) {
|
1424
|
+
particle.opacity *= 0.5 + Math.sin(particle.life * 0.3) * 0.5;
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
else if (animationType === 'stars' && (effects === null || effects === void 0 ? void 0 : effects.twinkle)) {
|
1428
|
+
// Twinkle effect for stars
|
1429
|
+
particle.opacity = (particle.life / 100) * (0.5 + Math.sin(particle.life * 0.3) * 0.5);
|
1389
1430
|
}
|
1390
1431
|
else {
|
1391
1432
|
particle.opacity = particle.life / 100;
|