use-scroll-animate 3.1.0 → 3.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 +22 -0
- package/README.md +2 -0
- package/README_ja.md +2 -0
- package/README_zh.md +2 -0
- package/dist/chunks/{index-tags-Gw1G06Pb.cjs → index-tags-Cz4iTBEK.cjs} +3 -1
- package/dist/chunks/index-tags-Cz4iTBEK.cjs.map +1 -0
- package/dist/chunks/{index-tags-D7NynL4r.js → index-tags-Dc_Z4yAY.js} +3 -1
- package/dist/chunks/index-tags-Dc_Z4yAY.js.map +1 -0
- package/dist/components/gesture.cjs +387 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +169 -0
- package/dist/components/gesture.d.ts +169 -0
- package/dist/components/gesture.js +379 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/jsx.d.cts +2 -0
- package/dist/components/jsx.d.ts +2 -0
- package/dist/components/lazy.cjs +3 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.d.cts +2 -0
- package/dist/components/lazy.d.ts +2 -0
- package/dist/components/lazy.js +3 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/react.cjs +1 -1
- package/dist/components/react.js +1 -1
- package/dist/components/svg.cjs +355 -0
- package/dist/components/svg.cjs.map +1 -0
- package/dist/components/svg.css +3 -0
- package/dist/components/svg.d.cts +148 -0
- package/dist/components/svg.d.ts +148 -0
- package/dist/components/svg.js +342 -0
- package/dist/components/svg.js.map +1 -0
- package/dist/components/vue.cjs +3 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +112 -0
- package/dist/components/vue.d.ts +112 -0
- package/dist/components/vue.js +3 -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.css +2 -0
- package/dist/components.d.cts +227 -2
- package/dist/components.d.ts +227 -2
- package/dist/components.js +8 -2
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/components.md +18 -0
- package/package.json +24 -2
- package/dist/chunks/index-tags-D7NynL4r.js.map +0 -1
- package/dist/chunks/index-tags-Gw1G06Pb.cjs.map +0 -1
|
@@ -1374,6 +1374,116 @@ declare global {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
1376
|
|
|
1377
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
1381
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
1382
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
1383
|
+
*
|
|
1384
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
1385
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
1386
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
1387
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
1388
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
1389
|
+
*/
|
|
1390
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
1391
|
+
swipe(direction: SwipeDirection): void;
|
|
1392
|
+
reset(): void;
|
|
1393
|
+
readonly offset: number;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
1398
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
1399
|
+
* scale and position spring back inside the bounds on release.
|
|
1400
|
+
*
|
|
1401
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
1402
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
1403
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
1404
|
+
*/
|
|
1405
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
1406
|
+
readonly scale: number;
|
|
1407
|
+
zoomTo(scale: number): void;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* use-scroll-animate/components/gesture — unified gestures (v3.2).
|
|
1412
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
1413
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
1414
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
1415
|
+
*/
|
|
1416
|
+
|
|
1417
|
+
declare global {
|
|
1418
|
+
interface HTMLElementTagNameMap {
|
|
1419
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
1420
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* `<usa-draw>` — line drawing: every stroke of the SVG inside draws itself.
|
|
1426
|
+
* Attributes: `trigger` (`view` default · `hover` · `click` · `scrub`),
|
|
1427
|
+
* `duration` (1600), `stagger` (0–0.9 share of the timeline, 0.2), `fill`
|
|
1428
|
+
* (fade the fill in after drawing), `repeat`. Method `play()`, property
|
|
1429
|
+
* `progress`, event `usa:complete`. Reduced motion: drawn immediately.
|
|
1430
|
+
*/
|
|
1431
|
+
interface UsaDrawElement extends UsaElement {
|
|
1432
|
+
play(): void;
|
|
1433
|
+
progress: number;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* `<usa-morph>` — morphs an SVG path through a list of shapes.
|
|
1438
|
+
* Put a `<svg><path></path></svg>` inside (one is created otherwise) and set
|
|
1439
|
+
* `paths="M… | M… | M…"` (same command structure morphs smoothly, others
|
|
1440
|
+
* switch at the midpoint). Attributes: `trigger` (`click` default · `hover`
|
|
1441
|
+
* · `auto` · `view`), `interval` (ms for auto, 2000), `duration` (600).
|
|
1442
|
+
* Property `index`, method `next()`, event `usa:change`.
|
|
1443
|
+
* Reduced motion: shapes switch without animating; `auto` does not cycle.
|
|
1444
|
+
*/
|
|
1445
|
+
interface UsaMorphElement extends UsaElement {
|
|
1446
|
+
readonly index: number;
|
|
1447
|
+
next(): Promise<void>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* `<usa-mask-reveal>` — reveals its content through a growing mask shape.
|
|
1452
|
+
* Attributes: `shape` (`circle` default · `diamond` · `wipe` · `wipe-up` ·
|
|
1453
|
+
* `iris` · `star`), `duration` (900), `delay`, `trigger` (`view` · `hover`
|
|
1454
|
+
* · `click`), `repeat`, `at` (`x% y%` origin for circle). Event
|
|
1455
|
+
* `usa:complete`. Reduced motion: content is shown without the mask.
|
|
1456
|
+
*/
|
|
1457
|
+
interface UsaMaskRevealElement extends UsaElement {
|
|
1458
|
+
reveal(): Promise<void>;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* `<usa-anim-icon name="bell">` — an animated stroke icon that plays its
|
|
1463
|
+
* motion on `trigger` (`hover` default · `click` · `view` · `loop`).
|
|
1464
|
+
* Attributes: `name` (see `ANIM_ICONS`), `size` (24), `label` (accessible
|
|
1465
|
+
* name; decorative when absent). Method `play()`. Reduced motion: static.
|
|
1466
|
+
*/
|
|
1467
|
+
interface UsaAnimIconElement extends UsaElement {
|
|
1468
|
+
play(): void;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* use-scroll-animate/components/svg — SVG animation (v3.3).
|
|
1473
|
+
* `<usa-draw>` (line drawing), `<usa-morph>` (path morph), `<usa-mask-reveal>`
|
|
1474
|
+
* (mask / clip-path reveals) and `<usa-anim-icon>` (animated icons), plus
|
|
1475
|
+
* `interpolatePath()`, `morphTo()`, `drawLines()`.
|
|
1476
|
+
*/
|
|
1477
|
+
|
|
1478
|
+
declare global {
|
|
1479
|
+
interface HTMLElementTagNameMap {
|
|
1480
|
+
'usa-draw': UsaDrawElement;
|
|
1481
|
+
'usa-morph': UsaMorphElement;
|
|
1482
|
+
'usa-mask-reveal': UsaMaskRevealElement;
|
|
1483
|
+
'usa-anim-icon': UsaAnimIconElement;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1377
1487
|
/** The component categories and their default tags. */
|
|
1378
1488
|
declare const COMPONENT_CATEGORIES: {
|
|
1379
1489
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1388,6 +1498,8 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1388
1498
|
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
1389
1499
|
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
1390
1500
|
readonly timeline: readonly ["usa-timeline"];
|
|
1501
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
1502
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
1391
1503
|
};
|
|
1392
1504
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1393
1505
|
|
package/dist/components/vue.d.ts
CHANGED
|
@@ -1374,6 +1374,116 @@ declare global {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
1376
|
|
|
1377
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
1381
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
1382
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
1383
|
+
*
|
|
1384
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
1385
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
1386
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
1387
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
1388
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
1389
|
+
*/
|
|
1390
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
1391
|
+
swipe(direction: SwipeDirection): void;
|
|
1392
|
+
reset(): void;
|
|
1393
|
+
readonly offset: number;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
1398
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
1399
|
+
* scale and position spring back inside the bounds on release.
|
|
1400
|
+
*
|
|
1401
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
1402
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
1403
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
1404
|
+
*/
|
|
1405
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
1406
|
+
readonly scale: number;
|
|
1407
|
+
zoomTo(scale: number): void;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* use-scroll-animate/components/gesture — unified gestures (v3.2).
|
|
1412
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
1413
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
1414
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
1415
|
+
*/
|
|
1416
|
+
|
|
1417
|
+
declare global {
|
|
1418
|
+
interface HTMLElementTagNameMap {
|
|
1419
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
1420
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* `<usa-draw>` — line drawing: every stroke of the SVG inside draws itself.
|
|
1426
|
+
* Attributes: `trigger` (`view` default · `hover` · `click` · `scrub`),
|
|
1427
|
+
* `duration` (1600), `stagger` (0–0.9 share of the timeline, 0.2), `fill`
|
|
1428
|
+
* (fade the fill in after drawing), `repeat`. Method `play()`, property
|
|
1429
|
+
* `progress`, event `usa:complete`. Reduced motion: drawn immediately.
|
|
1430
|
+
*/
|
|
1431
|
+
interface UsaDrawElement extends UsaElement {
|
|
1432
|
+
play(): void;
|
|
1433
|
+
progress: number;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* `<usa-morph>` — morphs an SVG path through a list of shapes.
|
|
1438
|
+
* Put a `<svg><path></path></svg>` inside (one is created otherwise) and set
|
|
1439
|
+
* `paths="M… | M… | M…"` (same command structure morphs smoothly, others
|
|
1440
|
+
* switch at the midpoint). Attributes: `trigger` (`click` default · `hover`
|
|
1441
|
+
* · `auto` · `view`), `interval` (ms for auto, 2000), `duration` (600).
|
|
1442
|
+
* Property `index`, method `next()`, event `usa:change`.
|
|
1443
|
+
* Reduced motion: shapes switch without animating; `auto` does not cycle.
|
|
1444
|
+
*/
|
|
1445
|
+
interface UsaMorphElement extends UsaElement {
|
|
1446
|
+
readonly index: number;
|
|
1447
|
+
next(): Promise<void>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* `<usa-mask-reveal>` — reveals its content through a growing mask shape.
|
|
1452
|
+
* Attributes: `shape` (`circle` default · `diamond` · `wipe` · `wipe-up` ·
|
|
1453
|
+
* `iris` · `star`), `duration` (900), `delay`, `trigger` (`view` · `hover`
|
|
1454
|
+
* · `click`), `repeat`, `at` (`x% y%` origin for circle). Event
|
|
1455
|
+
* `usa:complete`. Reduced motion: content is shown without the mask.
|
|
1456
|
+
*/
|
|
1457
|
+
interface UsaMaskRevealElement extends UsaElement {
|
|
1458
|
+
reveal(): Promise<void>;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* `<usa-anim-icon name="bell">` — an animated stroke icon that plays its
|
|
1463
|
+
* motion on `trigger` (`hover` default · `click` · `view` · `loop`).
|
|
1464
|
+
* Attributes: `name` (see `ANIM_ICONS`), `size` (24), `label` (accessible
|
|
1465
|
+
* name; decorative when absent). Method `play()`. Reduced motion: static.
|
|
1466
|
+
*/
|
|
1467
|
+
interface UsaAnimIconElement extends UsaElement {
|
|
1468
|
+
play(): void;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* use-scroll-animate/components/svg — SVG animation (v3.3).
|
|
1473
|
+
* `<usa-draw>` (line drawing), `<usa-morph>` (path morph), `<usa-mask-reveal>`
|
|
1474
|
+
* (mask / clip-path reveals) and `<usa-anim-icon>` (animated icons), plus
|
|
1475
|
+
* `interpolatePath()`, `morphTo()`, `drawLines()`.
|
|
1476
|
+
*/
|
|
1477
|
+
|
|
1478
|
+
declare global {
|
|
1479
|
+
interface HTMLElementTagNameMap {
|
|
1480
|
+
'usa-draw': UsaDrawElement;
|
|
1481
|
+
'usa-morph': UsaMorphElement;
|
|
1482
|
+
'usa-mask-reveal': UsaMaskRevealElement;
|
|
1483
|
+
'usa-anim-icon': UsaAnimIconElement;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1377
1487
|
/** The component categories and their default tags. */
|
|
1378
1488
|
declare const COMPONENT_CATEGORIES: {
|
|
1379
1489
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1388,6 +1498,8 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1388
1498
|
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
1389
1499
|
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
1390
1500
|
readonly timeline: readonly ["usa-timeline"];
|
|
1501
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
1502
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
1391
1503
|
};
|
|
1392
1504
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1393
1505
|
|
package/dist/components/vue.js
CHANGED
|
@@ -14,7 +14,9 @@ import './click.js';
|
|
|
14
14
|
import './ui.js';
|
|
15
15
|
import './page.js';
|
|
16
16
|
import './timeline.js';
|
|
17
|
-
import '
|
|
17
|
+
import './gesture.js';
|
|
18
|
+
import './svg.js';
|
|
19
|
+
import '../chunks/index-tags-Dc_Z4yAY.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* use-scroll-animate/components/vue — Vue integration (v2.9).
|
|
@@ -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
|
@@ -12,9 +12,11 @@ var components_click = require('./components/click.cjs');
|
|
|
12
12
|
var components_ui = require('./components/ui.cjs');
|
|
13
13
|
var components_page = require('./components/page.cjs');
|
|
14
14
|
var components_timeline = require('./components/timeline.cjs');
|
|
15
|
+
var components_gesture = require('./components/gesture.cjs');
|
|
16
|
+
var components_svg = require('./components/svg.cjs');
|
|
15
17
|
var variants = require('./chunks/variants-BNIrn4ch.cjs');
|
|
16
18
|
var base = require('./chunks/base-CXx7jZ-o.cjs');
|
|
17
|
-
var indexTags = require('./chunks/index-tags-
|
|
19
|
+
var indexTags = require('./chunks/index-tags-Cz4iTBEK.cjs');
|
|
18
20
|
var spring = require('./chunks/spring-2OTnYCzm.cjs');
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -50,6 +52,8 @@ const BY_CATEGORY = {
|
|
|
50
52
|
ui: components_ui.defineUiComponents,
|
|
51
53
|
page: components_page.definePageComponents,
|
|
52
54
|
timeline: components_timeline.defineTimelineComponents,
|
|
55
|
+
gesture: components_gesture.defineGestureComponents,
|
|
56
|
+
svg: components_svg.defineSvgComponents,
|
|
53
57
|
};
|
|
54
58
|
/**
|
|
55
59
|
* Register every `<usa-*>` component (or only the given categories).
|
|
@@ -184,6 +188,23 @@ exports.defineTimeline = components_timeline.defineTimeline;
|
|
|
184
188
|
exports.defineTimelineComponents = components_timeline.defineTimelineComponents;
|
|
185
189
|
exports.resolvePosition = components_timeline.resolvePosition;
|
|
186
190
|
exports.timeline = components_timeline.timeline;
|
|
191
|
+
exports.defineGestureComponents = components_gesture.defineGestureComponents;
|
|
192
|
+
exports.definePinchZoom = components_gesture.definePinchZoom;
|
|
193
|
+
exports.defineSwipeable = components_gesture.defineSwipeable;
|
|
194
|
+
exports.gesture = components_gesture.gesture;
|
|
195
|
+
exports.pinchScale = components_gesture.pinchScale;
|
|
196
|
+
exports.swipeDirection = components_gesture.swipeDirection;
|
|
197
|
+
exports.ANIM_ICONS = components_svg.ANIM_ICONS;
|
|
198
|
+
exports.MASK_SHAPES = components_svg.MASK_SHAPES;
|
|
199
|
+
exports.defineAnimIcon = components_svg.defineAnimIcon;
|
|
200
|
+
exports.defineDraw = components_svg.defineDraw;
|
|
201
|
+
exports.defineMaskReveal = components_svg.defineMaskReveal;
|
|
202
|
+
exports.defineMorph = components_svg.defineMorph;
|
|
203
|
+
exports.defineSvgComponents = components_svg.defineSvgComponents;
|
|
204
|
+
exports.drawLines = components_svg.drawLines;
|
|
205
|
+
exports.interpolatePath = components_svg.interpolatePath;
|
|
206
|
+
exports.morphTo = components_svg.morphTo;
|
|
207
|
+
exports.pathsCompatible = components_svg.pathsCompatible;
|
|
187
208
|
exports.VARIANTS = variants.VARIANTS;
|
|
188
209
|
exports.adoptVariants = variants.adoptVariants;
|
|
189
210
|
exports.setVariant = variants.setVariant;
|
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 { 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';\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};\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","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 { 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';\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};\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","canDefine","adoptVariants"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAqCH,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;CACzB;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,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACtG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/components.css
CHANGED
|
@@ -67,3 +67,5 @@ usa-motion-switch{--usa-motion-i:2;position:relative;display:inline-grid;grid-au
|
|
|
67
67
|
usa-splash{position:fixed;inset:0;z-index:2147483400;display:grid;place-items:center;background:var(--usa-splash-bg,var(--usa-surface,#0b0d12));color:var(--usa-text,#fff)}usa-splash[hidden]{display:none}
|
|
68
68
|
::view-transition-group(root){animation-duration:var(--usa-pt-duration,600ms)}html[data-usa-pt] ::view-transition-old(root),html[data-usa-pt] ::view-transition-new(root){animation-duration:var(--usa-pt-duration,600ms);animation-timing-function:cubic-bezier(0.22,1,0.36,1);mix-blend-mode:normal}html[data-usa-pt="slide"] ::view-transition-old(root),html[data-usa-pt="slide-left"] ::view-transition-old(root){animation-name:usa-pt-out-left}html[data-usa-pt="slide"] ::view-transition-new(root),html[data-usa-pt="slide-left"] ::view-transition-new(root){animation-name:usa-pt-in-right}html[data-usa-pt="slide-right"] ::view-transition-old(root){animation-name:usa-pt-out-right}html[data-usa-pt="slide-right"] ::view-transition-new(root){animation-name:usa-pt-in-left}html[data-usa-pt="slide-up"] ::view-transition-old(root){animation-name:usa-pt-out-up}html[data-usa-pt="slide-up"] ::view-transition-new(root){animation-name:usa-pt-in-up}html[data-usa-pt="zoom"] ::view-transition-old(root){animation-name:usa-pt-zoom-out}html[data-usa-pt="zoom"] ::view-transition-new(root){animation-name:usa-pt-zoom-in}html[data-usa-pt="circle"] ::view-transition-old(root){animation:none}html[data-usa-pt="circle"] ::view-transition-new(root){animation-name:usa-pt-circle}html[data-usa-pt="blinds"] ::view-transition-old(root){animation:none}html[data-usa-pt="blinds"] ::view-transition-new(root){animation-name:usa-pt-blinds;-webkit-mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh);mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh)}html[data-usa-pt="pixel"] ::view-transition-old(root){animation-name:usa-pt-pixel-out;animation-timing-function:steps(10,end)}html[data-usa-pt="pixel"] ::view-transition-new(root){animation-name:usa-pt-pixel-in;animation-timing-function:steps(10,end)}@property --usa-blind{syntax:"<length-percentage>";inherits:false;initial-value:0vh}@keyframes usa-pt-out-left{to{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-in-right{from{transform:translateX(30%);opacity:0}}@keyframes usa-pt-out-right{to{transform:translateX(30%);opacity:0}}@keyframes usa-pt-in-left{from{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-out-up{to{transform:translateY(-12%);opacity:0}}@keyframes usa-pt-in-up{from{transform:translateY(12%);opacity:0}}@keyframes usa-pt-zoom-out{to{transform:scale(0.92);opacity:0}}@keyframes usa-pt-zoom-in{from{transform:scale(1.08);opacity:0}}@keyframes usa-pt-circle{from{clip-path:circle(0 at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}to{clip-path:circle(var(--usa-pt-r,150vmax) at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}}@keyframes usa-pt-blinds{from{--usa-blind:0vh}to{--usa-blind:10vh}}@keyframes usa-pt-pixel-out{to{opacity:0;filter:blur(6px) contrast(1.4)}}@keyframes usa-pt-pixel-in{from{opacity:0;filter:blur(6px) contrast(1.4)}}@media (prefers-reduced-motion:reduce){::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none !important}}
|
|
69
69
|
usa-timeline{display:block}usa-timeline[scrub]{position:relative}@media (prefers-reduced-motion:reduce){usa-timeline [data-tl]{opacity:1 !important;transform:none !important;filter:none !important;clip-path:none !important}}
|
|
70
|
+
usa-swipeable{display:block;touch-action:pan-y;user-select:none;-webkit-user-select:none}usa-swipeable[axis="y"]{touch-action:pan-x}usa-swipeable>*{transform:translate3d(var(--usa-swipe,0px),0,0);opacity:calc(1 - var(--usa-swipe-p,0) * 0.5)}usa-swipeable[axis="y"]>*{transform:translate3d(0,var(--usa-swipe,0px),0)}usa-swipeable:focus-visible{outline:2px solid currentColor;outline-offset:2px}usa-pinch-zoom{display:block;overflow:hidden;touch-action:none;position:relative}usa-pinch-zoom>*{transform:translate3d(var(--usa-zoom-x,0px),var(--usa-zoom-y,0px),0) scale(var(--usa-zoom,1));transform-origin:50% 50%}usa-pinch-zoom[data-zoomed]{cursor:grab}usa-pinch-zoom:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
|
71
|
+
usa-draw{display:inline-block}usa-draw svg :is(path,line,polyline,polygon,circle,ellipse,rect){transition:fill-opacity 0.6s ease}usa-draw[fill]:not([data-drawn]) svg :is(path,polygon,circle,ellipse,rect){fill-opacity:0}usa-morph{display:inline-block;line-height:0}usa-morph svg{width:100%;height:100%;fill:currentColor}usa-morph[role="button"]{cursor:pointer}usa-mask-reveal{display:block}usa-mask-reveal[data-state="visible"]{clip-path:none !important}usa-anim-icon{display:inline-flex;line-height:0;vertical-align:middle}usa-anim-icon svg{overflow:visible}@media (prefers-reduced-motion:reduce){usa-mask-reveal{clip-path:none !important}usa-draw svg *{stroke-dashoffset:0 !important}}
|
package/dist/components.d.cts
CHANGED
|
@@ -1891,6 +1891,229 @@ declare global {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
1893
|
|
|
1894
|
+
interface PanState {
|
|
1895
|
+
/** Offset from the gesture start (px). */
|
|
1896
|
+
dx: number;
|
|
1897
|
+
dy: number;
|
|
1898
|
+
/** Velocity (px/s). */
|
|
1899
|
+
vx: number;
|
|
1900
|
+
vy: number;
|
|
1901
|
+
first: boolean;
|
|
1902
|
+
last: boolean;
|
|
1903
|
+
event: Event;
|
|
1904
|
+
}
|
|
1905
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
1906
|
+
interface SwipeState {
|
|
1907
|
+
direction: SwipeDirection;
|
|
1908
|
+
velocity: number;
|
|
1909
|
+
dx: number;
|
|
1910
|
+
dy: number;
|
|
1911
|
+
}
|
|
1912
|
+
interface PinchState {
|
|
1913
|
+
scale: number; /** Midpoint of the two pointers (client px). */
|
|
1914
|
+
x: number;
|
|
1915
|
+
y: number;
|
|
1916
|
+
first: boolean;
|
|
1917
|
+
last: boolean;
|
|
1918
|
+
}
|
|
1919
|
+
interface PressState {
|
|
1920
|
+
x: number;
|
|
1921
|
+
y: number;
|
|
1922
|
+
}
|
|
1923
|
+
interface GestureHandlers {
|
|
1924
|
+
onPan?: (s: PanState) => void;
|
|
1925
|
+
onSwipe?: (s: SwipeState) => void;
|
|
1926
|
+
onPinch?: (s: PinchState) => void;
|
|
1927
|
+
onLongPress?: (s: PressState) => void;
|
|
1928
|
+
onTap?: (s: PressState) => void;
|
|
1929
|
+
onDoubleTap?: (s: PressState) => void;
|
|
1930
|
+
}
|
|
1931
|
+
interface GestureOptions {
|
|
1932
|
+
/** Restrict panning to an axis. */
|
|
1933
|
+
axis?: 'x' | 'y';
|
|
1934
|
+
/** Movement (px) before a pan starts (default 4). */
|
|
1935
|
+
threshold?: number;
|
|
1936
|
+
/** Minimum distance (px, default 40) and speed (px/s, default 300) for a swipe. */
|
|
1937
|
+
swipeDistance?: number;
|
|
1938
|
+
swipeVelocity?: number;
|
|
1939
|
+
/** Long-press delay (ms, default 500). */
|
|
1940
|
+
longPress?: number;
|
|
1941
|
+
/** Ctrl/⌘ + wheel (trackpad pinch) counts as pinch (default true). */
|
|
1942
|
+
wheelPinch?: boolean;
|
|
1943
|
+
}
|
|
1944
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
1945
|
+
declare function swipeDirection(dx: number, dy: number, vx: number, vy: number, o?: {
|
|
1946
|
+
distance?: number;
|
|
1947
|
+
velocity?: number;
|
|
1948
|
+
axis?: 'x' | 'y';
|
|
1949
|
+
}): SwipeState | null;
|
|
1950
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
1951
|
+
declare function pinchScale(startDistance: number, distance: number, base?: number, min?: number, max?: number): number;
|
|
1952
|
+
/**
|
|
1953
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
1954
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
1955
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
1956
|
+
* through Pointer Events. Returns a cleanup function.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
1960
|
+
* gesture(card, {
|
|
1961
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
1962
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
1963
|
+
* }, { axis: 'x' });
|
|
1964
|
+
*/
|
|
1965
|
+
declare function gesture(el: HTMLElement, h: GestureHandlers, o?: GestureOptions): () => void;
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
1969
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
1970
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
1971
|
+
*
|
|
1972
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
1973
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
1974
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
1975
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
1976
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
1977
|
+
*/
|
|
1978
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
1979
|
+
swipe(direction: SwipeDirection): void;
|
|
1980
|
+
reset(): void;
|
|
1981
|
+
readonly offset: number;
|
|
1982
|
+
}
|
|
1983
|
+
declare function defineSwipeable(tag?: string): CustomElementConstructor | undefined;
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
1987
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
1988
|
+
* scale and position spring back inside the bounds on release.
|
|
1989
|
+
*
|
|
1990
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
1991
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
1992
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
1993
|
+
*/
|
|
1994
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
1995
|
+
readonly scale: number;
|
|
1996
|
+
zoomTo(scale: number): void;
|
|
1997
|
+
}
|
|
1998
|
+
declare function definePinchZoom(tag?: string): CustomElementConstructor | undefined;
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* use-scroll-animate/components/gesture — unified gestures (v3.2).
|
|
2002
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
2003
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
2004
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
2005
|
+
*/
|
|
2006
|
+
|
|
2007
|
+
/** Register every component of this category under its default tag. */
|
|
2008
|
+
declare function defineGestureComponents(): void;
|
|
2009
|
+
declare global {
|
|
2010
|
+
interface HTMLElementTagNameMap {
|
|
2011
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
2012
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* `<usa-draw>` — line drawing: every stroke of the SVG inside draws itself.
|
|
2018
|
+
* Attributes: `trigger` (`view` default · `hover` · `click` · `scrub`),
|
|
2019
|
+
* `duration` (1600), `stagger` (0–0.9 share of the timeline, 0.2), `fill`
|
|
2020
|
+
* (fade the fill in after drawing), `repeat`. Method `play()`, property
|
|
2021
|
+
* `progress`, event `usa:complete`. Reduced motion: drawn immediately.
|
|
2022
|
+
*/
|
|
2023
|
+
interface UsaDrawElement extends UsaElement {
|
|
2024
|
+
play(): void;
|
|
2025
|
+
progress: number;
|
|
2026
|
+
}
|
|
2027
|
+
declare function defineDraw(tag?: string): CustomElementConstructor | undefined;
|
|
2028
|
+
|
|
2029
|
+
/**
|
|
2030
|
+
* `<usa-morph>` — morphs an SVG path through a list of shapes.
|
|
2031
|
+
* Put a `<svg><path></path></svg>` inside (one is created otherwise) and set
|
|
2032
|
+
* `paths="M… | M… | M…"` (same command structure morphs smoothly, others
|
|
2033
|
+
* switch at the midpoint). Attributes: `trigger` (`click` default · `hover`
|
|
2034
|
+
* · `auto` · `view`), `interval` (ms for auto, 2000), `duration` (600).
|
|
2035
|
+
* Property `index`, method `next()`, event `usa:change`.
|
|
2036
|
+
* Reduced motion: shapes switch without animating; `auto` does not cycle.
|
|
2037
|
+
*/
|
|
2038
|
+
interface UsaMorphElement extends UsaElement {
|
|
2039
|
+
readonly index: number;
|
|
2040
|
+
next(): Promise<void>;
|
|
2041
|
+
}
|
|
2042
|
+
declare function defineMorph(tag?: string): CustomElementConstructor | undefined;
|
|
2043
|
+
|
|
2044
|
+
/** Clip-path start / end frames for each reveal shape. */
|
|
2045
|
+
declare const MASK_SHAPES: Record<string, [string, string]>;
|
|
2046
|
+
/**
|
|
2047
|
+
* `<usa-mask-reveal>` — reveals its content through a growing mask shape.
|
|
2048
|
+
* Attributes: `shape` (`circle` default · `diamond` · `wipe` · `wipe-up` ·
|
|
2049
|
+
* `iris` · `star`), `duration` (900), `delay`, `trigger` (`view` · `hover`
|
|
2050
|
+
* · `click`), `repeat`, `at` (`x% y%` origin for circle). Event
|
|
2051
|
+
* `usa:complete`. Reduced motion: content is shown without the mask.
|
|
2052
|
+
*/
|
|
2053
|
+
interface UsaMaskRevealElement extends UsaElement {
|
|
2054
|
+
reveal(): Promise<void>;
|
|
2055
|
+
}
|
|
2056
|
+
declare function defineMaskReveal(tag?: string): CustomElementConstructor | undefined;
|
|
2057
|
+
|
|
2058
|
+
type Icon = {
|
|
2059
|
+
d: string;
|
|
2060
|
+
frames: Keyframe[];
|
|
2061
|
+
duration: number;
|
|
2062
|
+
origin?: string;
|
|
2063
|
+
};
|
|
2064
|
+
/** Built-in animated icons (24×24 strokes) and the motion each one plays. */
|
|
2065
|
+
declare const ANIM_ICONS: Record<string, Icon>;
|
|
2066
|
+
/**
|
|
2067
|
+
* `<usa-anim-icon name="bell">` — an animated stroke icon that plays its
|
|
2068
|
+
* motion on `trigger` (`hover` default · `click` · `view` · `loop`).
|
|
2069
|
+
* Attributes: `name` (see `ANIM_ICONS`), `size` (24), `label` (accessible
|
|
2070
|
+
* name; decorative when absent). Method `play()`. Reduced motion: static.
|
|
2071
|
+
*/
|
|
2072
|
+
interface UsaAnimIconElement extends UsaElement {
|
|
2073
|
+
play(): void;
|
|
2074
|
+
}
|
|
2075
|
+
declare function defineAnimIcon(tag?: string): CustomElementConstructor | undefined;
|
|
2076
|
+
|
|
2077
|
+
/** `true` when two path strings share the same commands (so their numbers can be interpolated). */
|
|
2078
|
+
declare function pathsCompatible(a: string, b: string): boolean;
|
|
2079
|
+
/**
|
|
2080
|
+
* Path data between `a` and `b` at `t` (0–1). Paths with the same command
|
|
2081
|
+
* structure morph number-by-number; others switch at the midpoint.
|
|
2082
|
+
*/
|
|
2083
|
+
declare function interpolatePath(a: string, b: string, t: number): string;
|
|
2084
|
+
interface MorphOptions {
|
|
2085
|
+
duration?: number;
|
|
2086
|
+
easing?: (t: number) => number;
|
|
2087
|
+
}
|
|
2088
|
+
/** Animate a `<path>`'s `d` to `to`. Resolves when done; instant under reduced motion. */
|
|
2089
|
+
declare function morphTo(path: SVGPathElement | Element, to: string, o?: MorphOptions): Promise<void>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Prepare every stroke in `root` for line drawing (normalised `pathLength=1`,
|
|
2092
|
+
* so no `getTotalLength()` is needed) and return a function that sets
|
|
2093
|
+
* progress 0–1, optionally staggered between shapes.
|
|
2094
|
+
*/
|
|
2095
|
+
declare function drawLines(root: Element, o?: {
|
|
2096
|
+
stagger?: number;
|
|
2097
|
+
}): (progress: number) => void;
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* use-scroll-animate/components/svg — SVG animation (v3.3).
|
|
2101
|
+
* `<usa-draw>` (line drawing), `<usa-morph>` (path morph), `<usa-mask-reveal>`
|
|
2102
|
+
* (mask / clip-path reveals) and `<usa-anim-icon>` (animated icons), plus
|
|
2103
|
+
* `interpolatePath()`, `morphTo()`, `drawLines()`.
|
|
2104
|
+
*/
|
|
2105
|
+
|
|
2106
|
+
/** Register every component of this category under its default tag. */
|
|
2107
|
+
declare function defineSvgComponents(): void;
|
|
2108
|
+
declare global {
|
|
2109
|
+
interface HTMLElementTagNameMap {
|
|
2110
|
+
'usa-draw': UsaDrawElement;
|
|
2111
|
+
'usa-morph': UsaMorphElement;
|
|
2112
|
+
'usa-mask-reveal': UsaMaskRevealElement;
|
|
2113
|
+
'usa-anim-icon': UsaAnimIconElement;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
1894
2117
|
/** The component categories and their default tags. */
|
|
1895
2118
|
declare const COMPONENT_CATEGORIES: {
|
|
1896
2119
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1905,6 +2128,8 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1905
2128
|
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
1906
2129
|
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
1907
2130
|
readonly timeline: readonly ["usa-timeline"];
|
|
2131
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
2132
|
+
readonly svg: readonly ["usa-draw", "usa-morph", "usa-mask-reveal", "usa-anim-icon"];
|
|
1908
2133
|
};
|
|
1909
2134
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1910
2135
|
|
|
@@ -1914,5 +2139,5 @@ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
|
1914
2139
|
*/
|
|
1915
2140
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
1916
2141
|
|
|
1917
|
-
export { AMBIENT_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, easeOutExpo, enableMpaTransitions, flip, fluentPreset, getMotionIntensity, haptic, linearEasing, loadingBar, morphPath, pageTransition, prefersReducedMotion, projectInertia, readScrollProgress, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, themeTransition, timeline, toast, viewTransition };
|
|
1918
|
-
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, MotionIntensity, PageEffect, PageTransitionOptions, Placement, RevealEffect, ScrubOptions, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaTimelineElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|
|
2142
|
+
export { AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, drawLines, easeOutExpo, enableMpaTransitions, flip, fluentPreset, gesture, getMotionIntensity, haptic, interpolatePath, linearEasing, loadingBar, morphPath, morphTo, pageTransition, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
2143
|
+
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, GestureHandlers, GestureOptions, MorphOptions, MotionIntensity, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, PressState, RevealEffect, ScrubOptions, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, SwipeDirection, SwipeState, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAnimIconElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMaskRevealElement, UsaMorphElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPinchZoomElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaSwipeableElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaTimelineElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|