@wix/interact 2.0.3 → 2.0.4
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/dist/cjs/index.js +1 -1
- package/dist/cjs/react.js +1 -1
- package/dist/cjs/web.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/react.js +2 -2
- package/dist/es/web.js +2 -2
- package/dist/index-BZL18ynN.mjs +2750 -0
- package/dist/index-BZL18ynN.mjs.map +1 -0
- package/dist/index-IaOsZpFD.js +18 -0
- package/dist/index-IaOsZpFD.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/core/Interact.d.ts +9 -1
- package/dist/types/core/Interact.d.ts.map +1 -1
- package/dist/types/core/add.d.ts.map +1 -1
- package/dist/types/handlers/animationEnd.d.ts +1 -1
- package/dist/types/handlers/animationEnd.d.ts.map +1 -1
- package/dist/types/handlers/effectHandlers.d.ts +2 -1
- package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
- package/dist/types/handlers/eventTrigger.d.ts +1 -1
- package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
- package/dist/types/handlers/viewEnter.d.ts +1 -1
- package/dist/types/handlers/viewEnter.d.ts.map +1 -1
- package/dist/types/types.d.ts +29 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/rules/MASTER-CLEANUP-PLAN.md +286 -0
- package/rules/click.md +12 -31
- package/rules/full-lean.md +26 -4
- package/rules/hover.md +68 -153
- package/rules/integration.md +17 -85
- package/rules/pointermove.md +32 -57
- package/rules/scroll-list.md +82 -280
- package/rules/viewenter.md +65 -90
- package/rules/viewprogress.md +139 -845
- package/dist/index-BfcN_rkn.mjs +0 -2338
- package/dist/index-BfcN_rkn.mjs.map +0 -1
- package/dist/index-HXLBEIjG.js +0 -18
- package/dist/index-HXLBEIjG.js.map +0 -1
package/rules/viewenter.md
CHANGED
|
@@ -499,21 +499,27 @@ Same as Rule 2
|
|
|
499
499
|
|
|
500
500
|
```typescript
|
|
501
501
|
{
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
type: 'once',
|
|
506
|
-
threshold: 0.3, // Good for mobile
|
|
507
|
-
inset: '-100px' // Extra space for desktop
|
|
502
|
+
conditions: {
|
|
503
|
+
// Condition IDs are user-defined strings matched against these media predicates
|
|
504
|
+
'desktop-only': { type: 'media', predicate: '(min-width: 768px)' },
|
|
508
505
|
},
|
|
509
|
-
|
|
510
|
-
effects: [
|
|
506
|
+
interactions: [
|
|
511
507
|
{
|
|
512
508
|
key: 'responsive-element',
|
|
513
|
-
|
|
514
|
-
|
|
509
|
+
trigger: 'viewEnter',
|
|
510
|
+
params: {
|
|
511
|
+
type: 'once',
|
|
512
|
+
threshold: 0.3,
|
|
513
|
+
inset: '-100px'
|
|
515
514
|
},
|
|
516
|
-
|
|
515
|
+
conditions: ['desktop-only'],
|
|
516
|
+
effects: [
|
|
517
|
+
{
|
|
518
|
+
key: 'responsive-element',
|
|
519
|
+
namedEffect: { type: 'FadeIn' },
|
|
520
|
+
duration: 800
|
|
521
|
+
}
|
|
522
|
+
]
|
|
517
523
|
}
|
|
518
524
|
]
|
|
519
525
|
}
|
|
@@ -836,43 +842,42 @@ Animating multiple targets from single viewport trigger:
|
|
|
836
842
|
|
|
837
843
|
### Conditional ViewEnter Animations
|
|
838
844
|
|
|
839
|
-
|
|
845
|
+
Use the `conditions` config map to guard interactions by device or motion preference. Condition IDs are user-defined strings — they must be declared in the top-level `conditions` map before being referenced in an interaction.
|
|
840
846
|
|
|
841
847
|
```typescript
|
|
842
848
|
{
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
type: '
|
|
847
|
-
threshold: 0.5
|
|
849
|
+
conditions: {
|
|
850
|
+
'desktop-only': { type: 'media', predicate: '(min-width: 768px)' },
|
|
851
|
+
'prefers-motion': { type: 'media', predicate: '(prefers-reduced-motion: no-preference)' },
|
|
852
|
+
'mobile-only': { type: 'media', predicate: '(max-width: 767px)' },
|
|
848
853
|
},
|
|
849
|
-
|
|
850
|
-
effects: [
|
|
854
|
+
interactions: [
|
|
851
855
|
{
|
|
852
856
|
key: 'responsive-section',
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
},
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
type: 'once',
|
|
866
|
-
threshold: 0.7
|
|
867
|
-
},
|
|
868
|
-
conditions: ['mobile-only'],
|
|
869
|
-
effects: [
|
|
857
|
+
trigger: 'viewEnter',
|
|
858
|
+
params: { type: 'once', threshold: 0.5 },
|
|
859
|
+
conditions: ['desktop-only', 'prefers-motion'],
|
|
860
|
+
effects: [
|
|
861
|
+
{
|
|
862
|
+
key: 'responsive-section',
|
|
863
|
+
namedEffect: { type: 'SlideIn' },
|
|
864
|
+
duration: 1000
|
|
865
|
+
}
|
|
866
|
+
]
|
|
867
|
+
},
|
|
868
|
+
// Simplified fallback for mobile or reduced-motion users
|
|
870
869
|
{
|
|
871
870
|
key: 'responsive-section',
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
871
|
+
trigger: 'viewEnter',
|
|
872
|
+
params: { type: 'once', threshold: 0.7 },
|
|
873
|
+
conditions: ['mobile-only'],
|
|
874
|
+
effects: [
|
|
875
|
+
{
|
|
876
|
+
key: 'responsive-section',
|
|
877
|
+
namedEffect: { type: 'FadeIn' },
|
|
878
|
+
duration: 400
|
|
879
|
+
}
|
|
880
|
+
]
|
|
876
881
|
}
|
|
877
882
|
]
|
|
878
883
|
}
|
|
@@ -882,11 +887,14 @@ Combining with conditions for responsive behavior:
|
|
|
882
887
|
|
|
883
888
|
## Preventing Flash of Unstyled Content (FOUC)
|
|
884
889
|
|
|
885
|
-
|
|
890
|
+
Use `generate(config)` from `@wix/interact/web` server-side or at build time to produce critical CSS that hides entrance elements until their animation plays.
|
|
886
891
|
|
|
887
|
-
|
|
892
|
+
**Constraints:**
|
|
888
893
|
|
|
889
|
-
|
|
894
|
+
- MUST be called server-side or at build time — not client-side
|
|
895
|
+
- MUST set `data-interact-initial="true"` on the `<interact-element>` whose first child should be hidden
|
|
896
|
+
- Only valid for `viewEnter` + `params.type: 'once'` where source and target are the same element
|
|
897
|
+
- Do NOT use for `hover`, `click`, or `viewEnter` with `repeat`/`alternate`/`state` types
|
|
890
898
|
|
|
891
899
|
```typescript
|
|
892
900
|
import { generate } from '@wix/interact/web';
|
|
@@ -894,56 +902,35 @@ import { generate } from '@wix/interact/web';
|
|
|
894
902
|
const config: InteractConfig = {
|
|
895
903
|
interactions: [
|
|
896
904
|
{
|
|
897
|
-
key: 'hero
|
|
905
|
+
key: 'hero',
|
|
898
906
|
trigger: 'viewEnter',
|
|
899
|
-
params: { type: 'once', threshold: 0.
|
|
900
|
-
effects: [
|
|
901
|
-
{
|
|
902
|
-
namedEffect: { type: 'FadeIn' },
|
|
903
|
-
duration: 800,
|
|
904
|
-
fill: 'backwards',
|
|
905
|
-
},
|
|
906
|
-
],
|
|
907
|
+
params: { type: 'once', threshold: 0.2 },
|
|
908
|
+
effects: [{ namedEffect: { type: 'FadeIn' }, duration: 800 }],
|
|
907
909
|
},
|
|
908
910
|
],
|
|
909
911
|
};
|
|
910
912
|
|
|
911
|
-
//
|
|
913
|
+
// Called at build time or on the server
|
|
912
914
|
const css = generate(config);
|
|
913
915
|
|
|
914
|
-
//
|
|
916
|
+
// Inject into <head> before the page renders
|
|
915
917
|
const html = `
|
|
916
|
-
<!DOCTYPE html>
|
|
917
|
-
<html>
|
|
918
918
|
<head>
|
|
919
|
-
|
|
919
|
+
<style>${css}</style>
|
|
920
920
|
</head>
|
|
921
921
|
<body>
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
<p>This content fades in smoothly without flash</p>
|
|
926
|
-
</section>
|
|
927
|
-
</interact-element>
|
|
928
|
-
<script type="module" src="./main.js"></script>
|
|
922
|
+
<interact-element data-interact-key="hero" data-interact-initial="true">
|
|
923
|
+
<section class="hero">...</section>
|
|
924
|
+
</interact-element>
|
|
929
925
|
</body>
|
|
930
|
-
</html>
|
|
931
926
|
`;
|
|
932
927
|
```
|
|
933
928
|
|
|
934
|
-
### Generated CSS Behavior
|
|
935
|
-
|
|
936
|
-
The `generate` function produces CSS that:
|
|
937
|
-
|
|
938
|
-
1. **Hides marked elements** until their entrance animation completes
|
|
939
|
-
2. **Resets transforms** to allow `IntersectionObserver` to trigger entrance using the element's original layout and position
|
|
940
|
-
3. **Respects reduced motion preferences** - users with `prefers-reduced-motion: reduce` see elements immediately
|
|
941
|
-
|
|
942
929
|
---
|
|
943
930
|
|
|
944
931
|
## Best Practices for ViewEnter Interactions
|
|
945
932
|
|
|
946
|
-
### Behavior
|
|
933
|
+
### Behavior Guidelines
|
|
947
934
|
|
|
948
935
|
1. **Use `alternate` and `repeat` types only with a separate source `key` and target `key`** to avoid re-triggering when animation starts or not triggering at all if animated target is out of viewport or clipped
|
|
949
936
|
|
|
@@ -953,23 +940,15 @@ The `generate` function produces CSS that:
|
|
|
953
940
|
2. **Be careful with separate source/target patterns** - ensure source doesn't get clipped
|
|
954
941
|
3. **Use appropriate thresholds** - avoid triggering too early or too late
|
|
955
942
|
|
|
956
|
-
###
|
|
943
|
+
### Threshold and Timing Guidelines
|
|
957
944
|
|
|
958
945
|
1. **Use realistic thresholds** (0.1-0.5) for natural timing
|
|
959
|
-
2. **Use tiny thresholds for huge elements** 0.01-0.05 for elements much larger than viewport
|
|
946
|
+
2. **Use tiny thresholds for huge elements** (0.01-0.05) for elements much larger than viewport
|
|
960
947
|
3. **Provide adequate inset margins** for mobile viewports
|
|
961
948
|
4. **Keep entrance animations moderate** (500-1200ms)
|
|
962
949
|
5. **Use staggered delays thoughtfully** (50-200ms intervals)
|
|
963
|
-
6. **Ensure content is readable** during animations
|
|
964
950
|
|
|
965
|
-
###
|
|
966
|
-
|
|
967
|
-
1. **Respect `prefers-reduced-motion`** for all entrance animations
|
|
968
|
-
2. **Don't rely solely on animations** to convey important information
|
|
969
|
-
3. **Ensure sufficient contrast** during fade-in effects
|
|
970
|
-
4. **Provide alternative content loading** for users who disable animations
|
|
971
|
-
|
|
972
|
-
### Threshold and Timing Guidelines
|
|
951
|
+
### Threshold and Timing Reference
|
|
973
952
|
|
|
974
953
|
**Recommended Thresholds by Content Type**:
|
|
975
954
|
|
|
@@ -977,7 +956,7 @@ The `generate` function produces CSS that:
|
|
|
977
956
|
- **Content blocks**: 0.3-0.5 (balanced trigger)
|
|
978
957
|
- **Small elements**: 0.5-0.8 (late trigger)
|
|
979
958
|
- **Tall sections**: 0.1-0.2 (early trigger)
|
|
980
|
-
- **
|
|
959
|
+
- **Huge sections**: 0.01-0.05 (ensure trigger)
|
|
981
960
|
|
|
982
961
|
**Recommended Insets by Device**:
|
|
983
962
|
|
|
@@ -1048,7 +1027,3 @@ The `generate` function produces CSS that:
|
|
|
1048
1027
|
- Use hardware-accelerated properties
|
|
1049
1028
|
- Avoid animating layout properties
|
|
1050
1029
|
- Consider using `will-change` for complex animations
|
|
1051
|
-
|
|
1052
|
-
---
|
|
1053
|
-
|
|
1054
|
-
These rules provide comprehensive coverage for ViewEnter trigger interactions in `@wix/interact`, supporting all four behavior types and various intersection observer configurations as outlined in the development plan.
|