@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,61 @@
|
|
|
1
|
+
import { p as prefersReducedMotion } from '../chunks/reduced-motion-HX79Ac8G.js';
|
|
2
|
+
import { a as attachPointerFollow, g as getPointerMetrics } from '../chunks/pointer-follow-BETANySn.js';
|
|
3
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
4
|
+
|
|
5
|
+
const ANIMATION_ID = buildAnimId('3d-flip');
|
|
6
|
+
|
|
7
|
+
const CSS_CLASS = buildAnimClass('3d-flip');
|
|
8
|
+
const stateMap = new WeakMap();
|
|
9
|
+
|
|
10
|
+
function reset(el) {
|
|
11
|
+
el.style.setProperty('--readdy-anim-3d-rotate-x', '0deg');
|
|
12
|
+
el.style.setProperty('--readdy-anim-3d-rotate-y', '0deg');
|
|
13
|
+
el.style.setProperty('--readdy-anim-3d-translate-x', '0px');
|
|
14
|
+
el.style.setProperty('--readdy-anim-3d-translate-y', '0px');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function init(el, options = {}) {
|
|
18
|
+
destroy(el);
|
|
19
|
+
|
|
20
|
+
el.classList.add(CSS_CLASS);
|
|
21
|
+
reset(el);
|
|
22
|
+
|
|
23
|
+
if (prefersReducedMotion()) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const tilt = options.maxTilt ?? 12;
|
|
28
|
+
const travel = options.translate ?? 8;
|
|
29
|
+
|
|
30
|
+
const onMove = (event, context) => {
|
|
31
|
+
const { relativeX, relativeY } = getPointerMetrics(context.rect, event);
|
|
32
|
+
|
|
33
|
+
el.style.setProperty('--readdy-anim-3d-rotate-x', `${relativeY * -tilt * 2}deg`);
|
|
34
|
+
el.style.setProperty('--readdy-anim-3d-rotate-y', `${relativeX * tilt * 2}deg`);
|
|
35
|
+
el.style.setProperty('--readdy-anim-3d-translate-x', `${relativeX * travel * 2}px`);
|
|
36
|
+
el.style.setProperty('--readdy-anim-3d-translate-y', `${relativeY * travel * 2}px`);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const onLeave = () => {
|
|
40
|
+
reset(el);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const cleanup = attachPointerFollow(el, { onMove, onLeave });
|
|
44
|
+
stateMap.set(el, { cleanup });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function destroy(el) {
|
|
48
|
+
const state = stateMap.get(el);
|
|
49
|
+
if (state) {
|
|
50
|
+
state.cleanup();
|
|
51
|
+
stateMap.delete(el);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
el.classList.remove(CSS_CLASS);
|
|
55
|
+
el.style.removeProperty('--readdy-anim-3d-rotate-x');
|
|
56
|
+
el.style.removeProperty('--readdy-anim-3d-rotate-y');
|
|
57
|
+
el.style.removeProperty('--readdy-anim-3d-translate-x');
|
|
58
|
+
el.style.removeProperty('--readdy-anim-3d-translate-y');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../blur-fade-in.js';
|
|
3
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Blur Fade In — 按钮模糊淡入
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* <AnimBlurFadeIn><button>点击</button></AnimBlurFadeIn>
|
|
10
|
+
*
|
|
11
|
+
* 不加 wrapper div — 通过 cloneElement 给子元素注入 ref,加/删 .readdy-anim-blur-fade-in class
|
|
12
|
+
* 必须恰好包裹一个子元素
|
|
13
|
+
*/
|
|
14
|
+
function AnimBlurFadeIn({ 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 { AnimBlurFadeIn };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_ID = buildAnimId('blur-fade-in');
|
|
4
|
+
|
|
5
|
+
const CSS_CLASS = buildAnimClass('blur-fade-in');
|
|
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 { p as prefersReducedMotion } from '../../chunks/reduced-motion-HX79Ac8G.js';
|
|
3
|
+
import { init, destroy } from '../border-beam.js';
|
|
4
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
5
|
+
|
|
6
|
+
function AnimBorderBeam({ children, duration, delay, borderWidth, glowOpacity, size, initialOffset, colorFrom, colorTo, reverse, respectReducedMotion = true, }) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
if (respectReducedMotion && prefersReducedMotion())
|
|
13
|
+
return;
|
|
14
|
+
init(el, { duration, delay, borderWidth, glowOpacity, size, initialOffset, colorFrom, colorTo, reverse });
|
|
15
|
+
return () => {
|
|
16
|
+
destroy(el);
|
|
17
|
+
};
|
|
18
|
+
}, [borderWidth, colorFrom, colorTo, delay, duration, glowOpacity, initialOffset, respectReducedMotion, reverse, size]);
|
|
19
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { AnimBorderBeam };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_ID = buildAnimId('border-beam');
|
|
4
|
+
|
|
5
|
+
const CSS_CLASS = buildAnimClass('border-beam');
|
|
6
|
+
const LAYER_CLASS = `${CSS_CLASS}__layer`;
|
|
7
|
+
const BEAM_CLASS = `${CSS_CLASS}__beam`;
|
|
8
|
+
const BEAM_WARM_CLASS = `${BEAM_CLASS}--warm`;
|
|
9
|
+
const BEAM_COOL_CLASS = `${BEAM_CLASS}--cool`;
|
|
10
|
+
const ANIMATION_KEY = '__readdyBorderBeamAnimation';
|
|
11
|
+
const STATE_KEY = '__readdyBorderBeamState';
|
|
12
|
+
const DEFAULT_SIZE = 72;
|
|
13
|
+
|
|
14
|
+
function ensureLayer(el) {
|
|
15
|
+
const existing = Array.from(el.children).find((child) => child.classList?.contains(LAYER_CLASS));
|
|
16
|
+
if (existing) {
|
|
17
|
+
const warmBeam = existing.querySelector(`.${BEAM_WARM_CLASS}`);
|
|
18
|
+
const coolBeam = existing.querySelector(`.${BEAM_COOL_CLASS}`);
|
|
19
|
+
if (warmBeam && coolBeam) {
|
|
20
|
+
return { layer: existing, beams: [warmBeam, coolBeam] }
|
|
21
|
+
}
|
|
22
|
+
existing.remove();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const layer = document.createElement('span');
|
|
26
|
+
layer.className = LAYER_CLASS;
|
|
27
|
+
layer.setAttribute('aria-hidden', 'true');
|
|
28
|
+
|
|
29
|
+
const warmBeam = document.createElement('span');
|
|
30
|
+
warmBeam.className = `${BEAM_CLASS} ${BEAM_WARM_CLASS}`;
|
|
31
|
+
layer.appendChild(warmBeam);
|
|
32
|
+
|
|
33
|
+
const coolBeam = document.createElement('span');
|
|
34
|
+
coolBeam.className = `${BEAM_CLASS} ${BEAM_COOL_CLASS}`;
|
|
35
|
+
layer.appendChild(coolBeam);
|
|
36
|
+
|
|
37
|
+
el.appendChild(layer);
|
|
38
|
+
|
|
39
|
+
return { layer, beams: [warmBeam, coolBeam] }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function cancelAnimation(el) {
|
|
43
|
+
el[ANIMATION_KEY]?.cancel?.();
|
|
44
|
+
delete el[ANIMATION_KEY];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getBeamSize(el, options) {
|
|
48
|
+
if (typeof options.size === 'number') {
|
|
49
|
+
return options.size
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { width, height } = el.getBoundingClientRect();
|
|
53
|
+
return Math.max(DEFAULT_SIZE, Math.min(Math.round((width + height) * 0.22), 160))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function syncLayer(el) {
|
|
57
|
+
const state = el[STATE_KEY];
|
|
58
|
+
if (!state) return
|
|
59
|
+
|
|
60
|
+
const { beams, options } = state;
|
|
61
|
+
const radius = getComputedStyle(el).borderRadius || '0px';
|
|
62
|
+
const size = getBeamSize(el, options);
|
|
63
|
+
|
|
64
|
+
el.style.setProperty('--readdy-anim-border-beam-radius', radius);
|
|
65
|
+
el.style.setProperty('--readdy-anim-border-beam-duration', `${options.duration ?? 3000}ms`);
|
|
66
|
+
el.style.setProperty('--readdy-anim-border-beam-width', `${options.borderWidth ?? 1.35}px`);
|
|
67
|
+
el.style.setProperty('--readdy-anim-border-beam-glow-opacity', `${options.glowOpacity ?? 0.28}`);
|
|
68
|
+
el.style.setProperty('--readdy-anim-border-beam-size', `${size}px`);
|
|
69
|
+
|
|
70
|
+
beams.forEach((beam, index) => {
|
|
71
|
+
beam.style.width = `${size}px`;
|
|
72
|
+
beam.style.offsetPath = `rect(0 auto auto 0 round ${radius})`;
|
|
73
|
+
if (index === 0) {
|
|
74
|
+
beam.style.setProperty('--readdy-anim-border-beam-color-from', options.colorFrom ?? '#ff6b6b');
|
|
75
|
+
beam.style.setProperty('--readdy-anim-border-beam-color-to', options.colorTo ?? '#ffb86b');
|
|
76
|
+
} else {
|
|
77
|
+
beam.style.setProperty('--readdy-anim-border-beam-color-from', options.secondaryColorFrom ?? '#5ea0ff');
|
|
78
|
+
beam.style.setProperty('--readdy-anim-border-beam-color-to', options.secondaryColorTo ?? '#9ec5ff');
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function runAnimation(el) {
|
|
84
|
+
const state = el[STATE_KEY];
|
|
85
|
+
if (!state) return
|
|
86
|
+
|
|
87
|
+
const { beams, options } = state;
|
|
88
|
+
const initialOffset = options.initialOffset ?? 0;
|
|
89
|
+
const duration = options.duration ?? 3000;
|
|
90
|
+
const delay = options.delay ?? 0;
|
|
91
|
+
const reverse = options.reverse ?? false;
|
|
92
|
+
|
|
93
|
+
cancelAnimation(el);
|
|
94
|
+
const animations = beams
|
|
95
|
+
.map((beam, index) => {
|
|
96
|
+
if (typeof beam.animate !== 'function') return null
|
|
97
|
+
|
|
98
|
+
const beamOffset = initialOffset + index * 50;
|
|
99
|
+
const from = reverse ? `${100 - beamOffset}%` : `${beamOffset}%`;
|
|
100
|
+
const to = reverse ? `${-beamOffset}%` : `${100 + beamOffset}%`;
|
|
101
|
+
beam.style.offsetDistance = from;
|
|
102
|
+
|
|
103
|
+
return beam.animate(
|
|
104
|
+
[
|
|
105
|
+
{ offsetDistance: from },
|
|
106
|
+
{ offsetDistance: to },
|
|
107
|
+
],
|
|
108
|
+
{
|
|
109
|
+
duration,
|
|
110
|
+
delay: -delay,
|
|
111
|
+
easing: 'linear',
|
|
112
|
+
iterations: Infinity,
|
|
113
|
+
fill: 'both',
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
})
|
|
117
|
+
.filter(Boolean);
|
|
118
|
+
|
|
119
|
+
if (animations.length > 0) {
|
|
120
|
+
el[ANIMATION_KEY] = {
|
|
121
|
+
cancel() {
|
|
122
|
+
animations.forEach((animation) => animation.cancel());
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function init(el, options = {}) {
|
|
129
|
+
if (!el.classList.contains(CSS_CLASS)) {
|
|
130
|
+
el.classList.add(CSS_CLASS);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { layer, beams } = ensureLayer(el);
|
|
134
|
+
const state = el[STATE_KEY] ?? { layer, beams, options };
|
|
135
|
+
|
|
136
|
+
state.layer = layer;
|
|
137
|
+
state.beams = beams;
|
|
138
|
+
state.options = options;
|
|
139
|
+
|
|
140
|
+
if (!state.resizeObserver && typeof ResizeObserver !== 'undefined') {
|
|
141
|
+
state.resizeObserver = new ResizeObserver(() => {
|
|
142
|
+
syncLayer(el);
|
|
143
|
+
});
|
|
144
|
+
state.resizeObserver.observe(el);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
el[STATE_KEY] = state;
|
|
148
|
+
syncLayer(el);
|
|
149
|
+
runAnimation(el);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function destroy(el) {
|
|
153
|
+
cancelAnimation(el);
|
|
154
|
+
|
|
155
|
+
const state = el[STATE_KEY];
|
|
156
|
+
state?.resizeObserver?.disconnect();
|
|
157
|
+
state?.layer?.remove();
|
|
158
|
+
delete el[STATE_KEY];
|
|
159
|
+
|
|
160
|
+
el.classList.remove(CSS_CLASS);
|
|
161
|
+
el.style.removeProperty('--readdy-anim-border-beam-radius');
|
|
162
|
+
el.style.removeProperty('--readdy-anim-border-beam-duration');
|
|
163
|
+
el.style.removeProperty('--readdy-anim-border-beam-width');
|
|
164
|
+
el.style.removeProperty('--readdy-anim-border-beam-glow-opacity');
|
|
165
|
+
el.style.removeProperty('--readdy-anim-border-beam-size');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export { ANIMATION_ID, destroy, init };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../bounce-elastic.js';
|
|
3
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Bounce Elastic — 按钮弹性弹入
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* <AnimBounceElastic><button>点击</button></AnimBounceElastic>
|
|
10
|
+
*
|
|
11
|
+
* 不加 wrapper div — 通过 cloneElement 给子元素注入 ref,加/删 .readdy-anim-bounce-elastic class
|
|
12
|
+
* 必须恰好包裹一个子元素
|
|
13
|
+
*/
|
|
14
|
+
function AnimBounceElastic({ 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 { AnimBounceElastic };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { b as buildAnimId, a as buildAnimClass } from '../chunks/constants-EnH6-Pz4.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_ID = buildAnimId('bounce-elastic');
|
|
4
|
+
|
|
5
|
+
const CSS_CLASS = buildAnimClass('bounce-elastic');
|
|
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,20 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { init, destroy } from '../bubble-button.js';
|
|
3
|
+
import { p as prefersReducedMotion } from '../../chunks/reduced-motion-HX79Ac8G.js';
|
|
4
|
+
import '../../chunks/constants-EnH6-Pz4.js';
|
|
5
|
+
|
|
6
|
+
function AnimBubbleButton({ children }) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el || prefersReducedMotion())
|
|
11
|
+
return;
|
|
12
|
+
init(el);
|
|
13
|
+
return () => {
|
|
14
|
+
destroy(el);
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
return React.cloneElement(React.Children.only(children), { ref });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { AnimBubbleButton };
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { p as prefersReducedMotion } from '../chunks/reduced-motion-HX79Ac8G.js';
|
|
2
|
+
import { b as buildAnimId, a as buildAnimClass, c as buildAnimDomId } from '../chunks/constants-EnH6-Pz4.js';
|
|
3
|
+
|
|
4
|
+
const ANIMATION_ID = buildAnimId('bubble-button');
|
|
5
|
+
|
|
6
|
+
const CSS_CLASS = buildAnimClass('bubble-button');
|
|
7
|
+
const ACTIVE_CLASS = buildAnimClass('bubble-button-active');
|
|
8
|
+
const HOVER_CLASS = buildAnimClass('bubble-button-hover');
|
|
9
|
+
const FALLBACK_CLASS = buildAnimClass('bubble-button-fallback');
|
|
10
|
+
const CONTAINER_CLASS = buildAnimClass('bubble-button-container');
|
|
11
|
+
const EFFECT_CONTAINER_CLASS = buildAnimClass('bubble-button-effect-container');
|
|
12
|
+
const EFFECT_BUTTON_CLASS = buildAnimClass('bubble-button-effect-button');
|
|
13
|
+
const CIRCLE_CLASS = buildAnimClass('bubble-button-circle');
|
|
14
|
+
const FILTER_ID = buildAnimDomId('bubble-goo');
|
|
15
|
+
const FILTER_ROOT_ID = buildAnimDomId('bubble-goo-root');
|
|
16
|
+
|
|
17
|
+
const stateMap = new WeakMap();
|
|
18
|
+
let gooFilterRefCount = 0;
|
|
19
|
+
|
|
20
|
+
function ensureGooFilter() {
|
|
21
|
+
gooFilterRefCount += 1;
|
|
22
|
+
if (document.getElementById(FILTER_ID)) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
27
|
+
svg.id = FILTER_ROOT_ID;
|
|
28
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
29
|
+
svg.style.position = 'absolute';
|
|
30
|
+
svg.style.width = '0';
|
|
31
|
+
svg.style.height = '0';
|
|
32
|
+
svg.style.pointerEvents = 'none';
|
|
33
|
+
|
|
34
|
+
svg.innerHTML = `
|
|
35
|
+
<defs>
|
|
36
|
+
<filter id="${FILTER_ID}">
|
|
37
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
|
|
38
|
+
<feColorMatrix
|
|
39
|
+
in="blur"
|
|
40
|
+
mode="matrix"
|
|
41
|
+
values="
|
|
42
|
+
1 0 0 0 0
|
|
43
|
+
0 1 0 0 0
|
|
44
|
+
0 0 1 0 0
|
|
45
|
+
0 0 0 19 -9
|
|
46
|
+
"
|
|
47
|
+
result="goo"
|
|
48
|
+
/>
|
|
49
|
+
<feComposite in="SourceGraphic" in2="goo" />
|
|
50
|
+
</filter>
|
|
51
|
+
</defs>
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
document.body.appendChild(svg);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function releaseGooFilter() {
|
|
58
|
+
gooFilterRefCount = Math.max(gooFilterRefCount - 1, 0);
|
|
59
|
+
if (gooFilterRefCount === 0) {
|
|
60
|
+
document.getElementById(FILTER_ROOT_ID)?.remove();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createCircle(position, slot) {
|
|
65
|
+
const circle = document.createElement('span');
|
|
66
|
+
circle.className = `${CIRCLE_CLASS} ${CIRCLE_CLASS}-${position} ${CIRCLE_CLASS}-${position}-${slot}`;
|
|
67
|
+
return circle
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function ensureStructure(el) {
|
|
71
|
+
let container = el.parentElement;
|
|
72
|
+
|
|
73
|
+
if (!container?.classList.contains(CONTAINER_CLASS)) {
|
|
74
|
+
container = document.createElement('span');
|
|
75
|
+
container.className = CONTAINER_CLASS;
|
|
76
|
+
el.parentNode?.insertBefore(container, el);
|
|
77
|
+
container.appendChild(el);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let effectContainer = container.querySelector(`.${EFFECT_CONTAINER_CLASS}`);
|
|
81
|
+
if (!effectContainer) {
|
|
82
|
+
effectContainer = document.createElement('span');
|
|
83
|
+
effectContainer.className = EFFECT_CONTAINER_CLASS;
|
|
84
|
+
effectContainer.style.filter = `url(#${FILTER_ID})`;
|
|
85
|
+
effectContainer.style.webkitFilter = `url(#${FILTER_ID})`;
|
|
86
|
+
|
|
87
|
+
effectContainer.appendChild(createCircle('top-left', 1));
|
|
88
|
+
effectContainer.appendChild(createCircle('top-left', 2));
|
|
89
|
+
effectContainer.appendChild(createCircle('top-left', 3));
|
|
90
|
+
|
|
91
|
+
const effectButton = document.createElement('span');
|
|
92
|
+
effectButton.className = EFFECT_BUTTON_CLASS;
|
|
93
|
+
effectContainer.appendChild(effectButton);
|
|
94
|
+
|
|
95
|
+
effectContainer.appendChild(createCircle('bottom-right', 1));
|
|
96
|
+
effectContainer.appendChild(createCircle('bottom-right', 2));
|
|
97
|
+
effectContainer.appendChild(createCircle('bottom-right', 3));
|
|
98
|
+
|
|
99
|
+
container.appendChild(effectContainer);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
container,
|
|
104
|
+
effectContainer,
|
|
105
|
+
effectButton: effectContainer.querySelector(`.${EFFECT_BUTTON_CLASS}`),
|
|
106
|
+
circlesTopLeft: Array.from(effectContainer.querySelectorAll(`.${CIRCLE_CLASS}-top-left`)),
|
|
107
|
+
circlesBottomRight: Array.from(effectContainer.querySelectorAll(`.${CIRCLE_CLASS}-bottom-right`)),
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function setAccent(container, el) {
|
|
112
|
+
const computed = window.getComputedStyle(el);
|
|
113
|
+
const backgroundColor = computed.backgroundColor;
|
|
114
|
+
const accent = backgroundColor && backgroundColor !== 'rgba(0, 0, 0, 0)' ? backgroundColor : '#4f6bff';
|
|
115
|
+
container.style.setProperty('--readdy-anim-bubble-accent', accent);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function clearAnimations(state) {
|
|
119
|
+
state.animations.forEach((animation) => {
|
|
120
|
+
animation.cancel();
|
|
121
|
+
});
|
|
122
|
+
state.animations = [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function trackAnimation(state, animation) {
|
|
126
|
+
if (!animation) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
state.animations.push(animation);
|
|
131
|
+
const forget = () => {
|
|
132
|
+
state.animations = state.animations.filter((item) => item !== animation);
|
|
133
|
+
};
|
|
134
|
+
animation.addEventListener('finish', forget, { once: true });
|
|
135
|
+
animation.addEventListener('cancel', forget, { once: true });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function clearInlineState(state) {
|
|
139
|
+
const nodes = [
|
|
140
|
+
state.effectButton,
|
|
141
|
+
...state.circlesTopLeft,
|
|
142
|
+
...state.circlesBottomRight,
|
|
143
|
+
].filter(Boolean);
|
|
144
|
+
|
|
145
|
+
nodes.forEach((node) => {
|
|
146
|
+
node.style.opacity = '';
|
|
147
|
+
node.style.transform = '';
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function resetState(state) {
|
|
152
|
+
clearAnimations(state);
|
|
153
|
+
state.container.classList.remove(ACTIVE_CLASS);
|
|
154
|
+
state.container.classList.remove(HOVER_CLASS);
|
|
155
|
+
clearInlineState(state);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function hasWAAPI() {
|
|
159
|
+
return typeof Element.prototype.animate === 'function'
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function playBurst(state) {
|
|
163
|
+
const { container, effectButton, circlesTopLeft, circlesBottomRight } = state;
|
|
164
|
+
|
|
165
|
+
container.classList.remove(ACTIVE_CLASS);
|
|
166
|
+
void container.offsetWidth;
|
|
167
|
+
container.classList.add(HOVER_CLASS);
|
|
168
|
+
container.classList.add(ACTIVE_CLASS);
|
|
169
|
+
|
|
170
|
+
if (!state.supportsWAAPI) {
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
clearAnimations(state);
|
|
175
|
+
|
|
176
|
+
trackAnimation(
|
|
177
|
+
state,
|
|
178
|
+
effectButton?.animate(
|
|
179
|
+
[
|
|
180
|
+
{ transform: 'translateY(-50%) scaleY(1)', opacity: 1 },
|
|
181
|
+
{ transform: 'translateY(-50%) scaleY(1.1)', opacity: 1, offset: 0.34 },
|
|
182
|
+
{ transform: 'translateY(-50%) scale(1)', opacity: 1 },
|
|
183
|
+
],
|
|
184
|
+
{
|
|
185
|
+
duration: 1000,
|
|
186
|
+
easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
187
|
+
fill: 'forwards',
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const topFrames = [
|
|
193
|
+
[
|
|
194
|
+
{ transform: 'translate(0, 0) rotate(-45deg) scale(1)', opacity: 1 },
|
|
195
|
+
{ transform: 'translate(-25px, -25px) rotate(-45deg) scale(1, 2)', opacity: 1, offset: 0.5 },
|
|
196
|
+
{ transform: 'translate(-19px, -27px) rotate(-45deg) scale(0.2)', opacity: 0.95, offset: 0.58 },
|
|
197
|
+
{ transform: 'translate(-24px, -42px) rotate(-45deg) scale(0)', opacity: 0 },
|
|
198
|
+
],
|
|
199
|
+
[
|
|
200
|
+
{ transform: 'translate(0, 0) rotate(-45deg) scale(1)', opacity: 1 },
|
|
201
|
+
{ transform: 'translate(-25px, -25px) rotate(-45deg) scale(1, 2)', opacity: 1, offset: 0.5 },
|
|
202
|
+
{ transform: 'translate(-35px, -32px) rotate(-45deg) scale(1, 0.8)', opacity: 0.95, offset: 0.58 },
|
|
203
|
+
{ transform: 'translate(-45px, -42px) rotate(-45deg) scale(0.4)', opacity: 0 },
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
{ transform: 'translate(0, 0) rotate(-45deg) scale(1)', opacity: 1 },
|
|
207
|
+
{ transform: 'translate(-25px, -25px) rotate(-45deg) scale(1, 2)', opacity: 1, offset: 0.5 },
|
|
208
|
+
{ transform: 'translate(-40px, -19px) rotate(-45deg) scale(0.2)', opacity: 0.95, offset: 0.58 },
|
|
209
|
+
{ transform: 'translate(-55px, -14px) rotate(-45deg) scale(0)', opacity: 0 },
|
|
210
|
+
],
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
const bottomFrames = [
|
|
214
|
+
[
|
|
215
|
+
{ transform: 'translate(0, 0) rotate(45deg) scale(1)', opacity: 1 },
|
|
216
|
+
{ transform: 'translate(30px, 30px) rotate(45deg) scale(1)', opacity: 1, offset: 0.48 },
|
|
217
|
+
{ transform: 'translate(24px, 33px) rotate(45deg) scale(0.2)', opacity: 0.95, offset: 0.56 },
|
|
218
|
+
{ transform: 'translate(29px, 48px) rotate(45deg) scale(0)', opacity: 0 },
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
{ transform: 'translate(0, 0) rotate(45deg) scale(1)', opacity: 1 },
|
|
222
|
+
{ transform: 'translate(30px, 30px) rotate(45deg) scale(1)', opacity: 1, offset: 0.48 },
|
|
223
|
+
{ transform: 'translate(37px, 33px) rotate(45deg) scale(0.8)', opacity: 0.95, offset: 0.56 },
|
|
224
|
+
{ transform: 'translate(44px, 40px) rotate(45deg) scale(0.4)', opacity: 0 },
|
|
225
|
+
],
|
|
226
|
+
[
|
|
227
|
+
{ transform: 'translate(0, 0) rotate(45deg) scale(1)', opacity: 1 },
|
|
228
|
+
{ transform: 'translate(30px, 30px) rotate(45deg) scale(1)', opacity: 1, offset: 0.48 },
|
|
229
|
+
{ transform: 'translate(45px, 24px) rotate(45deg) scale(0.2)', opacity: 0.95, offset: 0.56 },
|
|
230
|
+
{ transform: 'translate(60px, 19px) rotate(45deg) scale(0)', opacity: 0 },
|
|
231
|
+
],
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
circlesTopLeft.forEach((circle, index) => {
|
|
235
|
+
trackAnimation(
|
|
236
|
+
state,
|
|
237
|
+
circle.animate(topFrames[index], {
|
|
238
|
+
duration: 1200,
|
|
239
|
+
easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
240
|
+
fill: 'forwards',
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
circlesBottomRight.forEach((circle, index) => {
|
|
246
|
+
trackAnimation(
|
|
247
|
+
state,
|
|
248
|
+
circle.animate(bottomFrames[index], {
|
|
249
|
+
duration: 1100,
|
|
250
|
+
easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
251
|
+
fill: 'forwards',
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function init(el) {
|
|
258
|
+
destroy(el);
|
|
259
|
+
el.classList.add(CSS_CLASS);
|
|
260
|
+
|
|
261
|
+
if (prefersReducedMotion()) {
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
ensureGooFilter();
|
|
266
|
+
const structure = ensureStructure(el);
|
|
267
|
+
setAccent(structure.container, el);
|
|
268
|
+
|
|
269
|
+
const state = {
|
|
270
|
+
...structure,
|
|
271
|
+
animations: [],
|
|
272
|
+
supportsWAAPI: hasWAAPI(),
|
|
273
|
+
onEnter: () => {},
|
|
274
|
+
onLeave: () => {},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
state.onEnter = () => {
|
|
278
|
+
playBurst(state);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
state.onLeave = () => {
|
|
282
|
+
resetState(state);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
state.container.addEventListener('mouseenter', state.onEnter);
|
|
286
|
+
state.container.addEventListener('mouseleave', state.onLeave);
|
|
287
|
+
state.container.classList.toggle(FALLBACK_CLASS, !state.supportsWAAPI);
|
|
288
|
+
stateMap.set(el, state);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function destroy(el) {
|
|
292
|
+
const state = stateMap.get(el);
|
|
293
|
+
if (state) {
|
|
294
|
+
state.container.removeEventListener('mouseenter', state.onEnter);
|
|
295
|
+
state.container.removeEventListener('mouseleave', state.onLeave);
|
|
296
|
+
resetState(state);
|
|
297
|
+
releaseGooFilter();
|
|
298
|
+
stateMap.delete(el);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
el.classList.remove(CSS_CLASS);
|
|
302
|
+
|
|
303
|
+
const container = el.parentElement?.classList.contains(CONTAINER_CLASS) ? el.parentElement : null;
|
|
304
|
+
if (container) {
|
|
305
|
+
container.classList.remove(ACTIVE_CLASS);
|
|
306
|
+
container.classList.remove(HOVER_CLASS);
|
|
307
|
+
container.classList.remove(FALLBACK_CLASS);
|
|
308
|
+
container.style.removeProperty('--readdy-anim-bubble-accent');
|
|
309
|
+
if (container.parentNode) {
|
|
310
|
+
container.parentNode.insertBefore(el, container);
|
|
311
|
+
} else {
|
|
312
|
+
container.removeChild(el);
|
|
313
|
+
}
|
|
314
|
+
container.remove();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export { ANIMATION_ID, destroy, init };
|