@readdy/anim 0.0.21
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/animations/button/3d-flip/index.js +60 -0
- package/animations/button/3d-flip/react.tsx +29 -0
- package/animations/button/3d-flip/style.css +17 -0
- package/animations/button/blur-fade-in/index.js +21 -0
- package/animations/button/blur-fade-in/react.tsx +26 -0
- package/animations/button/blur-fade-in/style.css +27 -0
- package/animations/button/border-beam/index.js +172 -0
- package/animations/button/border-beam/react.tsx +55 -0
- package/animations/button/border-beam/style.css +59 -0
- package/animations/button/bounce-elastic/index.js +21 -0
- package/animations/button/bounce-elastic/react.tsx +26 -0
- package/animations/button/bounce-elastic/style.css +31 -0
- package/animations/button/bubble-button/index.js +317 -0
- package/animations/button/bubble-button/react.tsx +19 -0
- package/animations/button/bubble-button/style.css +245 -0
- package/animations/button/confetti-button/index.js +66 -0
- package/animations/button/confetti-button/react.tsx +30 -0
- package/animations/button/confetti-button/style.css +48 -0
- package/animations/button/glow-cta/index.js +69 -0
- package/animations/button/glow-cta/react.tsx +45 -0
- package/animations/button/glow-cta/style.css +78 -0
- package/animations/button/magnetic-hover/index.js +61 -0
- package/animations/button/magnetic-hover/react.tsx +29 -0
- package/animations/button/magnetic-hover/style.css +18 -0
- package/animations/button/pulse/index.js +21 -0
- package/animations/button/pulse/react.tsx +26 -0
- package/animations/button/pulse/style.css +24 -0
- package/animations/button/rainbow-button/index.js +21 -0
- package/animations/button/rainbow-button/react.tsx +26 -0
- package/animations/button/rainbow-button/style.css +54 -0
- package/animations/button/shimmer-border/index.js +28 -0
- package/animations/button/shimmer-border/react.tsx +41 -0
- package/animations/button/shimmer-border/style.css +53 -0
- package/animations/button/sketch-button/index.js +16 -0
- package/animations/button/sketch-button/react.tsx +19 -0
- package/animations/button/sketch-button/style.css +25 -0
- package/animations/card/blur-rise/index.js +21 -0
- package/animations/card/blur-rise/react.tsx +26 -0
- package/animations/card/blur-rise/style.css +27 -0
- package/animations/card/bounce-in-bottom/index.js +21 -0
- package/animations/card/bounce-in-bottom/react.tsx +26 -0
- package/animations/card/bounce-in-bottom/style.css +31 -0
- package/animations/card/card-fan-spread/index.js +146 -0
- package/animations/card/card-fan-spread/react.tsx +35 -0
- package/animations/card/card-fan-spread/style.css +90 -0
- package/animations/card/card-flip/index.js +203 -0
- package/animations/card/card-flip/react.tsx +35 -0
- package/animations/card/card-flip/style.css +71 -0
- package/animations/card/float-idle/index.js +21 -0
- package/animations/card/float-idle/react.tsx +26 -0
- package/animations/card/float-idle/style.css +21 -0
- package/animations/card/image-magnifier/index.js +333 -0
- package/animations/card/image-magnifier/react.tsx +31 -0
- package/animations/card/image-magnifier/style.css +42 -0
- package/animations/card/image-zoom-rotate/index.js +48 -0
- package/animations/card/image-zoom-rotate/react.tsx +31 -0
- package/animations/card/image-zoom-rotate/style.css +20 -0
- package/animations/card/pop-in-stack/index.js +25 -0
- package/animations/card/pop-in-stack/react.tsx +33 -0
- package/animations/card/pop-in-stack/style.css +25 -0
- package/animations/card/reveal-from-top/index.js +21 -0
- package/animations/card/reveal-from-top/react.tsx +26 -0
- package/animations/card/reveal-from-top/style.css +28 -0
- package/animations/card/rgb-split-glitch/index.js +28 -0
- package/animations/card/rgb-split-glitch/react.tsx +41 -0
- package/animations/card/rgb-split-glitch/style.css +33 -0
- package/animations/card/tilted-card/index.js +64 -0
- package/animations/card/tilted-card/react.tsx +33 -0
- package/animations/card/tilted-card/style.css +27 -0
- package/animations/header/anime-splittext/index.js +108 -0
- package/animations/header/anime-splittext/react.tsx +30 -0
- package/animations/header/anime-splittext/style.css +71 -0
- package/animations/header/bounce-in-down/index.js +40 -0
- package/animations/header/bounce-in-down/react.tsx +29 -0
- package/animations/header/bounce-in-down/style.css +40 -0
- package/animations/header/fly-in-chars/index.js +46 -0
- package/animations/header/fly-in-chars/react.tsx +30 -0
- package/animations/header/fly-in-chars/style.css +29 -0
- package/animations/header/gradient-text/index.js +21 -0
- package/animations/header/gradient-text/react.tsx +26 -0
- package/animations/header/gradient-text/style.css +28 -0
- package/animations/header/letter-bounce/index.js +33 -0
- package/animations/header/letter-bounce/react.tsx +34 -0
- package/animations/header/letter-bounce/style.css +25 -0
- package/animations/header/roll-in/index.js +40 -0
- package/animations/header/roll-in/react.tsx +29 -0
- package/animations/header/roll-in/style.css +31 -0
- package/animations/header/shimmer-text/index.js +16 -0
- package/animations/header/shimmer-text/react.tsx +28 -0
- package/animations/header/shimmer-text/style.css +29 -0
- package/animations/header/shuffle/index.js +118 -0
- package/animations/header/shuffle/react.tsx +50 -0
- package/animations/header/shuffle/style.css +25 -0
- package/animations/header/split-text/index.js +72 -0
- package/animations/header/split-text/react.tsx +38 -0
- package/animations/header/split-text/style.css +31 -0
- package/animations/header/text-type/index.js +267 -0
- package/animations/header/text-type/react.tsx +63 -0
- package/animations/header/text-type/style.css +37 -0
- package/animations/header/word-curtain-reveal/index.js +97 -0
- package/animations/header/word-curtain-reveal/react.tsx +30 -0
- package/animations/header/word-curtain-reveal/style.css +39 -0
- package/dist/button/3d-flip/react.js +21 -0
- package/dist/button/3d-flip.js +61 -0
- package/dist/button/blur-fade-in/react.js +28 -0
- package/dist/button/blur-fade-in.js +17 -0
- package/dist/button/border-beam/react.js +22 -0
- package/dist/button/border-beam.js +168 -0
- package/dist/button/bounce-elastic/react.js +28 -0
- package/dist/button/bounce-elastic.js +17 -0
- package/dist/button/bubble-button/react.js +20 -0
- package/dist/button/bubble-button.js +318 -0
- package/dist/button/confetti-button/react.js +21 -0
- package/dist/button/confetti-button.js +67 -0
- package/dist/button/glow-cta/react.js +23 -0
- package/dist/button/glow-cta.js +65 -0
- package/dist/button/magnetic-hover/react.js +21 -0
- package/dist/button/magnetic-hover.js +62 -0
- package/dist/button/pulse/react.js +28 -0
- package/dist/button/pulse.js +17 -0
- package/dist/button/rainbow-button/react.js +28 -0
- package/dist/button/rainbow-button.js +17 -0
- package/dist/button/shimmer-border/react.js +22 -0
- package/dist/button/shimmer-border.js +24 -0
- package/dist/button/sketch-button/react.js +20 -0
- package/dist/button/sketch-button.js +17 -0
- package/dist/card/blur-rise/react.js +28 -0
- package/dist/card/blur-rise.js +17 -0
- package/dist/card/bounce-in-bottom/react.js +28 -0
- package/dist/card/bounce-in-bottom.js +17 -0
- package/dist/card/card-fan-spread/react.js +20 -0
- package/dist/card/card-fan-spread.js +147 -0
- package/dist/card/float-idle/react.js +28 -0
- package/dist/card/float-idle.js +17 -0
- package/dist/card/image-magnifier/react.js +22 -0
- package/dist/card/image-magnifier.js +334 -0
- package/dist/card/image-zoom-rotate/react.js +21 -0
- package/dist/card/image-zoom-rotate.js +49 -0
- package/dist/card/pop-in-stack/react.js +20 -0
- package/dist/card/pop-in-stack.js +26 -0
- package/dist/card/reveal-from-top/react.js +28 -0
- package/dist/card/reveal-from-top.js +17 -0
- package/dist/card/rgb-split-glitch/react.js +22 -0
- package/dist/card/rgb-split-glitch.js +24 -0
- package/dist/card/tilted-card/react.js +21 -0
- package/dist/card/tilted-card.js +65 -0
- package/dist/chunks/constants-EnH6-Pz4.js +66 -0
- package/dist/chunks/constants-ZTHic1pf.js +66 -0
- package/dist/chunks/pointer-follow-B3RFnn_q.js +93 -0
- package/dist/chunks/pointer-follow-BETANySn.js +93 -0
- package/dist/chunks/reduced-motion-BpQYuEzK.js +17 -0
- package/dist/chunks/reduced-motion-HX79Ac8G.js +17 -0
- package/dist/chunks/resolve-card-media-Cj3V_oms.js +43 -0
- package/dist/chunks/resolve-card-media-DBIU-duL.js +43 -0
- package/dist/chunks/text-split-D02jltVh.js +191 -0
- package/dist/chunks/text-split-frOR4UpH.js +191 -0
- package/dist/full.css +1 -0
- package/dist/full.js +3192 -0
- package/dist/header/anime-splittext/react.js +22 -0
- package/dist/header/anime-splittext.js +109 -0
- package/dist/header/bounce-in-down/react.js +32 -0
- package/dist/header/bounce-in-down.js +36 -0
- package/dist/header/fly-in-chars/react.js +23 -0
- package/dist/header/fly-in-chars.js +47 -0
- package/dist/header/gradient-text/react.js +28 -0
- package/dist/header/gradient-text.js +17 -0
- package/dist/header/letter-bounce/react.js +23 -0
- package/dist/header/letter-bounce.js +34 -0
- package/dist/header/roll-in/react.js +32 -0
- package/dist/header/roll-in.js +36 -0
- package/dist/header/shimmer-text/react.js +27 -0
- package/dist/header/shimmer-text.js +17 -0
- package/dist/header/shuffle/react.js +30 -0
- package/dist/header/shuffle.js +119 -0
- package/dist/header/split-text/react.js +26 -0
- package/dist/header/split-text.js +73 -0
- package/dist/header/text-type/react.js +43 -0
- package/dist/header/text-type.js +268 -0
- package/dist/header/word-curtain-reveal/react.js +22 -0
- package/dist/header/word-curtain-reveal.js +98 -0
- package/dist/meta.json +6 -0
- package/dist/metadata.json +1051 -0
- package/dist/react.css +1 -0
- package/dist/types/animations/button/3d-flip/index.d.ts +3 -0
- package/dist/types/animations/button/3d-flip/react.d.ts +8 -0
- package/dist/types/animations/button/blur-fade-in/index.d.ts +3 -0
- package/dist/types/animations/button/blur-fade-in/react.d.ts +13 -0
- package/dist/types/animations/button/border-beam/index.d.ts +3 -0
- package/dist/types/animations/button/border-beam/react.d.ts +25 -0
- package/dist/types/animations/button/bounce-elastic/index.d.ts +3 -0
- package/dist/types/animations/button/bounce-elastic/react.d.ts +13 -0
- package/dist/types/animations/button/bubble-button/index.d.ts +3 -0
- package/dist/types/animations/button/bubble-button/react.d.ts +4 -0
- package/dist/types/animations/button/confetti-button/index.d.ts +3 -0
- package/dist/types/animations/button/confetti-button/react.d.ts +8 -0
- package/dist/types/animations/button/glow-cta/index.d.ts +3 -0
- package/dist/types/animations/button/glow-cta/react.d.ts +20 -0
- package/dist/types/animations/button/magnetic-hover/index.d.ts +3 -0
- package/dist/types/animations/button/magnetic-hover/react.d.ts +8 -0
- package/dist/types/animations/button/pulse/index.d.ts +3 -0
- package/dist/types/animations/button/pulse/react.d.ts +13 -0
- package/dist/types/animations/button/rainbow-button/index.d.ts +3 -0
- package/dist/types/animations/button/rainbow-button/react.d.ts +13 -0
- package/dist/types/animations/button/shimmer-border/index.d.ts +3 -0
- package/dist/types/animations/button/shimmer-border/react.d.ts +18 -0
- package/dist/types/animations/button/sketch-button/index.d.ts +3 -0
- package/dist/types/animations/button/sketch-button/react.d.ts +4 -0
- package/dist/types/animations/card/blur-rise/index.d.ts +3 -0
- package/dist/types/animations/card/blur-rise/react.d.ts +13 -0
- package/dist/types/animations/card/bounce-in-bottom/index.d.ts +3 -0
- package/dist/types/animations/card/bounce-in-bottom/react.d.ts +13 -0
- package/dist/types/animations/card/card-fan-spread/index.d.ts +3 -0
- package/dist/types/animations/card/card-fan-spread/react.d.ts +11 -0
- package/dist/types/animations/card/card-flip/index.d.ts +3 -0
- package/dist/types/animations/card/card-flip/react.d.ts +11 -0
- package/dist/types/animations/card/float-idle/index.d.ts +3 -0
- package/dist/types/animations/card/float-idle/react.d.ts +13 -0
- package/dist/types/animations/card/image-magnifier/index.d.ts +3 -0
- package/dist/types/animations/card/image-magnifier/react.d.ts +9 -0
- package/dist/types/animations/card/image-zoom-rotate/index.d.ts +3 -0
- package/dist/types/animations/card/image-zoom-rotate/react.d.ts +9 -0
- package/dist/types/animations/card/pop-in-stack/index.d.ts +3 -0
- package/dist/types/animations/card/pop-in-stack/react.d.ts +10 -0
- package/dist/types/animations/card/reveal-from-top/index.d.ts +3 -0
- package/dist/types/animations/card/reveal-from-top/react.d.ts +13 -0
- package/dist/types/animations/card/rgb-split-glitch/index.d.ts +3 -0
- package/dist/types/animations/card/rgb-split-glitch/react.d.ts +18 -0
- package/dist/types/animations/card/tilted-card/index.d.ts +3 -0
- package/dist/types/animations/card/tilted-card/react.d.ts +10 -0
- package/dist/types/animations/header/anime-splittext/index.d.ts +3 -0
- package/dist/types/animations/header/anime-splittext/react.d.ts +8 -0
- package/dist/types/animations/header/bounce-in-down/index.d.ts +3 -0
- package/dist/types/animations/header/bounce-in-down/react.d.ts +13 -0
- package/dist/types/animations/header/fly-in-chars/index.d.ts +3 -0
- package/dist/types/animations/header/fly-in-chars/react.d.ts +8 -0
- package/dist/types/animations/header/gradient-text/index.d.ts +3 -0
- package/dist/types/animations/header/gradient-text/react.d.ts +13 -0
- package/dist/types/animations/header/letter-bounce/index.d.ts +3 -0
- package/dist/types/animations/header/letter-bounce/react.d.ts +10 -0
- package/dist/types/animations/header/roll-in/index.d.ts +3 -0
- package/dist/types/animations/header/roll-in/react.d.ts +13 -0
- package/dist/types/animations/header/shimmer-text/index.d.ts +3 -0
- package/dist/types/animations/header/shimmer-text/react.d.ts +4 -0
- package/dist/types/animations/header/shuffle/index.d.ts +3 -0
- package/dist/types/animations/header/shuffle/react.d.ts +14 -0
- package/dist/types/animations/header/split-text/index.d.ts +3 -0
- package/dist/types/animations/header/split-text/react.d.ts +10 -0
- package/dist/types/animations/header/text-type/index.d.ts +3 -0
- package/dist/types/animations/header/text-type/react.d.ts +13 -0
- package/dist/types/animations/header/word-curtain-reveal/index.d.ts +3 -0
- package/dist/types/animations/header/word-curtain-reveal/react.d.ts +8 -0
- package/dist/types/react-barrel.d.ts +34 -0
- package/dist/types/scripts/bundle-all.d.ts +173 -0
- package/dist/types/scripts/check-metadata.d.ts +1 -0
- package/dist/types/scripts/copy-metadata.d.ts +1 -0
- package/dist/types/scripts/generate-animation-id-map.d.ts +1 -0
- package/dist/types/scripts/generate-dist-meta.d.ts +1 -0
- package/dist/types/scripts/generate-preview-manifest.d.ts +1 -0
- package/dist/types/scripts/update-metadata.d.ts +1 -0
- package/dist/types/shared/constants.d.ts +34 -0
- package/dist/types/shared/meta.d.ts +18 -0
- package/dist/types/shared/pointer-follow.d.ts +8 -0
- package/dist/types/shared/reduced-motion.d.ts +11 -0
- package/dist/types/shared/resolve-card-media.d.ts +1 -0
- package/dist/types/shared/text-split.d.ts +19 -0
- package/dist/types/stories/3d-flip.stories.d.ts +7 -0
- package/dist/types/stories/_helpers.d.ts +24 -0
- package/dist/types/stories/anime-splittext.stories.d.ts +8 -0
- package/dist/types/stories/blur-fade-in.stories.d.ts +8 -0
- package/dist/types/stories/blur-rise.stories.d.ts +8 -0
- package/dist/types/stories/blur-to-sharp-rise-header.stories.d.ts +8 -0
- package/dist/types/stories/border-beam.stories.d.ts +8 -0
- package/dist/types/stories/bounce-elastic.stories.d.ts +8 -0
- package/dist/types/stories/bounce-in-bottom.stories.d.ts +8 -0
- package/dist/types/stories/bounce-in-down.stories.d.ts +9 -0
- package/dist/types/stories/bubble-button.stories.d.ts +8 -0
- package/dist/types/stories/card-fan-spread.stories.d.ts +7 -0
- package/dist/types/stories/card-flip.stories.d.ts +7 -0
- package/dist/types/stories/confetti-button.stories.d.ts +7 -0
- package/dist/types/stories/float-idle.stories.d.ts +8 -0
- package/dist/types/stories/fly-in-chars.stories.d.ts +8 -0
- package/dist/types/stories/glow-cta.stories.d.ts +9 -0
- package/dist/types/stories/gradient-text.stories.d.ts +9 -0
- package/dist/types/stories/image-magnifier.stories.d.ts +10 -0
- package/dist/types/stories/image-zoom-rotate.stories.d.ts +7 -0
- package/dist/types/stories/letter-bounce.stories.d.ts +8 -0
- package/dist/types/stories/magic-ui-border-beam-card.stories.d.ts +8 -0
- package/dist/types/stories/magnetic-hover.stories.d.ts +7 -0
- package/dist/types/stories/pop-in-stack.stories.d.ts +7 -0
- package/dist/types/stories/pulse.stories.d.ts +8 -0
- package/dist/types/stories/rainbow-button.stories.d.ts +8 -0
- package/dist/types/stories/reveal-from-top.stories.d.ts +8 -0
- package/dist/types/stories/rgb-split-glitch.stories.d.ts +8 -0
- package/dist/types/stories/roll-in.stories.d.ts +9 -0
- package/dist/types/stories/shimmer-border.stories.d.ts +9 -0
- package/dist/types/stories/shimmer-text.stories.d.ts +8 -0
- package/dist/types/stories/shuffle.stories.d.ts +8 -0
- package/dist/types/stories/sketch-button.stories.d.ts +7 -0
- package/dist/types/stories/split-text.stories.d.ts +8 -0
- package/dist/types/stories/text-type.stories.d.ts +8 -0
- package/dist/types/stories/tilted-card.stories.d.ts +7 -0
- package/dist/types/stories/word-curtain-reveal.stories.d.ts +8 -0
- package/package.json +166 -0
- package/react-barrel.js +44 -0
- package/shared/constants.js +64 -0
- package/shared/meta.js +21 -0
- package/shared/pointer-follow.js +91 -0
- package/shared/reduced-motion.js +15 -0
- package/shared/resolve-card-media.js +41 -0
- package/shared/text-split.js +188 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { p as prefersReducedMotion } from '../chunks/reduced-motion-HX79Ac8G.js';
|
|
2
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
3
|
+
|
|
4
|
+
const ANIMATION_ID = buildAnimId('card-fan-spread');
|
|
5
|
+
|
|
6
|
+
const CSS_CLASS = buildAnimClass('card-fan-spread');
|
|
7
|
+
const STACK_CLASS = buildAnimClass('card-fan-stack');
|
|
8
|
+
const ITEM_CLASS = buildAnimClass('card-fan-item');
|
|
9
|
+
const SURFACE_CLASS = buildAnimClass('card-fan-surface');
|
|
10
|
+
const VISUAL_CLASS = buildAnimClass('card-fan-visual');
|
|
11
|
+
const VISUAL_TEXT_CLASS = buildAnimClass('card-fan-visual-text');
|
|
12
|
+
const stateMap = new WeakMap();
|
|
13
|
+
|
|
14
|
+
function buildCardVisual(el) {
|
|
15
|
+
const visual = el.cloneNode(true);
|
|
16
|
+
visual.classList.add(VISUAL_CLASS);
|
|
17
|
+
visual.removeAttribute('id');
|
|
18
|
+
visual.removeAttribute('tabindex');
|
|
19
|
+
visual.removeAttribute('aria-labelledby');
|
|
20
|
+
visual.removeAttribute('aria-describedby');
|
|
21
|
+
visual.removeAttribute('aria-controls');
|
|
22
|
+
visual.querySelectorAll('[id]').forEach((node) => node.removeAttribute('id'));
|
|
23
|
+
visual.querySelectorAll('button, a, input, textarea, select, [tabindex]').forEach((node) => {
|
|
24
|
+
node.setAttribute('aria-hidden', 'true');
|
|
25
|
+
node.setAttribute('tabindex', '-1');
|
|
26
|
+
node.style.pointerEvents = 'none';
|
|
27
|
+
});
|
|
28
|
+
visual.querySelectorAll('video, audio').forEach((node) => {
|
|
29
|
+
node.pause?.();
|
|
30
|
+
node.removeAttribute('autoplay');
|
|
31
|
+
node.removeAttribute('controls');
|
|
32
|
+
});
|
|
33
|
+
visual.querySelectorAll('*').forEach((node) => {
|
|
34
|
+
if (node.closest(`.${buildAnimClass('card-media')}`)) return
|
|
35
|
+
if (node.children.length === 0 && (node.textContent ?? '').trim()) {
|
|
36
|
+
node.classList.add(VISUAL_TEXT_CLASS);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return visual
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildLayer(visualTemplate, index, radius) {
|
|
43
|
+
const item = document.createElement('div');
|
|
44
|
+
item.className = ITEM_CLASS;
|
|
45
|
+
item.setAttribute('aria-hidden', 'true');
|
|
46
|
+
item.style.setProperty('--readdy-anim-card-fan-index', `${index}`);
|
|
47
|
+
|
|
48
|
+
const surface = document.createElement('div');
|
|
49
|
+
surface.className = SURFACE_CLASS;
|
|
50
|
+
surface.style.borderRadius = radius;
|
|
51
|
+
surface.appendChild(visualTemplate.cloneNode(true));
|
|
52
|
+
item.appendChild(surface);
|
|
53
|
+
return item
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ensureStack(el, visual) {
|
|
57
|
+
const stack = document.createElement('div');
|
|
58
|
+
stack.className = STACK_CLASS;
|
|
59
|
+
stack.setAttribute('aria-hidden', 'true');
|
|
60
|
+
|
|
61
|
+
for (let index = 0; index < 2; index += 1) {
|
|
62
|
+
stack.appendChild(buildLayer(visual.visualTemplate, index, visual.radius));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
el.insertBefore(stack, el.firstChild);
|
|
66
|
+
return stack
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function init(el, options = {}) {
|
|
70
|
+
destroy(el);
|
|
71
|
+
|
|
72
|
+
el.classList.add(CSS_CLASS);
|
|
73
|
+
const spreadDistance = options.spreadDistance ?? 72;
|
|
74
|
+
const spreadRotate = options.spreadRotate ?? 24;
|
|
75
|
+
const depthRotate = options.depthRotate ?? 18;
|
|
76
|
+
const lift = options.lift ?? 14;
|
|
77
|
+
const duration = options.duration ?? 550;
|
|
78
|
+
|
|
79
|
+
el.style.setProperty('--readdy-anim-card-fan-distance', `${spreadDistance}px`);
|
|
80
|
+
el.style.setProperty('--readdy-anim-card-fan-rotate', `${spreadRotate}deg`);
|
|
81
|
+
el.style.setProperty('--readdy-anim-card-fan-depth-rotate', `${depthRotate}deg`);
|
|
82
|
+
el.style.setProperty('--readdy-anim-card-fan-lift', `${lift}px`);
|
|
83
|
+
el.style.setProperty('--readdy-anim-card-fan-duration', `${duration}ms`);
|
|
84
|
+
|
|
85
|
+
const visual = {
|
|
86
|
+
visualTemplate: buildCardVisual(el),
|
|
87
|
+
radius: window.getComputedStyle(el).borderRadius || 'inherit',
|
|
88
|
+
};
|
|
89
|
+
const stack = ensureStack(el, visual);
|
|
90
|
+
const state = {
|
|
91
|
+
savedTabIndex: el.getAttribute('tabindex'),
|
|
92
|
+
toggle: null,
|
|
93
|
+
onKeyDown: null,
|
|
94
|
+
stack,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
el.tabIndex = el.tabIndex >= 0 ? el.tabIndex : 0;
|
|
98
|
+
|
|
99
|
+
if (prefersReducedMotion()) {
|
|
100
|
+
stateMap.set(el, state);
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
state.toggle = () => {
|
|
105
|
+
el.classList.toggle('is-spread');
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
state.onKeyDown = (event) => {
|
|
109
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
state.toggle();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
el.addEventListener('click', state.toggle);
|
|
116
|
+
el.addEventListener('keydown', state.onKeyDown);
|
|
117
|
+
stateMap.set(el, state);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function destroy(el) {
|
|
121
|
+
const state = stateMap.get(el);
|
|
122
|
+
if (state) {
|
|
123
|
+
if (state.toggle) {
|
|
124
|
+
el.removeEventListener('click', state.toggle);
|
|
125
|
+
}
|
|
126
|
+
if (state.onKeyDown) {
|
|
127
|
+
el.removeEventListener('keydown', state.onKeyDown);
|
|
128
|
+
}
|
|
129
|
+
if (state.savedTabIndex === null) {
|
|
130
|
+
el.removeAttribute('tabindex');
|
|
131
|
+
} else {
|
|
132
|
+
el.setAttribute('tabindex', state.savedTabIndex);
|
|
133
|
+
}
|
|
134
|
+
state.stack?.remove();
|
|
135
|
+
stateMap.delete(el);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
el.classList.remove(CSS_CLASS, 'is-spread');
|
|
139
|
+
el.style.removeProperty('--readdy-anim-card-fan-distance');
|
|
140
|
+
el.style.removeProperty('--readdy-anim-card-fan-rotate');
|
|
141
|
+
el.style.removeProperty('--readdy-anim-card-fan-depth-rotate');
|
|
142
|
+
el.style.removeProperty('--readdy-anim-card-fan-lift');
|
|
143
|
+
el.style.removeProperty('--readdy-anim-card-fan-duration');
|
|
144
|
+
el.querySelector(`.${STACK_CLASS}`)?.remove();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../float-idle.js';
|
|
3
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Float Idle — 卡片悬浮idle
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* <AnimFloatIdle><div className="card">内容</div></AnimFloatIdle>
|
|
10
|
+
*
|
|
11
|
+
* 不加 wrapper div — 通过 cloneElement 给子元素注入 ref,加/删 .readdy-anim-float-idle class
|
|
12
|
+
* 必须恰好包裹一个子元素
|
|
13
|
+
*/
|
|
14
|
+
function AnimFloatIdle({ children }) {
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el)
|
|
19
|
+
return;
|
|
20
|
+
init(el);
|
|
21
|
+
return () => {
|
|
22
|
+
destroy(el);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { AnimFloatIdle };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_ID = buildAnimId('float-idle');
|
|
4
|
+
|
|
5
|
+
const CSS_CLASS = buildAnimClass('float-idle');
|
|
6
|
+
|
|
7
|
+
function init(el, options = {}) {
|
|
8
|
+
if (!el.classList.contains(CSS_CLASS)) {
|
|
9
|
+
el.classList.add(CSS_CLASS);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function destroy(el) {
|
|
14
|
+
el.classList.remove(CSS_CLASS);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../image-magnifier.js';
|
|
3
|
+
import { p as prefersReducedMotion } from '../../chunks/reduced-motion-HX79Ac8G.js';
|
|
4
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
5
|
+
import '../../chunks/pointer-follow-BETANySn.js';
|
|
6
|
+
import '../../chunks/resolve-card-media-Cj3V_oms.js';
|
|
7
|
+
|
|
8
|
+
function AnimImageMagnifier({ children, lensSize, zoom, fadeDuration, }) {
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const el = ref.current;
|
|
12
|
+
if (!el || prefersReducedMotion())
|
|
13
|
+
return;
|
|
14
|
+
init(el, { lensSize, zoom, fadeDuration });
|
|
15
|
+
return () => {
|
|
16
|
+
destroy(el);
|
|
17
|
+
};
|
|
18
|
+
}, [lensSize, zoom, fadeDuration]);
|
|
19
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { AnimImageMagnifier };
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { p as prefersReducedMotion } from '../chunks/reduced-motion-HX79Ac8G.js';
|
|
2
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
3
|
+
import { a as attachPointerFollow } from '../chunks/pointer-follow-BETANySn.js';
|
|
4
|
+
import { r as resolveCardMediaElement } from '../chunks/resolve-card-media-Cj3V_oms.js';
|
|
5
|
+
|
|
6
|
+
const ANIMATION_ID = buildAnimId('image-magnifier');
|
|
7
|
+
|
|
8
|
+
const CSS_CLASS = buildAnimClass('image-magnifier');
|
|
9
|
+
const MEDIA_CLASS = buildAnimClass('card-media');
|
|
10
|
+
const ENHANCED_MEDIA_CLASS = buildAnimClass('image-magnifier-media');
|
|
11
|
+
const LENS_CLASS = buildAnimClass('image-magnifier-lens');
|
|
12
|
+
const stateMap = new WeakMap();
|
|
13
|
+
|
|
14
|
+
function resolveImageUrl(image) {
|
|
15
|
+
try {
|
|
16
|
+
return new URL(image.currentSrc || image.src, document.baseURI).href
|
|
17
|
+
} catch {
|
|
18
|
+
return image.currentSrc || image.src
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parsePositionToken(token, axis) {
|
|
23
|
+
const value = token.trim().toLowerCase();
|
|
24
|
+
if (!value) {
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (value === 'center') {
|
|
29
|
+
return { type: 'factor', value: 0.5 }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (axis === 'x') {
|
|
33
|
+
if (value === 'left') return { type: 'factor', value: 0 }
|
|
34
|
+
if (value === 'right') return { type: 'factor', value: 1 }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (axis === 'y') {
|
|
38
|
+
if (value === 'top') return { type: 'factor', value: 0 }
|
|
39
|
+
if (value === 'bottom') return { type: 'factor', value: 1 }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (value.endsWith('%')) {
|
|
43
|
+
const percentage = Number.parseFloat(value);
|
|
44
|
+
if (Number.isFinite(percentage)) {
|
|
45
|
+
return { type: 'factor', value: percentage / 100 }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (value.endsWith('px')) {
|
|
50
|
+
const pixels = Number.parseFloat(value);
|
|
51
|
+
if (Number.isFinite(pixels)) {
|
|
52
|
+
return { type: 'px', value: pixels }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function resolveObjectPosition(image) {
|
|
60
|
+
const raw = window.getComputedStyle(image).objectPosition || '50% 50%';
|
|
61
|
+
const tokens = raw.split(/\s+/).filter(Boolean);
|
|
62
|
+
|
|
63
|
+
if (tokens.length === 0) {
|
|
64
|
+
return {
|
|
65
|
+
x: { type: 'factor', value: 0.5 },
|
|
66
|
+
y: { type: 'factor', value: 0.5 },
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (tokens.length === 1) {
|
|
71
|
+
const token = tokens[0];
|
|
72
|
+
const x = parsePositionToken(token, 'x');
|
|
73
|
+
const y = parsePositionToken(token, 'y');
|
|
74
|
+
|
|
75
|
+
if (y && !x) {
|
|
76
|
+
return { x: { type: 'factor', value: 0.5 }, y }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
x: x ?? { type: 'factor', value: 0.5 },
|
|
81
|
+
y: { type: 'factor', value: 0.5 },
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let xToken = tokens[0];
|
|
86
|
+
let yToken = tokens[1];
|
|
87
|
+
const firstIsVertical = ['top', 'bottom'].includes(tokens[0].toLowerCase());
|
|
88
|
+
const secondIsHorizontal = ['left', 'right'].includes(tokens[1].toLowerCase());
|
|
89
|
+
|
|
90
|
+
if (firstIsVertical && secondIsHorizontal) {
|
|
91
|
+
xToken = tokens[1];
|
|
92
|
+
yToken = tokens[0];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
x: parsePositionToken(xToken, 'x') ?? { type: 'factor', value: 0.5 },
|
|
97
|
+
y: parsePositionToken(yToken, 'y') ?? { type: 'factor', value: 0.5 },
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function resolveObjectOffset(availableSpace, position) {
|
|
102
|
+
if (position.type === 'px') {
|
|
103
|
+
return position.value
|
|
104
|
+
}
|
|
105
|
+
return availableSpace * position.value
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function ensureLens(el) {
|
|
109
|
+
const media = resolveCardMediaElement(el, MEDIA_CLASS);
|
|
110
|
+
media.classList.add(ENHANCED_MEDIA_CLASS);
|
|
111
|
+
|
|
112
|
+
let lens = media.querySelector(`.${LENS_CLASS}`);
|
|
113
|
+
if (!lens) {
|
|
114
|
+
lens = document.createElement('span');
|
|
115
|
+
lens.className = LENS_CLASS;
|
|
116
|
+
media.appendChild(lens);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return { media, lens }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function syncLensSurface(media, lens, zoomFactor) {
|
|
123
|
+
const image = media.querySelector('img');
|
|
124
|
+
const computed = window.getComputedStyle(media);
|
|
125
|
+
|
|
126
|
+
if (image?.currentSrc || image?.src) {
|
|
127
|
+
lens.style.backgroundImage = `url("${resolveImageUrl(image)}")`;
|
|
128
|
+
lens.style.backgroundColor = 'transparent';
|
|
129
|
+
lens.style.backgroundRepeat = 'no-repeat';
|
|
130
|
+
lens.style.removeProperty('background-size');
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
lens.style.backgroundImage = computed.backgroundImage;
|
|
135
|
+
lens.style.backgroundColor = computed.backgroundColor;
|
|
136
|
+
lens.style.backgroundRepeat = computed.backgroundRepeat;
|
|
137
|
+
lens.style.removeProperty('background-size');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function primeLensSurface(el, state, zoomFactor) {
|
|
141
|
+
const { media, lens, image } = state;
|
|
142
|
+
const markReady = () => {
|
|
143
|
+
if (stateMap.get(el) !== state) {
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
state.surfaceReady = true;
|
|
147
|
+
syncLensSurface(media, lens);
|
|
148
|
+
if (state.lastPointer) {
|
|
149
|
+
syncLensPosition({
|
|
150
|
+
mediaRect: media.getBoundingClientRect(),
|
|
151
|
+
lens,
|
|
152
|
+
image,
|
|
153
|
+
pointerX: state.lastPointer.x,
|
|
154
|
+
pointerY: state.lastPointer.y,
|
|
155
|
+
lensSize: state.lensSize,
|
|
156
|
+
zoomFactor,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (!(image?.currentSrc || image?.src)) {
|
|
162
|
+
markReady();
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
syncLensSurface(media, lens);
|
|
167
|
+
|
|
168
|
+
// If the image is already visible enough to be used as a magnifier source,
|
|
169
|
+
// don't block pointer interaction on decode/load timing.
|
|
170
|
+
state.surfaceReady = true;
|
|
171
|
+
|
|
172
|
+
if (image.complete && image.naturalWidth) {
|
|
173
|
+
if (typeof image.decode === 'function') {
|
|
174
|
+
image.decode().then(markReady).catch(markReady);
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
markReady();
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
state.onLoad = () => {
|
|
183
|
+
markReady();
|
|
184
|
+
};
|
|
185
|
+
image.addEventListener('load', state.onLoad, { once: true });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function syncLensPosition({
|
|
189
|
+
mediaRect,
|
|
190
|
+
lens,
|
|
191
|
+
image,
|
|
192
|
+
pointerX,
|
|
193
|
+
pointerY,
|
|
194
|
+
lensSize,
|
|
195
|
+
zoomFactor,
|
|
196
|
+
}) {
|
|
197
|
+
const lensX = pointerX - mediaRect.left;
|
|
198
|
+
const lensY = pointerY - mediaRect.top;
|
|
199
|
+
|
|
200
|
+
lens.style.setProperty('--readdy-anim-image-magnifier-lens-x', `${lensX}px`);
|
|
201
|
+
lens.style.setProperty('--readdy-anim-image-magnifier-lens-y', `${lensY}px`);
|
|
202
|
+
lens.style.opacity = '1';
|
|
203
|
+
|
|
204
|
+
if (image?.currentSrc || image?.src) {
|
|
205
|
+
const imageRect = image.getBoundingClientRect();
|
|
206
|
+
const naturalWidth = image.naturalWidth;
|
|
207
|
+
const naturalHeight = image.naturalHeight;
|
|
208
|
+
|
|
209
|
+
if (naturalWidth && naturalHeight && imageRect.width && imageRect.height) {
|
|
210
|
+
const localX = Math.min(Math.max(pointerX - imageRect.left, 0), imageRect.width);
|
|
211
|
+
const localY = Math.min(Math.max(pointerY - imageRect.top, 0), imageRect.height);
|
|
212
|
+
const scale = Math.max(imageRect.width / naturalWidth, imageRect.height / naturalHeight);
|
|
213
|
+
const renderedWidth = naturalWidth * scale;
|
|
214
|
+
const renderedHeight = naturalHeight * scale;
|
|
215
|
+
const objectPosition = resolveObjectPosition(image);
|
|
216
|
+
const offsetX = resolveObjectOffset(imageRect.width - renderedWidth, objectPosition.x);
|
|
217
|
+
const offsetY = resolveObjectOffset(imageRect.height - renderedHeight, objectPosition.y);
|
|
218
|
+
|
|
219
|
+
lens.style.backgroundSize = `${renderedWidth * zoomFactor}px ${renderedHeight * zoomFactor}px`;
|
|
220
|
+
lens.style.backgroundPosition = `${
|
|
221
|
+
-(localX - offsetX) * zoomFactor + lensSize / 2
|
|
222
|
+
}px ${-(localY - offsetY) * zoomFactor + lensSize / 2}px`;
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const localX = (lensX / mediaRect.width) * 100;
|
|
228
|
+
const localY = (lensY / mediaRect.height) * 100;
|
|
229
|
+
lens.style.setProperty('--readdy-anim-magnifier-x', `${localX}%`);
|
|
230
|
+
lens.style.setProperty('--readdy-anim-magnifier-y', `${localY}%`);
|
|
231
|
+
lens.style.backgroundPosition = `${localX}% ${localY}%`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function init(el, options = {}) {
|
|
235
|
+
destroy(el);
|
|
236
|
+
|
|
237
|
+
el.classList.add(CSS_CLASS);
|
|
238
|
+
|
|
239
|
+
if (prefersReducedMotion()) {
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const lensSize = options.lensSize ?? 104;
|
|
244
|
+
const zoom = options.zoom ?? 320;
|
|
245
|
+
const zoomFactor = zoom / 100;
|
|
246
|
+
const fadeDuration = options.fadeDuration ?? 160;
|
|
247
|
+
|
|
248
|
+
el.style.setProperty('--readdy-anim-image-magnifier-lens-size', `${lensSize}px`);
|
|
249
|
+
el.style.setProperty('--readdy-anim-image-magnifier-zoom', `${zoom}%`);
|
|
250
|
+
el.style.setProperty('--readdy-anim-image-magnifier-fade-duration', `${fadeDuration}ms`);
|
|
251
|
+
|
|
252
|
+
const { media, lens } = ensureLens(el);
|
|
253
|
+
const image = media.querySelector('img');
|
|
254
|
+
const state = {
|
|
255
|
+
media,
|
|
256
|
+
lens,
|
|
257
|
+
cleanupPointerFollow: () => {},
|
|
258
|
+
image,
|
|
259
|
+
onLoad: null,
|
|
260
|
+
surfaceReady: false,
|
|
261
|
+
lastPointer: null,
|
|
262
|
+
lensSize,
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const onMove = (event, context) => {
|
|
266
|
+
state.lastPointer = {
|
|
267
|
+
x: event.clientX,
|
|
268
|
+
y: event.clientY,
|
|
269
|
+
};
|
|
270
|
+
if (!state.surfaceReady) {
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
syncLensPosition({
|
|
275
|
+
mediaRect: context.rect,
|
|
276
|
+
lens,
|
|
277
|
+
image,
|
|
278
|
+
pointerX: event.clientX,
|
|
279
|
+
pointerY: event.clientY,
|
|
280
|
+
lensSize,
|
|
281
|
+
zoomFactor,
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const onLeave = () => {
|
|
286
|
+
lens.style.opacity = '0';
|
|
287
|
+
state.lastPointer = null;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const onEnter = (event, context) => {
|
|
291
|
+
state.lastPointer = {
|
|
292
|
+
x: event.clientX,
|
|
293
|
+
y: event.clientY,
|
|
294
|
+
};
|
|
295
|
+
if (!state.surfaceReady) {
|
|
296
|
+
return
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
syncLensPosition({
|
|
300
|
+
mediaRect: context.rect,
|
|
301
|
+
lens,
|
|
302
|
+
image,
|
|
303
|
+
pointerX: event.clientX,
|
|
304
|
+
pointerY: event.clientY,
|
|
305
|
+
lensSize,
|
|
306
|
+
zoomFactor,
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const cleanupPointerFollow = attachPointerFollow(media, { onEnter, onMove, onLeave });
|
|
311
|
+
state.cleanupPointerFollow = cleanupPointerFollow;
|
|
312
|
+
stateMap.set(el, state);
|
|
313
|
+
primeLensSurface(el, state, zoomFactor);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function destroy(el) {
|
|
317
|
+
const state = stateMap.get(el);
|
|
318
|
+
if (state) {
|
|
319
|
+
state.cleanupPointerFollow();
|
|
320
|
+
if (state.image && state.onLoad) {
|
|
321
|
+
state.image.removeEventListener('load', state.onLoad);
|
|
322
|
+
}
|
|
323
|
+
state.media.classList.remove(ENHANCED_MEDIA_CLASS);
|
|
324
|
+
stateMap.delete(el);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
el.classList.remove(CSS_CLASS);
|
|
328
|
+
el.style.removeProperty('--readdy-anim-image-magnifier-lens-size');
|
|
329
|
+
el.style.removeProperty('--readdy-anim-image-magnifier-zoom');
|
|
330
|
+
el.style.removeProperty('--readdy-anim-image-magnifier-fade-duration');
|
|
331
|
+
el.querySelector(`.${LENS_CLASS}`)?.remove();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../image-zoom-rotate.js';
|
|
3
|
+
import { p as prefersReducedMotion } from '../../chunks/reduced-motion-HX79Ac8G.js';
|
|
4
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
5
|
+
import '../../chunks/resolve-card-media-Cj3V_oms.js';
|
|
6
|
+
|
|
7
|
+
function AnimImageZoomRotate({ children, scale, rotate, duration, }) {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const el = ref.current;
|
|
11
|
+
if (!el || prefersReducedMotion())
|
|
12
|
+
return;
|
|
13
|
+
init(el, { scale, rotate, duration });
|
|
14
|
+
return () => {
|
|
15
|
+
destroy(el);
|
|
16
|
+
};
|
|
17
|
+
}, [scale, rotate, duration]);
|
|
18
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { AnimImageZoomRotate };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
import { r as resolveCardMediaElement } from '../chunks/resolve-card-media-Cj3V_oms.js';
|
|
3
|
+
|
|
4
|
+
const ANIMATION_ID = buildAnimId('image-zoom-rotate');
|
|
5
|
+
|
|
6
|
+
const CSS_CLASS = buildAnimClass('image-zoom-rotate');
|
|
7
|
+
const MEDIA_CLASS = buildAnimClass('card-media');
|
|
8
|
+
|
|
9
|
+
const autoMediaState = new WeakMap();
|
|
10
|
+
|
|
11
|
+
function init(el, options = {}) {
|
|
12
|
+
if (!el.classList.contains(CSS_CLASS)) {
|
|
13
|
+
el.classList.add(CSS_CLASS);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
el.style.setProperty('--readdy-anim-image-zoom-scale', `${options.scale ?? 1.08}`);
|
|
17
|
+
el.style.setProperty('--readdy-anim-image-zoom-rotate', `${options.rotate ?? 2}deg`);
|
|
18
|
+
el.style.setProperty('--readdy-anim-image-zoom-duration', `${options.duration ?? 500}ms`);
|
|
19
|
+
|
|
20
|
+
const media = resolveCardMediaElement(el, MEDIA_CLASS);
|
|
21
|
+
if (!media) return
|
|
22
|
+
|
|
23
|
+
const state = {
|
|
24
|
+
media,
|
|
25
|
+
addedMediaClass: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (!media.classList.contains(MEDIA_CLASS)) {
|
|
29
|
+
media.classList.add(MEDIA_CLASS);
|
|
30
|
+
state.addedMediaClass = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
autoMediaState.set(el, state);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function destroy(el) {
|
|
37
|
+
el.classList.remove(CSS_CLASS);
|
|
38
|
+
el.style.removeProperty('--readdy-anim-image-zoom-scale');
|
|
39
|
+
el.style.removeProperty('--readdy-anim-image-zoom-rotate');
|
|
40
|
+
el.style.removeProperty('--readdy-anim-image-zoom-duration');
|
|
41
|
+
|
|
42
|
+
const state = autoMediaState.get(el);
|
|
43
|
+
if (state?.addedMediaClass) {
|
|
44
|
+
state.media?.classList.remove(MEDIA_CLASS);
|
|
45
|
+
}
|
|
46
|
+
autoMediaState.delete(el);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../pop-in-stack.js';
|
|
3
|
+
import { p as prefersReducedMotion } from '../../chunks/reduced-motion-HX79Ac8G.js';
|
|
4
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
5
|
+
|
|
6
|
+
function AnimPopInStack({ children, delay, duration, offset, scaleStart, }) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el || prefersReducedMotion())
|
|
11
|
+
return;
|
|
12
|
+
init(el, { delay, duration, offset, scaleStart });
|
|
13
|
+
return () => {
|
|
14
|
+
destroy(el);
|
|
15
|
+
};
|
|
16
|
+
}, [delay, duration, offset, scaleStart]);
|
|
17
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { AnimPopInStack };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_ID = buildAnimId('pop-in-stack');
|
|
4
|
+
|
|
5
|
+
const CSS_CLASS = buildAnimClass('pop-in-stack');
|
|
6
|
+
|
|
7
|
+
function init(el, options = {}) {
|
|
8
|
+
if (!el.classList.contains(CSS_CLASS)) {
|
|
9
|
+
el.classList.add(CSS_CLASS);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
el.style.setProperty('--readdy-anim-pop-delay', `${options.delay ?? 0}ms`);
|
|
13
|
+
el.style.setProperty('--readdy-anim-pop-duration', `${options.duration ?? 600}ms`);
|
|
14
|
+
el.style.setProperty('--readdy-anim-pop-offset', `${options.offset ?? 18}px`);
|
|
15
|
+
el.style.setProperty('--readdy-anim-pop-scale-start', `${options.scaleStart ?? 0.88}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function destroy(el) {
|
|
19
|
+
el.classList.remove(CSS_CLASS);
|
|
20
|
+
el.style.removeProperty('--readdy-anim-pop-delay');
|
|
21
|
+
el.style.removeProperty('--readdy-anim-pop-duration');
|
|
22
|
+
el.style.removeProperty('--readdy-anim-pop-offset');
|
|
23
|
+
el.style.removeProperty('--readdy-anim-pop-scale-start');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../reveal-from-top.js';
|
|
3
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reveal From Top — 卡片从顶部揭示
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* <AnimRevealFromTop><div className="card">内容</div></AnimRevealFromTop>
|
|
10
|
+
*
|
|
11
|
+
* 不加 wrapper div — 通过 cloneElement 给子元素注入 ref,加/删 .readdy-anim-reveal-from-top class
|
|
12
|
+
* 必须恰好包裹一个子元素
|
|
13
|
+
*/
|
|
14
|
+
function AnimRevealFromTop({ children }) {
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el)
|
|
19
|
+
return;
|
|
20
|
+
init(el);
|
|
21
|
+
return () => {
|
|
22
|
+
destroy(el);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { AnimRevealFromTop };
|