use-scroll-animate 4.1.0 → 4.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 +20 -0
- package/dist/chunks/{core-CLu8ZrC-.cjs → core-BRIIoKeS.cjs} +4 -3
- package/dist/chunks/core-BRIIoKeS.cjs.map +1 -0
- package/dist/chunks/{core-QTFk4kgO.js → core-LkGRmgES.js} +4 -3
- package/dist/chunks/core-LkGRmgES.js.map +1 -0
- package/dist/components/angular.cjs +2 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +80 -76
- package/dist/components/angular.d.ts +80 -76
- package/dist/components/angular.js +2 -1
- package/dist/components/angular.js.map +1 -1
- package/dist/components/solid.cjs +2 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +80 -76
- package/dist/components/solid.d.ts +80 -76
- package/dist/components/solid.js +2 -1
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +2 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +80 -76
- package/dist/components/svelte.d.ts +80 -76
- package/dist/components/svelte.js +2 -1
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/text.cjs +283 -10
- package/dist/components/text.cjs.map +1 -1
- package/dist/components/text.d.cts +156 -3
- package/dist/components/text.d.ts +156 -3
- package/dist/components/text.js +278 -11
- package/dist/components/text.js.map +1 -1
- package/dist/components/timeline.cjs +2 -1
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.d.cts +3 -3
- package/dist/components/timeline.d.ts +3 -3
- package/dist/components/timeline.js +3 -2
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/vue.cjs +2 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +80 -76
- package/dist/components/vue.d.ts +80 -76
- package/dist/components/vue.js +2 -1
- package/dist/components/vue.js.map +1 -1
- package/dist/components.cjs +22 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +258 -108
- package/dist/components.d.ts +258 -108
- package/dist/components.js +3 -2
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/package.json +11 -1
- package/dist/chunks/core-CLu8ZrC-.cjs.map +0 -1
- package/dist/chunks/core-QTFk4kgO.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sources":["../../src/components/tokens/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/tokens — motion design tokens (4.2).\n *\n * One source of truth for durations, easings and springs: as CSS custom\n * properties (`--usa-duration-fast`, `--usa-easing-emphasized`,\n * `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable\n * from Figma Tokens (Tokens Studio) or Style Dictionary exports.\n *\n * ```ts\n * import { applyMotionTokens, importMotionTokens, motionToken } from 'use-scroll-animate/components/tokens';\n * applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));\n * el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });\n * ```\n */\n\nexport interface SpringToken {\n stiffness: number;\n damping: number;\n mass: number;\n}\n\nexport interface MotionTokens {\n /** Durations in ms. */\n duration: Record<string, number>;\n /** CSS easing strings. */\n easing: Record<string, string>;\n /** Spring physics parameters. */\n spring: Record<string, SpringToken>;\n}\n\n/** The default motion scale (Material / Fluent-inspired). */\nexport const MOTION_TOKENS: MotionTokens = {\n duration: { instant: 0, fast: 150, normal: 300, slow: 600, slower: 900, slowest: 1400 },\n easing: {\n linear: 'linear',\n standard: 'cubic-bezier(0.2, 0, 0, 1)',\n emphasized: 'cubic-bezier(0.22, 1, 0.36, 1)',\n decelerate: 'cubic-bezier(0, 0, 0, 1)',\n accelerate: 'cubic-bezier(0.3, 0, 1, 1)',\n spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)',\n bounce: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',\n },\n spring: {\n gentle: { stiffness: 120, damping: 14, mass: 1 },\n snappy: { stiffness: 300, damping: 30, mass: 1 },\n bouncy: { stiffness: 260, damping: 12, mass: 1 },\n wobbly: { stiffness: 180, damping: 8, mass: 1 },\n stiff: { stiffness: 500, damping: 40, mass: 1 },\n },\n};\n\nexport type MotionTokenGroup = keyof MotionTokens;\nexport type DeepPartialTokens = { [K in keyof MotionTokens]?: Partial<MotionTokens[K]> };\n\nlet active: MotionTokens = clone(MOTION_TOKENS);\n\nfunction clone(t: MotionTokens): MotionTokens {\n return { duration: { ...t.duration }, easing: { ...t.easing }, spring: Object.fromEntries(Object.entries(t.spring).map(([k, v]) => [k, { ...v }])) };\n}\n\n/** Merge partial tokens over a base (defaults: the built-in scale). */\nexport function mergeMotionTokens(partial: DeepPartialTokens, base: MotionTokens = MOTION_TOKENS): MotionTokens {\n const out = clone(base);\n Object.assign(out.duration, partial.duration || {});\n Object.assign(out.easing, partial.easing || {});\n for (const [k, v] of Object.entries(partial.spring || {})) out.spring[k] = { ...(out.spring[k] || { stiffness: 170, damping: 26, mass: 1 }), ...v };\n return out;\n}\n\nconst kebab = (s: string) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/[\\s_.]+/g, '-').toLowerCase();\n\n/** The custom-property map: `{ '--usa-duration-fast': '150ms', … }`. */\nexport function motionTokensToVars(tokens: MotionTokens = active, prefix = '--usa'): Record<string, string> {\n const vars: Record<string, string> = {};\n for (const [k, v] of Object.entries(tokens.duration)) vars[`${prefix}-duration-${kebab(k)}`] = `${v}ms`;\n for (const [k, v] of Object.entries(tokens.easing)) vars[`${prefix}-easing-${kebab(k)}`] = v;\n for (const [k, v] of Object.entries(tokens.spring)) {\n vars[`${prefix}-spring-${kebab(k)}-stiffness`] = String(v.stiffness);\n vars[`${prefix}-spring-${kebab(k)}-damping`] = String(v.damping);\n vars[`${prefix}-spring-${kebab(k)}-mass`] = String(v.mass);\n }\n return vars;\n}\n\n/** A stylesheet string: `:root { --usa-duration-fast: 150ms; … }`. */\nexport function motionTokensToCss(tokens: MotionTokens = active, selector = ':root', prefix = '--usa'): string {\n const body = Object.entries(motionTokensToVars(tokens, prefix)).map(([k, v]) => ` ${k}: ${v};`).join('\\n');\n return `${selector} {\\n${body}\\n}\\n`;\n}\n\n/** W3C Design Tokens (DTCG) JSON: `{ motion: { duration: { fast: { $type: 'duration', $value: '150ms' } } } }`. */\nexport function motionTokensToJSON(tokens: MotionTokens = active): Record<string, unknown> {\n const grp = <T>(o: Record<string, T>, f: (v: T) => unknown) => Object.fromEntries(Object.entries(o).map(([k, v]) => [k, f(v)]));\n return {\n motion: {\n duration: grp(tokens.duration, (v) => ({ $type: 'duration', $value: `${v}ms` })),\n easing: grp(tokens.easing, (v) => {\n const m = /^cubic-bezier\\(([^)]+)\\)$/.exec(v);\n return m ? { $type: 'cubicBezier', $value: m[1].split(',').map(Number) } : { $type: 'string', $value: v };\n }),\n spring: grp(tokens.spring, (v) => ({ $type: 'spring', $value: { ...v } })),\n },\n };\n}\n\n/** Parse `150ms`, `0.15s`, `150` → ms. */\nexport function parseDuration(v: unknown): number | undefined {\n if (typeof v === 'number' && isFinite(v)) return v;\n if (typeof v === 'object' && v && 'value' in (v as any) && 'unit' in (v as any)) return parseDuration(`${(v as any).value}${(v as any).unit}`);\n const m = /^\\s*(-?\\d*\\.?\\d+)\\s*(ms|s)?\\s*$/.exec(String(v ?? ''));\n if (!m) return undefined;\n return m[2] === 's' ? Number(m[1]) * 1000 : Number(m[1]);\n}\n\n/** Parse `[x1,y1,x2,y2]`, `'cubic-bezier(…)'`, `'0.2, 0, 0, 1'` or a keyword → CSS easing. */\nexport function parseEasing(v: unknown): string | undefined {\n if (Array.isArray(v) && v.length === 4 && v.every((n) => typeof n === 'number')) return `cubic-bezier(${v.join(', ')})`;\n if (typeof v !== 'string' || !v.trim()) return undefined;\n const s = v.trim();\n if (/^-?\\d*\\.?\\d+(\\s*,\\s*-?\\d*\\.?\\d+){3}$/.test(s)) return `cubic-bezier(${s.split(/\\s*,\\s*/).join(', ')})`;\n return s;\n}\n\nconst isLeaf = (o: any) => o && typeof o === 'object' && ('$value' in o || 'value' in o);\nconst leafValue = (o: any) => ('$value' in o ? o.$value : o.value);\nconst leafType = (o: any) => String(o.$type ?? o.type ?? '').toLowerCase();\n\n/**\n * Import tokens from W3C DTCG JSON, Figma Tokens / Tokens Studio\n * (`{ value, type }`) or Style Dictionary (`{ value }`, nested) — anything\n * under a `duration` / `easing` / `spring` group (any depth, e.g.\n * `motion.duration.fast` or `global.animation.easing.out`), or typed leaves\n * (`duration`, `cubicBezier`, `transition`, `spring`). Unknown values are\n * skipped; the result is merged over the defaults.\n */\nexport function importMotionTokens(json: unknown, base: MotionTokens = MOTION_TOKENS): MotionTokens {\n const partial: Required<DeepPartialTokens> = { duration: {}, easing: {}, spring: {} };\n const walk = (node: any, path: string[]) => {\n if (!node || typeof node !== 'object') return;\n if (isLeaf(node)) {\n const name = path[path.length - 1];\n const type = leafType(node);\n const group = path.slice(0, -1).map((p) => p.toLowerCase());\n const val = leafValue(node);\n const inGroup = (g: string[]) => group.some((p) => g.includes(p));\n if (type === 'duration' || (!type && inGroup(['duration', 'durations'])) || (type !== 'cubicbezier' && inGroup(['duration', 'durations']))) {\n const ms = parseDuration(val);\n if (ms !== undefined) partial.duration[name] = ms;\n } else if (type === 'cubicbezier' || type === 'easing' || inGroup(['easing', 'easings', 'ease'])) {\n const e = parseEasing(val);\n if (e) partial.easing[name] = e;\n } else if (type === 'spring' || inGroup(['spring', 'springs'])) {\n if (val && typeof val === 'object') partial.spring[name] = { stiffness: Number(val.stiffness ?? 170), damping: Number(val.damping ?? 26), mass: Number(val.mass ?? 1) };\n } else if (type === 'transition' && val && typeof val === 'object') {\n const ms = parseDuration(val.duration);\n if (ms !== undefined) partial.duration[name] = ms;\n const e = parseEasing(val.timingFunction);\n if (e) partial.easing[name] = e;\n }\n return;\n }\n for (const [k, v] of Object.entries(node)) if (!k.startsWith('$')) walk(v, [...path, k]);\n };\n walk(json, []);\n return mergeMotionTokens(partial, base);\n}\n\n/** The tokens currently applied (via `applyMotionTokens`), or the defaults. */\nexport function getMotionTokens(): MotionTokens {\n return clone(active);\n}\n\n/**\n * Write tokens as CSS custom properties on `root` (default `<html>`) and make\n * them the active set for `motionToken()`. Returns an undo function.\n */\nexport function applyMotionTokens(tokens: DeepPartialTokens | MotionTokens = MOTION_TOKENS, root?: HTMLElement, prefix = '--usa'): () => void {\n const prev = active;\n active = mergeMotionTokens(tokens as DeepPartialTokens, MOTION_TOKENS);\n const el = root || (typeof document !== 'undefined' ? document.documentElement : null);\n const vars = motionTokensToVars(active, prefix);\n const old: Record<string, string> = {};\n if (el) for (const [k, v] of Object.entries(vars)) ((old[k] = el.style.getPropertyValue(k)), el.style.setProperty(k, v));\n return () => {\n active = prev;\n if (el) for (const [k, v] of Object.entries(old)) v ? el.style.setProperty(k, v) : el.style.removeProperty(k);\n };\n}\n\n/** Look up a token: `motionToken('duration', 'fast')` → `150`; `motionToken('easing', 'emphasized')` → CSS easing. */\nexport function motionToken(group: 'duration', name: string): number;\nexport function motionToken(group: 'easing', name: string): string;\nexport function motionToken(group: 'spring', name: string): SpringToken;\nexport function motionToken(group: MotionTokenGroup, name: string): number | string | SpringToken | undefined {\n const g = active[group] as Record<string, any>;\n return g[name] ?? (MOTION_TOKENS[group] as Record<string, any>)[name];\n}\n\n/** `var(--usa-duration-fast, 150ms)` — a CSS reference with the current value as fallback. */\nexport function motionVar(group: MotionTokenGroup, name: string, prop?: 'stiffness' | 'damping' | 'mass', prefix = '--usa'): string {\n if (group === 'spring') {\n const s = motionToken('spring', name);\n const p = prop || 'stiffness';\n return `var(${prefix}-spring-${kebab(name)}-${p}, ${s ? s[p] : ''})`;\n }\n const v = group === 'duration' ? `${motionToken('duration', name)}ms` : motionToken('easing', name);\n return `var(${prefix}-${group}-${kebab(name)}, ${v})`;\n}\n\n/** Resolve a duration that may be a token name (`'fast'`) or ms. */\nexport function resolveDurationToken(v: number | string | undefined, fallback: number): number {\n if (typeof v === 'number') return v;\n if (typeof v === 'string') return (active.duration[v] ?? parseDuration(v)) ?? fallback;\n return fallback;\n}\n\n/** Resolve an easing that may be a token name (`'emphasized'`) or CSS. */\nexport function resolveEasingToken(v: string | undefined, fallback: string): string {\n if (!v) return fallback;\n return active.easing[v] ?? v;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AAiBH;AACO,MAAM,aAAa,GAAiB;IACzC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE;AACvF,IAAA,MAAM,EAAE;AACN,QAAA,MAAM,EAAE,QAAQ;AAChB,QAAA,QAAQ,EAAE,4BAA4B;AACtC,QAAA,UAAU,EAAE,gCAAgC;AAC5C,QAAA,UAAU,EAAE,0BAA0B;AACtC,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,MAAM,EAAE,mCAAmC;AAC3C,QAAA,MAAM,EAAE,wCAAwC;AACjD,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EA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AgB,EAAA;AACxE,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ;IACvB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9B;;;;"}
|
package/dist/components/vue.cjs
CHANGED
|
@@ -4,6 +4,8 @@ var components = require('../components.cjs');
|
|
|
4
4
|
require('./reveal.cjs');
|
|
5
5
|
require('../chunks/base-CXx7jZ-o.cjs');
|
|
6
6
|
require('./text.cjs');
|
|
7
|
+
require('../chunks/core-BRIIoKeS.cjs');
|
|
8
|
+
require('./tokens.cjs');
|
|
7
9
|
require('./interaction.cjs');
|
|
8
10
|
require('./feedback.cjs');
|
|
9
11
|
require('./background.cjs');
|
|
@@ -16,7 +18,6 @@ require('./click.cjs');
|
|
|
16
18
|
require('./ui.cjs');
|
|
17
19
|
require('./page.cjs');
|
|
18
20
|
require('./timeline.cjs');
|
|
19
|
-
require('../chunks/core-CLu8ZrC-.cjs');
|
|
20
21
|
require('./gesture.cjs');
|
|
21
22
|
require('../chunks/core-IaorbTdu.cjs');
|
|
22
23
|
require('./svg.cjs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.cjs","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":["defineComponents"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.cjs","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":["defineComponents"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAGH;AACO,MAAM,YAAY,GAAG,CAAC,GAAW,KAAc,GAAG,CAAC,UAAU,CAAC,MAAM;AAO3E;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,CAAC,GAAmF,EAAE,OAAA,GAA4B,EAAE,EAAA;;AACzH,QAAA,MAAM,EAAE,IAAG,CAAA,EAAA,GAAC,GAAG,CAAC,MAAM,EAAC,eAAe,KAAA,EAAA,CAAf,eAAe,GAAK,EAAE,EAAC;AAC9C,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,eAAe;QAC/B,EAAE,CAAC,eAAe,GAAG,CAAC,CAAS,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AAClE,QAAAA,2BAAgB,CAAC,OAAO,CAAC,UAAU,CAAC;IACtC,CAAC;;;;;;"}
|
|
@@ -117,7 +117,11 @@ interface UsaTypewriterElement extends UsaElement {
|
|
|
117
117
|
* them in a cascade (pure CSS animation per unit, transform / opacity /
|
|
118
118
|
* filter only). Words never break across lines.
|
|
119
119
|
*
|
|
120
|
-
*
|
|
120
|
+
* 4.3: `Intl.Segmenter`-aware (emoji, CJK words), Arabic-script words are
|
|
121
|
+
* never split below the word, `by="lines"` reveals line by line, and `from`
|
|
122
|
+
* (`start` · `end` · `center` · `edges` · `random`) sets the cascade order.
|
|
123
|
+
*
|
|
124
|
+
* Attributes: `by` (`chars` | `words` | `lines`, default `chars`), `effect`
|
|
121
125
|
* (`rise` | `fade` | `blur` | `flip` | `pop`, default `rise`), `stagger`
|
|
122
126
|
* (ms between units, 28 for chars / 70 for words), `duration` (ms, 620),
|
|
123
127
|
* `delay` (ms, 0), `trigger` (`view` | `load` | `manual`, default `view`),
|
|
@@ -230,6 +234,81 @@ interface UsaScrollHighlightElement extends UsaElement {
|
|
|
230
234
|
readonly progress: number;
|
|
231
235
|
}
|
|
232
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Where a step starts on a timeline:
|
|
239
|
+
* - a number: absolute time in ms
|
|
240
|
+
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
241
|
+
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
242
|
+
* - `'<+=100'`: 100ms after the previous step's start
|
|
243
|
+
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
244
|
+
*/
|
|
245
|
+
type TimelinePosition = number | string;
|
|
246
|
+
interface TimelineStepOptions {
|
|
247
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
248
|
+
duration?: number | string;
|
|
249
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
250
|
+
easing?: string;
|
|
251
|
+
/** Start position, see `TimelinePosition`. */
|
|
252
|
+
at?: TimelinePosition;
|
|
253
|
+
/** ms between targets when the selector matches several elements. */
|
|
254
|
+
stagger?: number;
|
|
255
|
+
}
|
|
256
|
+
interface ScrubOptions {
|
|
257
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
258
|
+
offset?: number;
|
|
259
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
260
|
+
smooth?: number;
|
|
261
|
+
/**
|
|
262
|
+
* 4.1: which progress source drives the timeline.
|
|
263
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
264
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
265
|
+
*/
|
|
266
|
+
source?: 'view' | 'scroll';
|
|
267
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
268
|
+
engine?: 'auto' | 'native' | 'js';
|
|
269
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
270
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
271
|
+
}
|
|
272
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
273
|
+
interface ScrubHandle {
|
|
274
|
+
(): void;
|
|
275
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
276
|
+
readonly native: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface Timeline {
|
|
279
|
+
/** Total length in ms. */
|
|
280
|
+
readonly duration: number;
|
|
281
|
+
/** Label positions in ms. */
|
|
282
|
+
readonly labels: Readonly<Record<string, number>>;
|
|
283
|
+
/** Current playhead in ms. */
|
|
284
|
+
readonly time: number;
|
|
285
|
+
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
286
|
+
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
287
|
+
/** Name a position (default: the current end). */
|
|
288
|
+
label(name: string, at?: TimelinePosition): Timeline;
|
|
289
|
+
/** Run `fn` when the playhead passes `at`. */
|
|
290
|
+
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
291
|
+
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
292
|
+
play(from?: TimelinePosition): Promise<void>;
|
|
293
|
+
/** Play backwards to 0. */
|
|
294
|
+
reverse(): Promise<void>;
|
|
295
|
+
pause(): Timeline;
|
|
296
|
+
/** Jump to a time (ms) or label. */
|
|
297
|
+
seek(to: TimelinePosition): Timeline;
|
|
298
|
+
/** Get or set progress 0–1. */
|
|
299
|
+
progress(p?: number): number;
|
|
300
|
+
/**
|
|
301
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
302
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
303
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
304
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
305
|
+
* Returns a stop function with a `native` flag.
|
|
306
|
+
*/
|
|
307
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
308
|
+
/** Stop and drop every animation (elements keep their last frame). */
|
|
309
|
+
cancel(): void;
|
|
310
|
+
}
|
|
311
|
+
|
|
233
312
|
/**
|
|
234
313
|
* use-scroll-animate/components/text — text effects.
|
|
235
314
|
* `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
|
|
@@ -1275,81 +1354,6 @@ declare global {
|
|
|
1275
1354
|
}
|
|
1276
1355
|
}
|
|
1277
1356
|
|
|
1278
|
-
/**
|
|
1279
|
-
* Where a step starts on a timeline:
|
|
1280
|
-
* - a number: absolute time in ms
|
|
1281
|
-
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
1282
|
-
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
1283
|
-
* - `'<+=100'`: 100ms after the previous step's start
|
|
1284
|
-
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
1285
|
-
*/
|
|
1286
|
-
type TimelinePosition = number | string;
|
|
1287
|
-
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (default: timeline default, 600). */
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */
|
|
1291
|
-
easing?: string;
|
|
1292
|
-
/** Start position, see `TimelinePosition`. */
|
|
1293
|
-
at?: TimelinePosition;
|
|
1294
|
-
/** ms between targets when the selector matches several elements. */
|
|
1295
|
-
stagger?: number;
|
|
1296
|
-
}
|
|
1297
|
-
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
|
-
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
|
-
smooth?: number;
|
|
1302
|
-
/**
|
|
1303
|
-
* 4.1: which progress source drives the timeline.
|
|
1304
|
-
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
-
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
-
*/
|
|
1307
|
-
source?: 'view' | 'scroll';
|
|
1308
|
-
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
-
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
-
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
-
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
-
}
|
|
1313
|
-
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
-
interface ScrubHandle {
|
|
1315
|
-
(): void;
|
|
1316
|
-
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
-
readonly native: boolean;
|
|
1318
|
-
}
|
|
1319
|
-
interface Timeline {
|
|
1320
|
-
/** Total length in ms. */
|
|
1321
|
-
readonly duration: number;
|
|
1322
|
-
/** Label positions in ms. */
|
|
1323
|
-
readonly labels: Readonly<Record<string, number>>;
|
|
1324
|
-
/** Current playhead in ms. */
|
|
1325
|
-
readonly time: number;
|
|
1326
|
-
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
1327
|
-
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
1328
|
-
/** Name a position (default: the current end). */
|
|
1329
|
-
label(name: string, at?: TimelinePosition): Timeline;
|
|
1330
|
-
/** Run `fn` when the playhead passes `at`. */
|
|
1331
|
-
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
1332
|
-
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
1333
|
-
play(from?: TimelinePosition): Promise<void>;
|
|
1334
|
-
/** Play backwards to 0. */
|
|
1335
|
-
reverse(): Promise<void>;
|
|
1336
|
-
pause(): Timeline;
|
|
1337
|
-
/** Jump to a time (ms) or label. */
|
|
1338
|
-
seek(to: TimelinePosition): Timeline;
|
|
1339
|
-
/** Get or set progress 0–1. */
|
|
1340
|
-
progress(p?: number): number;
|
|
1341
|
-
/**
|
|
1342
|
-
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
-
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
-
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
-
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
-
* Returns a stop function with a `native` flag.
|
|
1347
|
-
*/
|
|
1348
|
-
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1349
|
-
/** Stop and drop every animation (elements keep their last frame). */
|
|
1350
|
-
cancel(): void;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
1357
|
/**
|
|
1354
1358
|
* `<usa-timeline>` — declarative choreography. Every descendant with
|
|
1355
1359
|
* `data-tl="<preset>"` becomes a step, in document order; `data-at`
|
package/dist/components/vue.d.ts
CHANGED
|
@@ -117,7 +117,11 @@ interface UsaTypewriterElement extends UsaElement {
|
|
|
117
117
|
* them in a cascade (pure CSS animation per unit, transform / opacity /
|
|
118
118
|
* filter only). Words never break across lines.
|
|
119
119
|
*
|
|
120
|
-
*
|
|
120
|
+
* 4.3: `Intl.Segmenter`-aware (emoji, CJK words), Arabic-script words are
|
|
121
|
+
* never split below the word, `by="lines"` reveals line by line, and `from`
|
|
122
|
+
* (`start` · `end` · `center` · `edges` · `random`) sets the cascade order.
|
|
123
|
+
*
|
|
124
|
+
* Attributes: `by` (`chars` | `words` | `lines`, default `chars`), `effect`
|
|
121
125
|
* (`rise` | `fade` | `blur` | `flip` | `pop`, default `rise`), `stagger`
|
|
122
126
|
* (ms between units, 28 for chars / 70 for words), `duration` (ms, 620),
|
|
123
127
|
* `delay` (ms, 0), `trigger` (`view` | `load` | `manual`, default `view`),
|
|
@@ -230,6 +234,81 @@ interface UsaScrollHighlightElement extends UsaElement {
|
|
|
230
234
|
readonly progress: number;
|
|
231
235
|
}
|
|
232
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Where a step starts on a timeline:
|
|
239
|
+
* - a number: absolute time in ms
|
|
240
|
+
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
241
|
+
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
242
|
+
* - `'<+=100'`: 100ms after the previous step's start
|
|
243
|
+
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
244
|
+
*/
|
|
245
|
+
type TimelinePosition = number | string;
|
|
246
|
+
interface TimelineStepOptions {
|
|
247
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
248
|
+
duration?: number | string;
|
|
249
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
250
|
+
easing?: string;
|
|
251
|
+
/** Start position, see `TimelinePosition`. */
|
|
252
|
+
at?: TimelinePosition;
|
|
253
|
+
/** ms between targets when the selector matches several elements. */
|
|
254
|
+
stagger?: number;
|
|
255
|
+
}
|
|
256
|
+
interface ScrubOptions {
|
|
257
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
258
|
+
offset?: number;
|
|
259
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
260
|
+
smooth?: number;
|
|
261
|
+
/**
|
|
262
|
+
* 4.1: which progress source drives the timeline.
|
|
263
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
264
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
265
|
+
*/
|
|
266
|
+
source?: 'view' | 'scroll';
|
|
267
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
268
|
+
engine?: 'auto' | 'native' | 'js';
|
|
269
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
270
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
271
|
+
}
|
|
272
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
273
|
+
interface ScrubHandle {
|
|
274
|
+
(): void;
|
|
275
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
276
|
+
readonly native: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface Timeline {
|
|
279
|
+
/** Total length in ms. */
|
|
280
|
+
readonly duration: number;
|
|
281
|
+
/** Label positions in ms. */
|
|
282
|
+
readonly labels: Readonly<Record<string, number>>;
|
|
283
|
+
/** Current playhead in ms. */
|
|
284
|
+
readonly time: number;
|
|
285
|
+
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
286
|
+
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
287
|
+
/** Name a position (default: the current end). */
|
|
288
|
+
label(name: string, at?: TimelinePosition): Timeline;
|
|
289
|
+
/** Run `fn` when the playhead passes `at`. */
|
|
290
|
+
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
291
|
+
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
292
|
+
play(from?: TimelinePosition): Promise<void>;
|
|
293
|
+
/** Play backwards to 0. */
|
|
294
|
+
reverse(): Promise<void>;
|
|
295
|
+
pause(): Timeline;
|
|
296
|
+
/** Jump to a time (ms) or label. */
|
|
297
|
+
seek(to: TimelinePosition): Timeline;
|
|
298
|
+
/** Get or set progress 0–1. */
|
|
299
|
+
progress(p?: number): number;
|
|
300
|
+
/**
|
|
301
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
302
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
303
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
304
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
305
|
+
* Returns a stop function with a `native` flag.
|
|
306
|
+
*/
|
|
307
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
308
|
+
/** Stop and drop every animation (elements keep their last frame). */
|
|
309
|
+
cancel(): void;
|
|
310
|
+
}
|
|
311
|
+
|
|
233
312
|
/**
|
|
234
313
|
* use-scroll-animate/components/text — text effects.
|
|
235
314
|
* `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
|
|
@@ -1275,81 +1354,6 @@ declare global {
|
|
|
1275
1354
|
}
|
|
1276
1355
|
}
|
|
1277
1356
|
|
|
1278
|
-
/**
|
|
1279
|
-
* Where a step starts on a timeline:
|
|
1280
|
-
* - a number: absolute time in ms
|
|
1281
|
-
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
1282
|
-
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
1283
|
-
* - `'<+=100'`: 100ms after the previous step's start
|
|
1284
|
-
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
1285
|
-
*/
|
|
1286
|
-
type TimelinePosition = number | string;
|
|
1287
|
-
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (default: timeline default, 600). */
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */
|
|
1291
|
-
easing?: string;
|
|
1292
|
-
/** Start position, see `TimelinePosition`. */
|
|
1293
|
-
at?: TimelinePosition;
|
|
1294
|
-
/** ms between targets when the selector matches several elements. */
|
|
1295
|
-
stagger?: number;
|
|
1296
|
-
}
|
|
1297
|
-
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
|
-
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
|
-
smooth?: number;
|
|
1302
|
-
/**
|
|
1303
|
-
* 4.1: which progress source drives the timeline.
|
|
1304
|
-
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
-
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
-
*/
|
|
1307
|
-
source?: 'view' | 'scroll';
|
|
1308
|
-
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
-
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
-
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
-
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
-
}
|
|
1313
|
-
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
-
interface ScrubHandle {
|
|
1315
|
-
(): void;
|
|
1316
|
-
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
-
readonly native: boolean;
|
|
1318
|
-
}
|
|
1319
|
-
interface Timeline {
|
|
1320
|
-
/** Total length in ms. */
|
|
1321
|
-
readonly duration: number;
|
|
1322
|
-
/** Label positions in ms. */
|
|
1323
|
-
readonly labels: Readonly<Record<string, number>>;
|
|
1324
|
-
/** Current playhead in ms. */
|
|
1325
|
-
readonly time: number;
|
|
1326
|
-
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
1327
|
-
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
1328
|
-
/** Name a position (default: the current end). */
|
|
1329
|
-
label(name: string, at?: TimelinePosition): Timeline;
|
|
1330
|
-
/** Run `fn` when the playhead passes `at`. */
|
|
1331
|
-
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
1332
|
-
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
1333
|
-
play(from?: TimelinePosition): Promise<void>;
|
|
1334
|
-
/** Play backwards to 0. */
|
|
1335
|
-
reverse(): Promise<void>;
|
|
1336
|
-
pause(): Timeline;
|
|
1337
|
-
/** Jump to a time (ms) or label. */
|
|
1338
|
-
seek(to: TimelinePosition): Timeline;
|
|
1339
|
-
/** Get or set progress 0–1. */
|
|
1340
|
-
progress(p?: number): number;
|
|
1341
|
-
/**
|
|
1342
|
-
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
-
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
-
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
-
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
-
* Returns a stop function with a `native` flag.
|
|
1347
|
-
*/
|
|
1348
|
-
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1349
|
-
/** Stop and drop every animation (elements keep their last frame). */
|
|
1350
|
-
cancel(): void;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
1357
|
/**
|
|
1354
1358
|
* `<usa-timeline>` — declarative choreography. Every descendant with
|
|
1355
1359
|
* `data-tl="<preset>"` becomes a step, in document order; `data-at`
|
package/dist/components/vue.js
CHANGED
|
@@ -2,6 +2,8 @@ import { defineComponents } from '../components.js';
|
|
|
2
2
|
import './reveal.js';
|
|
3
3
|
import '../chunks/base-BPG5zvex.js';
|
|
4
4
|
import './text.js';
|
|
5
|
+
import '../chunks/core-LkGRmgES.js';
|
|
6
|
+
import './tokens.js';
|
|
5
7
|
import './interaction.js';
|
|
6
8
|
import './feedback.js';
|
|
7
9
|
import './background.js';
|
|
@@ -14,7 +16,6 @@ import './click.js';
|
|
|
14
16
|
import './ui.js';
|
|
15
17
|
import './page.js';
|
|
16
18
|
import './timeline.js';
|
|
17
|
-
import '../chunks/core-QTFk4kgO.js';
|
|
18
19
|
import './gesture.js';
|
|
19
20
|
import '../chunks/core-eXX8rB_b.js';
|
|
20
21
|
import './svg.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.js","sources":["../../src/components/frameworks/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/vue — Vue integration (v2.9).\n *\n * ```js\n * // vite.config.js\n * import vue from '@vitejs/plugin-vue';\n * import { isUsaElement } from 'use-scroll-animate/components/vue';\n * export default { plugins: [vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } })] };\n *\n * // main.js\n * import { UsaPlugin } from 'use-scroll-animate/components/vue';\n * app.use(UsaPlugin, { categories: ['click', 'cards'] });\n * ```\n * In templates, listen with `@usa:change=\"…\"` and bind properties with\n * `.prop`: `<usa-toggle :checked.prop=\"on\" @usa:change=\"on = $event.detail.checked\">`.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\n\n/** `compilerOptions.isCustomElement` predicate for every `<usa-*>` tag. */\nexport const isUsaElement = (tag: string): boolean => tag.startsWith('usa-');\n\nexport interface UsaPluginOptions {\n /** Only register these categories (default: all). */\n categories?: ComponentCategory[];\n}\n\n/** Vue plugin: registers the `<usa-*>` elements (client only) and sets `isCustomElement` at runtime. */\nexport const UsaPlugin = {\n install(app: { config: { compilerOptions?: { isCustomElement?: (t: string) => boolean } } }, options: UsaPluginOptions = {}): void {\n const co = (app.config.compilerOptions ||= {});\n const prev = co.isCustomElement;\n co.isCustomElement = (t: string) => isUsaElement(t) || !!prev?.(t);\n defineComponents(options.categories);\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAGH;AACO,MAAM,YAAY,GAAG,CAAC,GAAW,KAAc,GAAG,CAAC,UAAU,CAAC,MAAM;AAO3E;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,CAAC,GAAmF,EAAE,OAAA,GAA4B,EAAE,EAAA;;AACzH,QAAA,MAAM,EAAE,IAAG,CAAA,EAAA,GAAC,GAAG,CAAC,MAAM,EAAC,eAAe,KAAA,EAAA,CAAf,eAAe,GAAK,EAAE,EAAC;AAC9C,QAAA,MAAM,IAAI,GAAG,EAAE,CAAC,eAAe;QAC/B,EAAE,CAAC,eAAe,GAAG,CAAC,CAAS,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AAClE,QAAA,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC;IACtC,CAAC;;;;;"}
|
package/dist/components.cjs
CHANGED
|
@@ -20,9 +20,10 @@ var components_layout = require('./components/layout.cjs');
|
|
|
20
20
|
var components_packs = require('./components/packs.cjs');
|
|
21
21
|
var variants = require('./chunks/variants-BNIrn4ch.cjs');
|
|
22
22
|
var base = require('./chunks/base-CXx7jZ-o.cjs');
|
|
23
|
+
var components_tokens = require('./components/tokens.cjs');
|
|
23
24
|
var indexTags = require('./chunks/index-tags-BQh_uGqH.cjs');
|
|
24
25
|
var spring = require('./chunks/spring-2OTnYCzm.cjs');
|
|
25
|
-
var core = require('./chunks/core-
|
|
26
|
+
var core = require('./chunks/core-BRIIoKeS.cjs');
|
|
26
27
|
var core$1 = require('./chunks/core-IaorbTdu.cjs');
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -83,6 +84,7 @@ exports.defineScrolly = components_reveal.defineScrolly;
|
|
|
83
84
|
exports.defineStagger = components_reveal.defineStagger;
|
|
84
85
|
exports.readScrollProgress = components_reveal.readScrollProgress;
|
|
85
86
|
exports.revealKeyframes = components_reveal.revealKeyframes;
|
|
87
|
+
exports.JOINING_SCRIPT = components_text.JOINING_SCRIPT;
|
|
86
88
|
exports.defineCounter = components_text.defineCounter;
|
|
87
89
|
exports.defineGlitch = components_text.defineGlitch;
|
|
88
90
|
exports.defineGradientText = components_text.defineGradientText;
|
|
@@ -96,7 +98,12 @@ exports.defineTextRotate = components_text.defineTextRotate;
|
|
|
96
98
|
exports.defineTypewriter = components_text.defineTypewriter;
|
|
97
99
|
exports.defineWaveText = components_text.defineWaveText;
|
|
98
100
|
exports.easeOutExpo = components_text.easeOutExpo;
|
|
101
|
+
exports.graphemes = components_text.graphemes;
|
|
99
102
|
exports.scrambleFrame = components_text.scrambleFrame;
|
|
103
|
+
exports.splitOrder = components_text.splitOrder;
|
|
104
|
+
exports.splitText = components_text.splitText;
|
|
105
|
+
exports.splitTimeline = components_text.splitTimeline;
|
|
106
|
+
exports.splitWords = components_text.splitWords;
|
|
100
107
|
exports.defineInteractionComponents = components_interaction.defineInteractionComponents;
|
|
101
108
|
exports.defineMagnetic = components_interaction.defineMagnetic;
|
|
102
109
|
exports.definePress = components_interaction.definePress;
|
|
@@ -243,6 +250,20 @@ exports.MOTION_SCALE = base.MOTION_SCALE;
|
|
|
243
250
|
exports.configureComponents = base.configureComponents;
|
|
244
251
|
exports.getMotionIntensity = base.getMotionIntensity;
|
|
245
252
|
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
253
|
+
exports.MOTION_TOKENS = components_tokens.MOTION_TOKENS;
|
|
254
|
+
exports.applyMotionTokens = components_tokens.applyMotionTokens;
|
|
255
|
+
exports.getMotionTokens = components_tokens.getMotionTokens;
|
|
256
|
+
exports.importMotionTokens = components_tokens.importMotionTokens;
|
|
257
|
+
exports.mergeMotionTokens = components_tokens.mergeMotionTokens;
|
|
258
|
+
exports.motionToken = components_tokens.motionToken;
|
|
259
|
+
exports.motionTokensToCss = components_tokens.motionTokensToCss;
|
|
260
|
+
exports.motionTokensToJSON = components_tokens.motionTokensToJSON;
|
|
261
|
+
exports.motionTokensToVars = components_tokens.motionTokensToVars;
|
|
262
|
+
exports.motionVar = components_tokens.motionVar;
|
|
263
|
+
exports.parseDuration = components_tokens.parseDuration;
|
|
264
|
+
exports.parseEasing = components_tokens.parseEasing;
|
|
265
|
+
exports.resolveDurationToken = components_tokens.resolveDurationToken;
|
|
266
|
+
exports.resolveEasingToken = components_tokens.resolveEasingToken;
|
|
246
267
|
exports.COMPONENT_CATEGORIES = indexTags.COMPONENT_CATEGORIES;
|
|
247
268
|
exports.SPRING_PRESETS = spring.SPRING_PRESETS;
|
|
248
269
|
exports.createSpring = spring.createSpring;
|
package/dist/components.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.cjs","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { defineTimelineComponents } from './timeline/index';\nimport { defineGestureComponents } from './gesture/index';\nimport { defineSvgComponents } from './svg/index';\nimport { defineWebglComponents } from './webgl/index';\nimport { defineDepthComponents } from './depth/index';\nimport { defineLayoutComponents } from './layout/index';\nimport { definePacksComponents } from './packs/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\nexport * from './timeline/index';\nexport * from './gesture/index';\nexport * from './svg/index';\nexport * from './webgl/index';\nexport * from './depth/index';\nexport * from './layout/index';\nexport * from './packs/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n timeline: defineTimelineComponents,\n gesture: defineGestureComponents,\n svg: defineSvgComponents,\n webgl: defineWebglComponents,\n depth: defineDepthComponents,\n layout: defineLayoutComponents,\n packs: definePacksComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":["defineRevealComponents","defineTextComponents","defineInteractionComponents","defineFeedbackComponents","defineBackgroundComponents","defineTransitionComponents","definePhysicsComponents","defineCardComponents","defineClickComponents","defineUiComponents","definePageComponents","defineTimelineComponents","defineGestureComponents","defineSvgComponents","defineWebglComponents","defineDepthComponents","defineLayoutComponents","definePacksComponents","canDefine","adoptVariants"],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.cjs","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { defineTimelineComponents } from './timeline/index';\nimport { defineGestureComponents } from './gesture/index';\nimport { defineSvgComponents } from './svg/index';\nimport { defineWebglComponents } from './webgl/index';\nimport { defineDepthComponents } from './depth/index';\nimport { defineLayoutComponents } from './layout/index';\nimport { definePacksComponents } from './packs/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\nexport * from './timeline/index';\nexport * from './gesture/index';\nexport * from './svg/index';\nexport * from './webgl/index';\nexport * from './depth/index';\nexport * from './layout/index';\nexport * from './packs/index';\nexport * from './tokens/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n timeline: defineTimelineComponents,\n gesture: defineGestureComponents,\n svg: defineSvgComponents,\n webgl: defineWebglComponents,\n depth: defineDepthComponents,\n layout: defineLayoutComponents,\n packs: definePacksComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":["defineRevealComponents","defineTextComponents","defineInteractionComponents","defineFeedbackComponents","defineBackgroundComponents","defineTransitionComponents","definePhysicsComponents","defineCardComponents","defineClickComponents","defineUiComponents","definePageComponents","defineTimelineComponents","defineGestureComponents","defineSvgComponents","defineWebglComponents","defineDepthComponents","defineLayoutComponents","definePacksComponents","canDefine","adoptVariants"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA8CH,MAAM,WAAW,GAA0C;AACzD,IAAA,MAAM,EAAEA,wCAAsB;AAC9B,IAAA,IAAI,EAAEC,oCAAoB;AAC1B,IAAA,WAAW,EAAEC,kDAA2B;AACxC,IAAA,QAAQ,EAAEC,4CAAwB;AAClC,IAAA,UAAU,EAAEC,gDAA0B;AACtC,IAAA,WAAW,EAAEC,iDAA0B;AACvC,IAAA,OAAO,EAAEC,0CAAuB;AAChC,IAAA,KAAK,EAAEC,qCAAoB;AAC3B,IAAA,KAAK,EAAEC,sCAAqB;AAC5B,IAAA,EAAE,EAAEC,gCAAkB;AACtB,IAAA,IAAI,EAAEC,oCAAoB;AAC1B,IAAA,QAAQ,EAAEC,4CAAwB;AAClC,IAAA,OAAO,EAAEC,0CAAuB;AAChC,IAAA,GAAG,EAAEC,kCAAmB;AACxB,IAAA,KAAK,EAAEC,sCAAqB;AAC5B,IAAA,KAAK,EAAEC,sCAAqB;AAC5B,IAAA,MAAM,EAAEC,wCAAsB;AAC9B,IAAA,KAAK,EAAEC,sCAAqB;CAC7B;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,UAAgC,EAAA;AAC/D,IAAA,IAAIC,cAAS,EAAE;AAAE,QAAAC,sBAAa,EAAE;IAChC,CAAC,UAAU,IAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAyB,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,WA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