use-scroll-animate 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +31 -2
- package/README_ja.md +19 -0
- package/README_zh.md +30 -0
- package/dist/chunks/base-CJ7XfidP.cjs +233 -0
- package/dist/chunks/base-CJ7XfidP.cjs.map +1 -0
- package/dist/chunks/base-CuvCgqLy.js +219 -0
- package/dist/chunks/base-CuvCgqLy.js.map +1 -0
- package/dist/components/background.cjs +395 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +7 -0
- package/dist/components/background.d.cts +132 -0
- package/dist/components/background.d.ts +132 -0
- package/dist/components/background.js +387 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/feedback.cjs +444 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +170 -0
- package/dist/components/feedback.d.ts +170 -0
- package/dist/components/feedback.js +434 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/interaction.cjs +426 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +142 -0
- package/dist/components/interaction.d.ts +142 -0
- package/dist/components/interaction.js +417 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/physics.cjs +664 -0
- package/dist/components/physics.cjs.map +1 -0
- package/dist/components/physics.css +5 -0
- package/dist/components/physics.d.cts +216 -0
- package/dist/components/physics.d.ts +216 -0
- package/dist/components/physics.js +644 -0
- package/dist/components/physics.js.map +1 -0
- package/dist/components/reveal.cjs +360 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +132 -0
- package/dist/components/reveal.d.ts +132 -0
- package/dist/components/reveal.js +350 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/text.cjs +528 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +7 -0
- package/dist/components/text.d.cts +164 -0
- package/dist/components/text.d.ts +164 -0
- package/dist/components/text.js +517 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/transitions.cjs +546 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +6 -0
- package/dist/components/transitions.d.cts +180 -0
- package/dist/components/transitions.d.ts +180 -0
- package/dist/components/transitions.js +536 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components.cjs +127 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +33 -0
- package/dist/components.d.cts +919 -0
- package/dist/components.d.ts +919 -0
- package/dist/components.js +65 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +22 -0
- package/dist/components.umd.js.map +1 -0
- package/docs/API.md +2 -0
- package/docs/components.md +169 -0
- package/docs/windows-apps.md +108 -0
- package/package.json +105 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reveal.js","sources":["../../src/components/reveal/effects.ts","../../src/components/reveal/reveal.ts","../../src/components/reveal/stagger.ts","../../src/components/reveal/scroll-progress.ts","../../src/components/reveal/scrolly.ts","../../src/components/reveal/index.ts"],"sourcesContent":["/** Entrance effects shared by `<usa-reveal>` and `<usa-stagger>` (transform / opacity / filter only). */\n\nexport const REVEAL_EFFECTS = [\n 'fade',\n 'fade-up',\n 'fade-down',\n 'fade-left',\n 'fade-right',\n 'zoom-in',\n 'zoom-out',\n 'blur',\n 'blur-up',\n 'flip-up',\n 'flip-left',\n 'rise',\n] as const;\n\nexport type RevealEffect = (typeof REVEAL_EFFECTS)[number];\n\n/** The \"from\" keyframe of an effect; the \"to\" keyframe is the element's natural state. */\nexport function revealFrom(effect: string, distance = 32): Keyframe {\n const d = `${distance}px`;\n switch (effect) {\n case 'fade':\n return { opacity: 0 };\n case 'fade-down':\n return { opacity: 0, transform: `translate3d(0,-${d},0)` };\n case 'fade-left':\n return { opacity: 0, transform: `translate3d(-${d},0,0)` };\n case 'fade-right':\n return { opacity: 0, transform: `translate3d(${d},0,0)` };\n case 'zoom-in':\n return { opacity: 0, transform: 'scale(0.86)' };\n case 'zoom-out':\n return { opacity: 0, transform: 'scale(1.14)' };\n case 'blur':\n return { opacity: 0, filter: 'blur(12px)' };\n case 'blur-up':\n return { opacity: 0, filter: 'blur(10px)', transform: `translate3d(0,${d},0)` };\n case 'flip-up':\n return { opacity: 0, transform: 'perspective(800px) rotateX(-55deg)', transformOrigin: '50% 100%' };\n case 'flip-left':\n return { opacity: 0, transform: 'perspective(800px) rotateY(55deg)', transformOrigin: '0% 50%' };\n case 'rise':\n return { opacity: 0, transform: `translate3d(0,${distance * 1.5}px,0) scale(0.96)` };\n case 'fade-up':\n default:\n return { opacity: 0, transform: `translate3d(0,${d},0)` };\n }\n}\n\n/** Keyframes from the effect to the natural state. */\nexport function revealKeyframes(effect: string, distance?: number): Keyframe[] {\n const from = revealFrom(effect, distance);\n const to: Keyframe = {};\n for (const k of Object.keys(from)) {\n if (k === 'opacity') to.opacity = 1;\n else if (k === 'transform') to.transform = 'none';\n else if (k === 'filter') to.filter = 'none';\n else if (k === 'transformOrigin') to.transformOrigin = from.transformOrigin;\n }\n return [from, to];\n}\n","import { defineElement, EASE_OUT, type UsaElement } from '../base';\nimport { revealKeyframes, type RevealEffect } from './effects';\nimport css from './reveal.css?raw';\n\n/**\n * `<usa-reveal>` — reveals its content when it scrolls into view.\n *\n * Attributes: `effect` (see {@link RevealEffect}, default `fade-up`),\n * `duration` (ms, 700), `delay` (ms, 0), `distance` (px, 32), `easing`,\n * `threshold` (0–1, 0.15), `root-margin`, `repeat` (hide again when it\n * leaves, replay on re-entry). Events: `usa:enter`, `usa:leave`, `usa:complete`.\n */\nexport interface UsaRevealElement extends UsaElement {\n effect: RevealEffect | string;\n /** Play the entrance now (also called automatically on enter). */\n reveal(): Promise<void>;\n /** Hide again so the next `reveal()` replays the entrance. */\n reset(): void;\n readonly revealed: boolean;\n}\n\nexport function defineReveal(tag = 'usa-reveal'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaReveal extends Base {\n static get observedAttributes(): string[] {\n return ['effect', 'distance', 'repeat', 'threshold', 'root-margin'];\n }\n\n private _anim: Animation | null = null;\n\n get effect(): string {\n return this.str('effect', 'fade-up');\n }\n set effect(v: string) {\n this.setAttribute('effect', v);\n }\n get revealed(): boolean {\n return this.getAttribute('data-state') !== 'hidden';\n }\n\n mount(): void {\n if (this.reduced) {\n this.setAttribute('data-state', 'shown');\n return;\n }\n if (this.getAttribute('data-state') !== 'shown') this.setAttribute('data-state', 'hidden');\n this.inView(\n (visible) => {\n if (visible) {\n this.emit('enter');\n if (!this.revealed) this.reveal();\n } else {\n this.emit('leave');\n if (this.flag('repeat') && this.revealed) this.reset();\n }\n },\n { threshold: this.num('threshold', 0.15), rootMargin: this.str('root-margin', '0px') }\n );\n }\n\n unmount(): void {\n this._anim?.cancel();\n this._anim = null;\n }\n\n reveal(): Promise<void> {\n this._anim?.cancel();\n this.setAttribute('data-state', 'shown');\n if (this.reduced) return Promise.resolve();\n const a = this.motion(this, revealKeyframes(this.effect, this.num('distance', 32)), {\n duration: this.num('duration', 700),\n delay: this.num('delay', 0),\n easing: this.str('easing', EASE_OUT),\n fill: 'backwards',\n });\n this._anim = a;\n return new Promise((resolve) => {\n const done = () => {\n if (this._anim === a) this._anim = null;\n this.emit('complete');\n resolve();\n };\n if (!a) done();\n else a.onfinish = done;\n });\n }\n\n reset(): void {\n this._anim?.cancel();\n this._anim = null;\n if (!this.reduced) this.setAttribute('data-state', 'hidden');\n }\n },\n { id: 'reveal', text: css }\n );\n}\n","import { defineElement, EASE_OUT, type UsaElement } from '../base';\nimport { revealKeyframes } from './effects';\nimport css from './reveal.css?raw';\n\n/**\n * `<usa-stagger>` — reveals its direct children one after another when the\n * list scrolls into view.\n *\n * Attributes: `effect` (default `fade-up`), `interval` (ms between children,\n * 70), `duration` (600), `delay` (0), `distance` (24), `easing`,\n * `threshold` (0.1), `repeat`. Events: `usa:enter`, `usa:complete`.\n */\nexport interface UsaStaggerElement extends UsaElement {\n reveal(): Promise<void>;\n reset(): void;\n}\n\nexport function defineStagger(tag = 'usa-stagger'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaStagger extends Base {\n static get observedAttributes(): string[] {\n return ['effect', 'repeat', 'threshold'];\n }\n\n private _anims: Animation[] = [];\n\n mount(): void {\n if (this.reduced) {\n this.setAttribute('data-state', 'shown');\n return;\n }\n if (this.getAttribute('data-state') !== 'shown') this.setAttribute('data-state', 'hidden');\n this.inView(\n (visible) => {\n if (visible && this.getAttribute('data-state') === 'hidden') {\n this.emit('enter');\n this.reveal();\n } else if (!visible && this.flag('repeat')) this.reset();\n },\n { threshold: this.num('threshold', 0.1) }\n );\n }\n\n unmount(): void {\n this.cancel();\n }\n\n private cancel(): void {\n this._anims.splice(0).forEach((a) => a.cancel());\n }\n\n reveal(): Promise<void> {\n this.cancel();\n this.setAttribute('data-state', 'shown');\n const kids = Array.from(this.children) as HTMLElement[];\n if (this.reduced || !kids.length) return Promise.resolve();\n const frames = revealKeyframes(this.str('effect', 'fade-up'), this.num('distance', 24));\n const interval = this.num('interval', 70);\n const base = this.num('delay', 0);\n const duration = this.num('duration', 600);\n const easing = this.str('easing', EASE_OUT);\n const anims = kids\n .map((kid, i) => this.motion(kid, frames, { duration, easing, delay: base + i * interval, fill: 'backwards' }))\n .filter((a): a is Animation => !!a);\n this._anims = anims;\n const last = anims[anims.length - 1];\n return new Promise((resolve) => {\n const done = () => {\n this.emit('complete');\n resolve();\n };\n if (!last) done();\n else last.onfinish = done;\n });\n }\n\n reset(): void {\n this.cancel();\n if (!this.reduced) this.setAttribute('data-state', 'hidden');\n }\n },\n { id: 'reveal', text: css }\n );\n}\n","import { defineElement, raf, caf, clamp, type UsaElement } from '../base';\nimport css from './scroll-progress.css?raw';\n\n/**\n * `<usa-scroll-progress>` — a reading-progress bar.\n *\n * Attributes: `target` (CSS selector of an article to track; default the\n * whole page), `position` (`top` | `bottom` | `inline`, default `top`),\n * `label` (accessible name, default \"Reading progress\"). Style with\n * `--usa-progress-color`, `--usa-progress-height`, `--usa-progress-track`.\n * Exposes the progress (0–1) as `--usa-progress` on the element and as the\n * `progress` property. Event: `usa:progress` (`detail.progress`).\n *\n * Writes only `transform: scaleX()` (compositor-friendly); reads layout\n * once per animation frame, and only while scrolling.\n */\nexport interface UsaScrollProgressElement extends UsaElement {\n readonly progress: number;\n /** Re-measure (e.g. after content loaded). */\n update(): void;\n}\n\n/** Progress (0–1) of `target` scrolling through the viewport, or of the page. */\nexport function readScrollProgress(target?: Element | null): number {\n if (typeof window === 'undefined') return 0;\n const vh = window.innerHeight || document.documentElement.clientHeight;\n if (target) {\n const r = target.getBoundingClientRect();\n const total = r.height - vh;\n return total <= 0 ? (r.top <= 0 ? 1 : 0) : clamp(-r.top / total, 0, 1);\n }\n const doc = document.documentElement;\n const max = doc.scrollHeight - vh;\n return max <= 0 ? 0 : clamp((window.scrollY || doc.scrollTop) / max, 0, 1);\n}\n\nexport function defineScrollProgress(tag = 'usa-scroll-progress'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaScrollProgress extends Base {\n static get observedAttributes(): string[] {\n return ['target', 'label'];\n }\n\n private _bar: HTMLElement | null = null;\n private _p = -1;\n private _frame = 0;\n\n get progress(): number {\n return Math.max(0, this._p);\n }\n\n mount(): void {\n if (!this._bar) {\n this._bar = document.createElement('span');\n this._bar.className = 'usa-progress-fill';\n this.replaceChildren(this._bar);\n }\n this.setAttribute('role', 'progressbar');\n this.setAttribute('aria-valuemin', '0');\n this.setAttribute('aria-valuemax', '100');\n if (!this.hasAttribute('aria-label')) this.setAttribute('aria-label', this.str('label', 'Reading progress'));\n const schedule = () => {\n if (!this._frame) this._frame = raf(() => ((this._frame = 0), this.update()));\n };\n this.listen(window, 'scroll', schedule, { passive: true });\n this.listen(window, 'resize', schedule, { passive: true });\n this.update();\n }\n\n unmount(): void {\n caf(this._frame);\n this._frame = 0;\n }\n\n update(): void {\n const sel = this.getAttribute('target');\n const target = sel ? document.querySelector(sel) : null;\n const p = readScrollProgress(target);\n if (Math.abs(p - this._p) < 0.0005) return;\n this._p = p;\n if (this._bar) this._bar.style.transform = `scaleX(${p})`;\n this.style.setProperty('--usa-progress', String(p));\n const pct = String(Math.round(p * 100));\n if (this.getAttribute('aria-valuenow') !== pct) this.setAttribute('aria-valuenow', pct);\n this.emit('progress', { progress: p });\n }\n },\n { id: 'scroll-progress', text: css }\n );\n}\n","import { defineElement, clamp, type UsaElement } from '../base';\nimport css from './scrolly.css?raw';\n\n/**\n * `<usa-scrolly>` — sticky scrollytelling. A child marked `data-sticky`\n * stays pinned while the `[data-step]` children scroll past; the step that\n * crosses the trigger line becomes active.\n *\n * Attributes: `offset` (trigger line as a fraction of the viewport height,\n * default 0.5), `active` (reflected index of the active step). The active\n * step gets `data-active`; the host gets `--usa-step` and `data-step-name`\n * (the step's `data-step` value). Event: `usa:step` (`detail.index`,\n * `detail.step`, `detail.name`).\n */\nexport interface UsaScrollyElement extends UsaElement {\n readonly active: number;\n readonly steps: HTMLElement[];\n}\n\nexport function defineScrolly(tag = 'usa-scrolly'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaScrolly extends Base {\n static get observedAttributes(): string[] {\n return ['offset'];\n }\n\n private _active = -1;\n\n get active(): number {\n return this._active;\n }\n get steps(): HTMLElement[] {\n return Array.from(this.querySelectorAll<HTMLElement>('[data-step]'));\n }\n\n mount(): void {\n const steps = this.steps;\n if (!steps.length) return;\n const offset = clamp(this.num('offset', 0.5), 0, 1);\n // A thin trigger band `offset` down the viewport\n const top = Math.min(99, Math.round(offset * 100));\n const rootMargin = `-${top}% 0px -${Math.max(0, 99 - top)}% 0px`;\n if (typeof IntersectionObserver === 'undefined') {\n this.activate(0);\n return;\n }\n const io = new IntersectionObserver(\n (entries) => {\n for (const e of entries) if (e.isIntersecting) this.activate(steps.indexOf(e.target as HTMLElement));\n },\n { rootMargin }\n );\n steps.forEach((s) => io.observe(s));\n this.onCleanup(() => io.disconnect());\n if (this._active < 0) this.activate(0, true);\n }\n\n activate(index: number, silent = false): void {\n const steps = this.steps;\n if (index < 0 || index >= steps.length || index === this._active) return;\n this._active = index;\n steps.forEach((s, i) => s.toggleAttribute('data-active', i === index));\n const step = steps[index];\n this.setAttribute('active', String(index));\n this.style.setProperty('--usa-step', String(index));\n this.setAttribute('data-step-name', step.dataset.step || String(index));\n if (!silent) this.emit('step', { index, step, name: step.dataset.step || '' });\n }\n },\n { id: 'scrolly', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/reveal — entrance & scroll reveal components.\n * `<usa-reveal>`, `<usa-stagger>`, `<usa-scroll-progress>`, `<usa-scrolly>`.\n */\nimport { defineReveal, type UsaRevealElement } from './reveal';\nimport { defineStagger, type UsaStaggerElement } from './stagger';\nimport { defineScrollProgress, type UsaScrollProgressElement } from './scroll-progress';\nimport { defineScrolly, type UsaScrollyElement } from './scrolly';\n\nexport { defineReveal, defineStagger, defineScrollProgress, defineScrolly };\nexport { readScrollProgress } from './scroll-progress';\nexport { REVEAL_EFFECTS, revealKeyframes } from './effects';\nexport type { RevealEffect } from './effects';\nexport type { UsaRevealElement, UsaStaggerElement, UsaScrollProgressElement, UsaScrollyElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineRevealComponents(): void {\n defineReveal();\n defineStagger();\n defineScrollProgress();\n defineScrolly();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-reveal': UsaRevealElement;\n 'usa-stagger': UsaStaggerElement;\n 'usa-scroll-progress': UsaScrollProgressElement;\n 'usa-scrolly': UsaScrollyElement;\n }\n}\n"],"names":["css"],"mappings":";;;AAAA;AAEO,MAAM,cAAc,GAAG;IAC5B,MAAM;IACN,SAAS;IACT,WAAW;IACX,WAAW;IACX,YAAY;IACZ,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AAK,CAAC,CAAC;AAC1C,YAAA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AACnD,YAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACvE,YAAA,IAAI,CAAC,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;QAChF;KACD,EACH,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,CAC7B;AACH;;ACzEA;;;AAGG;AAcH;SACgB,sBAAsB,GAAA;AACpC,IAAA,YAAY,EAAE;AACd,IAAA,aAAa,EAAE;AACf,IAAA,oBAAoB,EAAE;AACtB,IAAA,aAAa,EAAE;AACjB;;;;"}
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../chunks/base-CJ7XfidP.cjs');
|
|
4
|
+
|
|
5
|
+
var css$4 = "usa-typewriter{white-space:pre-wrap}usa-typewriter .usa-tw-caret{display:inline-block;width:var(--usa-caret-width,0.08em);height:1.05em;margin-left:0.06em;vertical-align:-0.12em;background:var(--usa-caret-color,currentColor);animation:usa-caret 1.06s steps(1) infinite}usa-typewriter[data-typing] .usa-tw-caret{animation:none}usa-typewriter[data-no-cursor] .usa-tw-caret{display:none}@keyframes usa-caret{50%{opacity:0}}@media (prefers-reduced-motion:reduce){usa-typewriter .usa-tw-caret,usa-shimmer-text{animation:none}}";
|
|
6
|
+
|
|
7
|
+
function defineTypewriter(tag = 'usa-typewriter') {
|
|
8
|
+
return base.defineElement(tag, (Base) => class UsaTypewriter extends Base {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this._source = null;
|
|
12
|
+
this._out = null;
|
|
13
|
+
this._timer = 0;
|
|
14
|
+
this._running = false;
|
|
15
|
+
}
|
|
16
|
+
static get observedAttributes() {
|
|
17
|
+
return ['text', 'words'];
|
|
18
|
+
}
|
|
19
|
+
get phrases() {
|
|
20
|
+
const words = this.getAttribute('words');
|
|
21
|
+
if (words)
|
|
22
|
+
return words.split('|').map((w) => w.trim()).filter(Boolean);
|
|
23
|
+
return [this.getAttribute('text') ?? this._source ?? ''];
|
|
24
|
+
}
|
|
25
|
+
mount() {
|
|
26
|
+
if (this._source === null)
|
|
27
|
+
this._source = (this.textContent || '').trim();
|
|
28
|
+
const phrases = this.phrases;
|
|
29
|
+
const sr = base.srText(phrases.join(', '));
|
|
30
|
+
this._out = document.createElement('span');
|
|
31
|
+
this._out.className = 'usa-tw-text';
|
|
32
|
+
this._out.setAttribute('aria-hidden', 'true');
|
|
33
|
+
const caret = document.createElement('span');
|
|
34
|
+
caret.className = 'usa-tw-caret';
|
|
35
|
+
caret.setAttribute('aria-hidden', 'true');
|
|
36
|
+
this.replaceChildren(sr, this._out, caret);
|
|
37
|
+
this.toggleAttribute('data-no-cursor', this.getAttribute('cursor') === 'false');
|
|
38
|
+
if (this.reduced) {
|
|
39
|
+
this._out.textContent = phrases[0] || '';
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const start = this.str('start', 'view');
|
|
43
|
+
if (start === 'load')
|
|
44
|
+
this.start();
|
|
45
|
+
else if (start === 'view') {
|
|
46
|
+
this.inView((visible) => {
|
|
47
|
+
if (visible && !this._running && !this._out?.textContent)
|
|
48
|
+
this.start();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
unmount() {
|
|
53
|
+
this.stop();
|
|
54
|
+
}
|
|
55
|
+
stop() {
|
|
56
|
+
clearTimeout(this._timer);
|
|
57
|
+
this._timer = 0;
|
|
58
|
+
this._running = false;
|
|
59
|
+
this.removeAttribute('data-typing');
|
|
60
|
+
}
|
|
61
|
+
restart() {
|
|
62
|
+
this.stop();
|
|
63
|
+
if (this._out)
|
|
64
|
+
this._out.textContent = '';
|
|
65
|
+
this.start();
|
|
66
|
+
}
|
|
67
|
+
start() {
|
|
68
|
+
if (this._running || !this._out)
|
|
69
|
+
return;
|
|
70
|
+
const out = this._out;
|
|
71
|
+
const phrases = this.phrases;
|
|
72
|
+
if (this.reduced) {
|
|
73
|
+
out.textContent = phrases[0] || '';
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this._running = true;
|
|
77
|
+
const speed = this.num('speed', 55);
|
|
78
|
+
const del = this.num('delete-speed', 30);
|
|
79
|
+
const pause = this.num('pause', 1400);
|
|
80
|
+
const loop = this.flag('loop') || phrases.length > 1;
|
|
81
|
+
let p = 0;
|
|
82
|
+
let i = 0;
|
|
83
|
+
let deleting = false;
|
|
84
|
+
const tick = () => {
|
|
85
|
+
const word = phrases[p] || '';
|
|
86
|
+
if (!deleting) {
|
|
87
|
+
i++;
|
|
88
|
+
out.textContent = word.slice(0, i);
|
|
89
|
+
this.setAttribute('data-typing', '');
|
|
90
|
+
if (i >= word.length) {
|
|
91
|
+
this.removeAttribute('data-typing');
|
|
92
|
+
const last = p === phrases.length - 1;
|
|
93
|
+
if (last)
|
|
94
|
+
this.emit('complete');
|
|
95
|
+
if (!loop && last) {
|
|
96
|
+
this._running = false;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
deleting = true;
|
|
100
|
+
this._timer = setTimeout(tick, pause);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this._timer = setTimeout(tick, speed * (0.6 + Math.random() * 0.8));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
i--;
|
|
107
|
+
out.textContent = word.slice(0, Math.max(0, i));
|
|
108
|
+
if (i <= 0) {
|
|
109
|
+
deleting = false;
|
|
110
|
+
p = (p + 1) % phrases.length;
|
|
111
|
+
this._timer = setTimeout(tick, speed * 4);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._timer = setTimeout(tick, del);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
this._timer = setTimeout(tick, this.num('delay', 0));
|
|
118
|
+
}
|
|
119
|
+
}, { id: 'typewriter', text: css$4 });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var css$3 = "usa-split-text .usa-split-word{display:inline-block;white-space:nowrap}usa-split-text .usa-split-unit{display:inline-block;white-space:pre}usa-split-text[data-state=\"hidden\"] .usa-split-unit{opacity:0}usa-split-text[data-state=\"play\"] .usa-split-unit{animation:usa-split-rise var(--usa-split-duration,620ms) cubic-bezier(0.22,1,0.36,1) both;animation-delay:calc(var(--usa-split-delay,0ms) + var(--i,0) * var(--usa-split-stagger,28ms))}usa-split-text[effect=\"fade\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-fade}usa-split-text[effect=\"blur\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-blur}usa-split-text[effect=\"flip\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-flip;transform-origin:50% 100%}usa-split-text[effect=\"pop\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-pop;animation-timing-function:cubic-bezier(0.34,1.56,0.64,1)}@keyframes usa-split-rise{from{opacity:0;transform:translate3d(0,0.6em,0)}to{opacity:1;transform:none}}@keyframes usa-split-fade{from{opacity:0}to{opacity:1}}@keyframes usa-split-blur{from{opacity:0;filter:blur(8px)}to{opacity:1;filter:none}}@keyframes usa-split-flip{from{opacity:0;transform:perspective(500px) rotateX(-80deg)}to{opacity:1;transform:none}}@keyframes usa-split-pop{from{opacity:0;transform:scale(0.3)}to{opacity:1;transform:none}}@media (prefers-reduced-motion:reduce){usa-split-text .usa-split-unit{animation:none !important;opacity:1 !important}}";
|
|
123
|
+
|
|
124
|
+
function defineSplitText(tag = 'usa-split-text') {
|
|
125
|
+
return base.defineElement(tag, (Base) => class UsaSplitText extends Base {
|
|
126
|
+
constructor() {
|
|
127
|
+
super(...arguments);
|
|
128
|
+
this._source = null;
|
|
129
|
+
this._timer = 0;
|
|
130
|
+
}
|
|
131
|
+
static get observedAttributes() {
|
|
132
|
+
return ['by', 'text'];
|
|
133
|
+
}
|
|
134
|
+
get units() {
|
|
135
|
+
return Array.from(this.querySelectorAll('.usa-split-unit'));
|
|
136
|
+
}
|
|
137
|
+
mount() {
|
|
138
|
+
if (this._source === null)
|
|
139
|
+
this._source = this.getAttribute('text') ?? (this.textContent || '').replace(/\s+/g, ' ').trim();
|
|
140
|
+
const text = this.getAttribute('text') ?? this._source;
|
|
141
|
+
const byWords = this.str('by', 'chars') === 'words';
|
|
142
|
+
const frag = document.createDocumentFragment();
|
|
143
|
+
frag.append(base.srText(text));
|
|
144
|
+
let i = 0;
|
|
145
|
+
text.split(' ').forEach((word, w) => {
|
|
146
|
+
if (w > 0)
|
|
147
|
+
frag.append(' ');
|
|
148
|
+
const wordEl = document.createElement('span');
|
|
149
|
+
wordEl.className = 'usa-split-word';
|
|
150
|
+
wordEl.setAttribute('aria-hidden', 'true');
|
|
151
|
+
const parts = byWords ? [word] : Array.from(word);
|
|
152
|
+
for (const part of parts) {
|
|
153
|
+
const u = document.createElement('span');
|
|
154
|
+
u.className = 'usa-split-unit';
|
|
155
|
+
u.textContent = part;
|
|
156
|
+
u.style.setProperty('--i', String(i++));
|
|
157
|
+
wordEl.append(u);
|
|
158
|
+
}
|
|
159
|
+
frag.append(wordEl);
|
|
160
|
+
});
|
|
161
|
+
this.replaceChildren(frag);
|
|
162
|
+
this.style.setProperty('--usa-split-stagger', `${this.num('stagger', byWords ? 70 : 28)}ms`);
|
|
163
|
+
this.style.setProperty('--usa-split-duration', `${this.num('duration', 620)}ms`);
|
|
164
|
+
this.style.setProperty('--usa-split-delay', `${this.num('delay', 0)}ms`);
|
|
165
|
+
this.style.setProperty('--usa-split-count', String(i));
|
|
166
|
+
if (this.reduced) {
|
|
167
|
+
this.setAttribute('data-state', 'shown');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
this.setAttribute('data-state', 'hidden');
|
|
171
|
+
const trigger = this.str('trigger', 'view');
|
|
172
|
+
if (trigger === 'load')
|
|
173
|
+
this.play();
|
|
174
|
+
else if (trigger === 'view') {
|
|
175
|
+
this.inView((visible) => {
|
|
176
|
+
if (visible && this.getAttribute('data-state') === 'hidden')
|
|
177
|
+
this.play();
|
|
178
|
+
else if (!visible && this.flag('repeat'))
|
|
179
|
+
this.reset();
|
|
180
|
+
}, { threshold: 0.2 });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
unmount() {
|
|
184
|
+
clearTimeout(this._timer);
|
|
185
|
+
}
|
|
186
|
+
play() {
|
|
187
|
+
clearTimeout(this._timer);
|
|
188
|
+
if (this.reduced) {
|
|
189
|
+
this.setAttribute('data-state', 'shown');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
// Restart the CSS animations
|
|
193
|
+
this.setAttribute('data-state', 'hidden');
|
|
194
|
+
void this.offsetWidth;
|
|
195
|
+
this.setAttribute('data-state', 'play');
|
|
196
|
+
const n = this.units.length;
|
|
197
|
+
const total = this.num('delay', 0) + this.num('duration', 620) + Math.max(0, n - 1) * this.num('stagger', this.str('by') === 'words' ? 70 : 28);
|
|
198
|
+
this._timer = setTimeout(() => {
|
|
199
|
+
this.setAttribute('data-state', 'shown');
|
|
200
|
+
this.emit('complete');
|
|
201
|
+
}, total);
|
|
202
|
+
}
|
|
203
|
+
reset() {
|
|
204
|
+
clearTimeout(this._timer);
|
|
205
|
+
this.setAttribute('data-state', this.reduced ? 'shown' : 'hidden');
|
|
206
|
+
}
|
|
207
|
+
}, { id: 'split-text', text: css$3 });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const GLYPHS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*+=<>/\\?!';
|
|
211
|
+
/** One frame of the scramble: the first `progress` share is resolved. */
|
|
212
|
+
function scrambleFrame(text, progress, glyphs = GLYPHS, rnd = Math.random) {
|
|
213
|
+
const done = Math.floor(text.length * progress);
|
|
214
|
+
let out = '';
|
|
215
|
+
for (let i = 0; i < text.length; i++) {
|
|
216
|
+
const ch = text[i];
|
|
217
|
+
out += i < done || /\s|[.,:;!?'"()\-–—]/.test(ch) ? ch : glyphs[Math.floor(rnd() * glyphs.length)];
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
function defineScramble(tag = 'usa-scramble') {
|
|
222
|
+
return base.defineElement(tag, (Base) => class UsaScramble extends Base {
|
|
223
|
+
constructor() {
|
|
224
|
+
super(...arguments);
|
|
225
|
+
this._source = null;
|
|
226
|
+
this._out = null;
|
|
227
|
+
this._frame = 0;
|
|
228
|
+
}
|
|
229
|
+
static get observedAttributes() {
|
|
230
|
+
return ['text'];
|
|
231
|
+
}
|
|
232
|
+
get text() {
|
|
233
|
+
return this.getAttribute('text') ?? this._source ?? '';
|
|
234
|
+
}
|
|
235
|
+
mount() {
|
|
236
|
+
if (this._source === null)
|
|
237
|
+
this._source = (this.textContent || '').trim();
|
|
238
|
+
this._out = document.createElement('span');
|
|
239
|
+
this._out.setAttribute('aria-hidden', 'true');
|
|
240
|
+
this._out.textContent = this.text;
|
|
241
|
+
this.replaceChildren(base.srText(this.text), this._out);
|
|
242
|
+
if (this.reduced)
|
|
243
|
+
return;
|
|
244
|
+
const trigger = this.str('trigger', 'view');
|
|
245
|
+
if (trigger === 'load')
|
|
246
|
+
this.play();
|
|
247
|
+
else if (trigger === 'hover') {
|
|
248
|
+
this.listen(this, 'pointerenter', () => this.play());
|
|
249
|
+
this.listen(this, 'focusin', () => this.play());
|
|
250
|
+
}
|
|
251
|
+
else if (trigger === 'view') {
|
|
252
|
+
let played = false;
|
|
253
|
+
this.inView((v) => {
|
|
254
|
+
if (v && !played) {
|
|
255
|
+
played = true;
|
|
256
|
+
this.play();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
unmount() {
|
|
262
|
+
base.caf(this._frame);
|
|
263
|
+
this._frame = 0;
|
|
264
|
+
}
|
|
265
|
+
play() {
|
|
266
|
+
base.caf(this._frame);
|
|
267
|
+
const out = this._out;
|
|
268
|
+
const text = this.text;
|
|
269
|
+
if (!out || this.reduced) {
|
|
270
|
+
if (out)
|
|
271
|
+
out.textContent = text;
|
|
272
|
+
return Promise.resolve();
|
|
273
|
+
}
|
|
274
|
+
const duration = this.num('duration', 900);
|
|
275
|
+
const glyphs = this.str('chars', GLYPHS) || GLYPHS;
|
|
276
|
+
const t0 = base.now();
|
|
277
|
+
let last = -1;
|
|
278
|
+
return new Promise((resolve) => {
|
|
279
|
+
const step = () => {
|
|
280
|
+
const p = Math.min(1, Math.max(0, base.now() - t0) / duration);
|
|
281
|
+
// ~30 fps glyph churn is plenty and halves DOM writes
|
|
282
|
+
const bucket = Math.floor(p * duration / 33);
|
|
283
|
+
if (bucket !== last || p === 1) {
|
|
284
|
+
last = bucket;
|
|
285
|
+
out.textContent = p === 1 ? text : scrambleFrame(text, p, glyphs);
|
|
286
|
+
}
|
|
287
|
+
if (p < 1)
|
|
288
|
+
this._frame = base.raf(step);
|
|
289
|
+
else {
|
|
290
|
+
this._frame = 0;
|
|
291
|
+
this.emit('complete');
|
|
292
|
+
resolve();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
this._frame = base.raf(step);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}, undefined);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
var css$2 = "usa-counter{font-variant-numeric:tabular-nums}";
|
|
302
|
+
|
|
303
|
+
/** easeOutExpo */
|
|
304
|
+
const easeOutExpo = (t) => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t));
|
|
305
|
+
function defineCounter(tag = 'usa-counter') {
|
|
306
|
+
return base.defineElement(tag, (Base) => class UsaCounter extends Base {
|
|
307
|
+
constructor() {
|
|
308
|
+
super(...arguments);
|
|
309
|
+
this._current = NaN;
|
|
310
|
+
this._target = NaN;
|
|
311
|
+
this._frame = 0;
|
|
312
|
+
this._fmt = null;
|
|
313
|
+
}
|
|
314
|
+
static get observedAttributes() {
|
|
315
|
+
return ['to', 'decimals', 'locale', 'prefix', 'suffix', 'grouping'];
|
|
316
|
+
}
|
|
317
|
+
get value() {
|
|
318
|
+
return Number.isNaN(this._target) ? this.num('to', 0) : this._target;
|
|
319
|
+
}
|
|
320
|
+
set value(v) {
|
|
321
|
+
this.play(Number(v));
|
|
322
|
+
}
|
|
323
|
+
format(n) {
|
|
324
|
+
if (!this._fmt) {
|
|
325
|
+
const d = Math.max(0, Math.min(20, this.num('decimals', 0)));
|
|
326
|
+
const locale = this.getAttribute('locale') || (typeof document !== 'undefined' && document.documentElement.lang) || undefined;
|
|
327
|
+
try {
|
|
328
|
+
this._fmt = new Intl.NumberFormat(locale, { minimumFractionDigits: d, maximumFractionDigits: d, useGrouping: this.getAttribute('grouping') !== 'false' });
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
this._fmt = new Intl.NumberFormat(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return `${this.str('prefix')}${this._fmt.format(n)}${this.str('suffix')}`;
|
|
335
|
+
}
|
|
336
|
+
render(n) {
|
|
337
|
+
this._current = n;
|
|
338
|
+
this.textContent = this.format(n);
|
|
339
|
+
}
|
|
340
|
+
changed(name) {
|
|
341
|
+
this._fmt = null;
|
|
342
|
+
if (name === 'to')
|
|
343
|
+
this.play();
|
|
344
|
+
else
|
|
345
|
+
this.render(Number.isNaN(this._current) ? this.num('from', 0) : this._current);
|
|
346
|
+
}
|
|
347
|
+
mount() {
|
|
348
|
+
this._fmt = null;
|
|
349
|
+
const to = this.num('to', 0);
|
|
350
|
+
if (this.reduced) {
|
|
351
|
+
this._target = to;
|
|
352
|
+
this.render(to);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (Number.isNaN(this._current))
|
|
356
|
+
this.render(this.num('from', 0));
|
|
357
|
+
const start = this.str('start', 'view');
|
|
358
|
+
if (start === 'load')
|
|
359
|
+
this.play();
|
|
360
|
+
else if (start === 'view') {
|
|
361
|
+
let done = false;
|
|
362
|
+
this.inView((v) => {
|
|
363
|
+
if (v && !done) {
|
|
364
|
+
done = true;
|
|
365
|
+
this.play();
|
|
366
|
+
}
|
|
367
|
+
}, { threshold: 0.4 });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
unmount() {
|
|
371
|
+
base.caf(this._frame);
|
|
372
|
+
this._frame = 0;
|
|
373
|
+
}
|
|
374
|
+
play(to = this.num('to', 0)) {
|
|
375
|
+
base.caf(this._frame);
|
|
376
|
+
this._target = to;
|
|
377
|
+
const from = Number.isNaN(this._current) ? this.num('from', 0) : this._current;
|
|
378
|
+
if (this.reduced || from === to || !this.isConnected) {
|
|
379
|
+
this.render(to);
|
|
380
|
+
this.emit('complete', { value: to });
|
|
381
|
+
return Promise.resolve();
|
|
382
|
+
}
|
|
383
|
+
const duration = this.num('duration', 1600);
|
|
384
|
+
const t0 = base.now();
|
|
385
|
+
return new Promise((resolve) => {
|
|
386
|
+
const step = () => {
|
|
387
|
+
const t = Math.min(1, Math.max(0, base.now() - t0) / duration);
|
|
388
|
+
this.render(from + (to - from) * easeOutExpo(t));
|
|
389
|
+
if (t < 1)
|
|
390
|
+
this._frame = base.raf(step);
|
|
391
|
+
else {
|
|
392
|
+
this._frame = 0;
|
|
393
|
+
this.render(to);
|
|
394
|
+
this.emit('complete', { value: to });
|
|
395
|
+
resolve();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
this._frame = base.raf(step);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}, { id: 'counter', text: css$2 });
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
var css$1 = "usa-shimmer-text{--usa-shimmer-color:currentColor;--usa-shimmer-shine:#fff;background:linear-gradient(var(--usa-shimmer-angle,110deg),var(--usa-shimmer-color) 35%,var(--usa-shimmer-shine) 50%,var(--usa-shimmer-color) 65%) 0 0 / 250% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent;animation:usa-shimmer var(--usa-shimmer-duration,2600ms) linear infinite}@keyframes usa-shimmer{from{background-position:100% 0}to{background-position:-150% 0}}";
|
|
405
|
+
|
|
406
|
+
function defineShimmerText(tag = 'usa-shimmer-text') {
|
|
407
|
+
return base.defineElement(tag, (Base) => class UsaShimmerText extends Base {
|
|
408
|
+
static get observedAttributes() {
|
|
409
|
+
return ['duration', 'color', 'shine', 'angle'];
|
|
410
|
+
}
|
|
411
|
+
mount() {
|
|
412
|
+
const set = (attr, prop, unit = '') => {
|
|
413
|
+
const v = this.getAttribute(attr);
|
|
414
|
+
if (v !== null)
|
|
415
|
+
this.style.setProperty(prop, v + unit);
|
|
416
|
+
else
|
|
417
|
+
this.style.removeProperty(prop);
|
|
418
|
+
};
|
|
419
|
+
set('duration', '--usa-shimmer-duration', 'ms');
|
|
420
|
+
set('color', '--usa-shimmer-color');
|
|
421
|
+
set('shine', '--usa-shimmer-shine');
|
|
422
|
+
set('angle', '--usa-shimmer-angle', 'deg');
|
|
423
|
+
}
|
|
424
|
+
}, { id: 'shimmer-text', text: css$1 });
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var css = "usa-text-rotate{display:inline-grid;vertical-align:bottom;overflow:hidden;padding-block:0.08em}usa-text-rotate .usa-rotate-word{grid-area:1 / 1;white-space:nowrap}usa-text-rotate .usa-rotate-word[data-hidden]{opacity:0}";
|
|
428
|
+
|
|
429
|
+
function defineTextRotate(tag = 'usa-text-rotate') {
|
|
430
|
+
return base.defineElement(tag, (Base) => class UsaTextRotate extends Base {
|
|
431
|
+
constructor() {
|
|
432
|
+
super(...arguments);
|
|
433
|
+
this._source = null;
|
|
434
|
+
this._index = 0;
|
|
435
|
+
this._timer = 0;
|
|
436
|
+
this._visible = true;
|
|
437
|
+
}
|
|
438
|
+
static get observedAttributes() {
|
|
439
|
+
return ['words', 'interval', 'paused'];
|
|
440
|
+
}
|
|
441
|
+
get index() {
|
|
442
|
+
return this._index;
|
|
443
|
+
}
|
|
444
|
+
get words() {
|
|
445
|
+
return (this.getAttribute('words') ?? this._source ?? '').split('|').map((w) => w.trim()).filter(Boolean);
|
|
446
|
+
}
|
|
447
|
+
mount() {
|
|
448
|
+
if (this._source === null)
|
|
449
|
+
this._source = (this.textContent || '').trim();
|
|
450
|
+
const words = this.words;
|
|
451
|
+
this.replaceChildren(base.srText(words.join(', ')), ...words.map((w, i) => {
|
|
452
|
+
const s = document.createElement('span');
|
|
453
|
+
s.className = 'usa-rotate-word';
|
|
454
|
+
s.textContent = w;
|
|
455
|
+
s.setAttribute('aria-hidden', 'true');
|
|
456
|
+
if (i !== this._index)
|
|
457
|
+
s.setAttribute('data-hidden', '');
|
|
458
|
+
return s;
|
|
459
|
+
}));
|
|
460
|
+
if (this._index >= words.length)
|
|
461
|
+
this._index = 0;
|
|
462
|
+
if (words.length < 2)
|
|
463
|
+
return;
|
|
464
|
+
this.inView((v) => (this._visible = v));
|
|
465
|
+
if (!this.flag('paused')) {
|
|
466
|
+
this._timer = setInterval(() => {
|
|
467
|
+
if (this._visible && !(typeof document !== 'undefined' && document.hidden))
|
|
468
|
+
this.next();
|
|
469
|
+
}, Math.max(400, this.num('interval', 2200)));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
unmount() {
|
|
473
|
+
clearInterval(this._timer);
|
|
474
|
+
this._timer = 0;
|
|
475
|
+
}
|
|
476
|
+
next() {
|
|
477
|
+
const els = Array.from(this.querySelectorAll('.usa-rotate-word'));
|
|
478
|
+
if (els.length < 2)
|
|
479
|
+
return;
|
|
480
|
+
const prev = els[this._index];
|
|
481
|
+
this._index = (this._index + 1) % els.length;
|
|
482
|
+
const cur = els[this._index];
|
|
483
|
+
prev.setAttribute('data-hidden', '');
|
|
484
|
+
cur.removeAttribute('data-hidden');
|
|
485
|
+
const effect = this.reduced ? 'fade' : this.str('effect', 'slide');
|
|
486
|
+
const [inFrom, outTo] = effect === 'fade'
|
|
487
|
+
? [{ opacity: 0 }, { opacity: 0 }]
|
|
488
|
+
: effect === 'flip'
|
|
489
|
+
? [{ opacity: 0, transform: 'perspective(400px) rotateX(-90deg)' }, { opacity: 0, transform: 'perspective(400px) rotateX(90deg)' }]
|
|
490
|
+
: effect === 'blur'
|
|
491
|
+
? [{ opacity: 0, filter: 'blur(8px)' }, { opacity: 0, filter: 'blur(8px)' }]
|
|
492
|
+
: [{ opacity: 0, transform: 'translateY(0.8em)' }, { opacity: 0, transform: 'translateY(-0.8em)' }];
|
|
493
|
+
const neutral = { opacity: 1, transform: 'none', filter: 'none' };
|
|
494
|
+
const pick = (f) => Object.fromEntries(Object.keys(f).map((k) => [k, neutral[k]]));
|
|
495
|
+
this.motion(prev, [{ ...pick(outTo) }, outTo], { duration: 380, easing: base.EASE_OUT });
|
|
496
|
+
this.motion(cur, [inFrom, pick(inFrom)], { duration: 520, easing: effect === 'slide' ? base.EASE_SPRING : base.EASE_OUT });
|
|
497
|
+
this.emit('change', { index: this._index, word: cur.textContent });
|
|
498
|
+
}
|
|
499
|
+
}, { id: 'text-rotate', text: css });
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* use-scroll-animate/components/text — text effects.
|
|
504
|
+
* `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
|
|
505
|
+
* `<usa-shimmer-text>`, `<usa-text-rotate>`.
|
|
506
|
+
*/
|
|
507
|
+
/** Register every component of this category under its default tag. */
|
|
508
|
+
function defineTextComponents() {
|
|
509
|
+
defineTypewriter();
|
|
510
|
+
defineSplitText();
|
|
511
|
+
defineScramble();
|
|
512
|
+
defineCounter();
|
|
513
|
+
defineShimmerText();
|
|
514
|
+
defineTextRotate();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
exports.configureComponents = base.configureComponents;
|
|
518
|
+
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
519
|
+
exports.defineCounter = defineCounter;
|
|
520
|
+
exports.defineScramble = defineScramble;
|
|
521
|
+
exports.defineShimmerText = defineShimmerText;
|
|
522
|
+
exports.defineSplitText = defineSplitText;
|
|
523
|
+
exports.defineTextComponents = defineTextComponents;
|
|
524
|
+
exports.defineTextRotate = defineTextRotate;
|
|
525
|
+
exports.defineTypewriter = defineTypewriter;
|
|
526
|
+
exports.easeOutExpo = easeOutExpo;
|
|
527
|
+
exports.scrambleFrame = scrambleFrame;
|
|
528
|
+
//# sourceMappingURL=text.cjs.map
|