partycles 0.4.0 → 1.1.0
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 +27 -1
- package/dist/animations/animations/index.d.ts.map +1 -1
- package/dist/animations/index.d.ts +1 -0
- package/dist/animations/index.d.ts.map +1 -1
- package/dist/animations/mobileOptimizations.d.ts +6 -0
- package/dist/animations/mobileOptimizations.d.ts.map +1 -0
- package/dist/animations/types.d.ts +1 -1
- package/dist/animations/types.d.ts.map +1 -1
- package/dist/animations/useReward.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +103 -1237
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +103 -1235
- package/dist/index.js.map +1 -1
- package/dist/mobileOptimizations.d.ts +6 -0
- package/dist/mobileOptimizations.d.ts.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useReward.d.ts.map +1 -1
- package/package.json +14 -3
package/README.md
CHANGED
@@ -359,7 +359,7 @@ function Achievement({ unlocked, name }) {
|
|
359
359
|
1. **Unique IDs**: Ensure each animated element has a unique ID
|
360
360
|
2. **Performance**: Avoid triggering multiple animations simultaneously
|
361
361
|
3. **Accessibility**: Provide alternative feedback for users who prefer reduced motion
|
362
|
-
4. **Mobile**:
|
362
|
+
4. **Mobile**: Partycles automatically optimizes for mobile devices
|
363
363
|
|
364
364
|
```tsx
|
365
365
|
// Respect user preferences
|
@@ -370,6 +370,32 @@ const { reward } = useReward('buttonId', 'confetti', {
|
|
370
370
|
});
|
371
371
|
```
|
372
372
|
|
373
|
+
## 📱 Mobile Optimization
|
374
|
+
|
375
|
+
Partycles automatically detects mobile devices and optimizes performance:
|
376
|
+
|
377
|
+
- **Reduced particle counts** (60% of desktop)
|
378
|
+
- **Smaller particle sizes** (80% of desktop)
|
379
|
+
- **Shorter lifetimes** (80% of desktop)
|
380
|
+
- **Frame skipping** for smoother performance
|
381
|
+
- **Tab visibility detection** to pause when inactive
|
382
|
+
|
383
|
+
You can also manually check for mobile devices:
|
384
|
+
|
385
|
+
```tsx
|
386
|
+
import { isMobileDevice, optimizeConfigForMobile } from 'partycles';
|
387
|
+
|
388
|
+
if (isMobileDevice()) {
|
389
|
+
// Custom mobile logic
|
390
|
+
}
|
391
|
+
|
392
|
+
// Or manually optimize a config
|
393
|
+
const mobileConfig = optimizeConfigForMobile({
|
394
|
+
particleCount: 100,
|
395
|
+
elementSize: 30
|
396
|
+
});
|
397
|
+
```
|
398
|
+
|
373
399
|
## 🔧 Advanced Usage
|
374
400
|
|
375
401
|
### Custom Physics
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/animations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/animations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmCpE,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,eAAe,KAAK,QAAQ,EAAE,CAAC;AACxG,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,KAAK,CAAC,SAAS,CAAC;AAEvE,UAAU,gBAAgB;IACxB,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,gBAAgB,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CA6E9D,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { useReward } from './useReward';
|
2
2
|
export type { AnimationType, AnimationConfig, UseRewardConfig } from './types';
|
3
3
|
export { emojiPresets } from './animations/emoji';
|
4
|
+
export { isMobileDevice, optimizeConfigForMobile } from './mobileOptimizations';
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { AnimationConfig } from './types';
|
2
|
+
export declare const isMobileDevice: () => boolean;
|
3
|
+
export declare const optimizeConfigForMobile: (config: AnimationConfig) => AnimationConfig;
|
4
|
+
export declare const shouldSkipFrame: (frameCount: number) => boolean;
|
5
|
+
export declare const simplifyVisualEffects: (animationType: string) => boolean;
|
6
|
+
//# sourceMappingURL=mobileOptimizations.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mobileOptimizations.d.ts","sourceRoot":"","sources":["../src/mobileOptimizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,cAAc,QAAO,OAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,eAAe,KAAG,eAoBjE,CAAC;AAGF,eAAO,MAAM,eAAe,GAAI,YAAY,MAAM,KAAG,OAIpD,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,KAAG,OAK7D,CAAC"}
|
@@ -26,7 +26,7 @@ export interface AnimationConfig {
|
|
26
26
|
friction?: number;
|
27
27
|
};
|
28
28
|
}
|
29
|
-
export type AnimationType = 'confetti' | 'sparkles' | 'fireworks' | 'hearts' | 'stars' | 'bubbles' | 'snow' | 'emoji' | 'coins' | '
|
29
|
+
export type AnimationType = 'confetti' | 'sparkles' | 'fireworks' | 'hearts' | 'stars' | 'bubbles' | 'snow' | 'emoji' | 'coins' | 'petals' | 'aurora' | 'fireflies' | 'paint' | 'balloons' | 'galaxy' | 'leaves' | 'glitch' | 'magicdust' | 'crystals';
|
30
30
|
export interface UseRewardConfig extends AnimationConfig {
|
31
31
|
animationType: AnimationType;
|
32
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,M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AAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,UAAU,GACV,WAAW,GACX,QAAQ,GACR,OAAO,GACP,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,aAAa,EAAE,aAAa,CAAC;CAC9B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useReward.d.ts","sourceRoot":"","sources":["../src/useReward.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAY,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"useReward.d.ts","sourceRoot":"","sources":["../src/useReward.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAY,MAAM,SAAS,CAAC;AAKnE,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,GACpB,WAAW,MAAM,EACjB,eAAe,aAAa,EAC5B,SAAS,eAAe,KACvB,eAuKF,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export { useReward } from './useReward';
|
2
2
|
export type { AnimationType, AnimationConfig, UseRewardConfig } from './types';
|
3
3
|
export { emojiPresets } from './animations/emoji';
|
4
|
+
export { isMobileDevice, optimizeConfigForMobile } from './mobileOptimizations';
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|