@yorozu/animations 0.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/LICENSE +21 -0
- package/README.md +199 -0
- package/index.d.ts +1 -0
- package/index.js +2229 -0
- package/package.json +21 -0
- package/playground/src/catalog.d.ts +8 -0
- package/playground/src/level-switch.d.ts +1 -0
- package/playground/src/level.d.ts +7 -0
- package/playground/src/main.d.ts +0 -0
- package/playground/src/overlay.d.ts +2 -0
- package/playground/src/testers/digit-flip.d.ts +1 -0
- package/playground/src/testers/dock.d.ts +1 -0
- package/playground/src/testers/fade.d.ts +1 -0
- package/playground/src/testers/list-layer.d.ts +1 -0
- package/playground/src/testers/list-reorder.d.ts +1 -0
- package/playground/src/testers/pinch-zoom.d.ts +1 -0
- package/playground/src/testers/popover.d.ts +1 -0
- package/playground/src/testers/presence-pop.d.ts +1 -0
- package/playground/src/testers/ripple.d.ts +1 -0
- package/playground/src/testers/scroll-tween.d.ts +1 -0
- package/playground/src/testers/send-flight.d.ts +1 -0
- package/playground/src/testers/shared-element.d.ts +1 -0
- package/playground/src/testers/sliding-indicator.d.ts +1 -0
- package/playground/src/testers/spoiler.d.ts +1 -0
- package/playground/src/testers/swipe-reveal.d.ts +1 -0
- package/playground/src/testers/tabs.d.ts +1 -0
- package/playground/src/testers/view-slide-modes.d.ts +3 -0
- package/playground/src/testers/view-slide.d.ts +1 -0
- package/playground/src/testers/waveform.d.ts +1 -0
- package/src/core/level.d.ts +10 -0
- package/src/core/playback.d.ts +7 -0
- package/src/core/raf.d.ts +1 -0
- package/src/core/reduced-motion.d.ts +1 -0
- package/src/core/styles.d.ts +2 -0
- package/src/core/tween.d.ts +11 -0
- package/src/core/types.d.ts +9 -0
- package/src/digit-flip/play.d.ts +12 -0
- package/src/digit-flip/slots.d.ts +14 -0
- package/src/dock/dock.d.ts +23 -0
- package/src/dock/transforms.d.ts +14 -0
- package/src/fade/fade.d.ts +11 -0
- package/src/index.d.ts +45 -0
- package/src/list-reorder/classify.d.ts +10 -0
- package/src/list-reorder/reorder.d.ts +19 -0
- package/src/pinch-zoom/math.d.ts +21 -0
- package/src/pinch-zoom/pinch.d.ts +15 -0
- package/src/popover/popover.d.ts +14 -0
- package/src/rect/fit.d.ts +5 -0
- package/src/rect/types.d.ts +17 -0
- package/src/ripple/ripple.d.ts +13 -0
- package/src/scroll-tween/scroll.d.ts +8 -0
- package/src/send-flight/flight.d.ts +14 -0
- package/src/shared-element/math.d.ts +45 -0
- package/src/shared-element/player.d.ts +52 -0
- package/src/sliding-indicator/indicator.d.ts +15 -0
- package/src/spoiler/spoiler.d.ts +14 -0
- package/src/swipe-reveal/swipe.d.ts +16 -0
- package/src/view-slide/session.d.ts +27 -0
- package/src/view-slide/transforms.d.ts +34 -0
- package/src/waveform/decode.d.ts +2 -0
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yorozu/animations",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "framework-agnostic compositor motion primitives",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"default": "./index.js"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"author": "inshinrei",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/inshinrei/yorozu.git"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountLevelSwitch(host: HTMLElement): () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnimationLevel } from '../../src/index.ts';
|
|
2
|
+
export declare let LEVEL_KEY: string;
|
|
3
|
+
type Listener = (level: AnimationLevel) => void;
|
|
4
|
+
export declare function getAnimationLevel(): AnimationLevel;
|
|
5
|
+
export declare function setAnimationLevel(next: AnimationLevel): void;
|
|
6
|
+
export declare function subscribeAnimationLevel(listener: Listener): () => void;
|
|
7
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountDigitFlip(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountDock(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountFade(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountListLayer(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountListReorder(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountPinchZoom(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountPopover(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountPresencePop(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountRipple(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountScrollTween(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountSendFlight(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountSharedElement(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountSlidingIndicator(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountSpoiler(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountSwipeReveal(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountTabs(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountViewSlide(root: HTMLElement): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mountWaveform(root: HTMLElement): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type AnimationLevel = "low" | "med" | "high";
|
|
2
|
+
export declare const ANIMATION_LEVELS: readonly AnimationLevel[];
|
|
3
|
+
export declare const DEFAULT_ANIMATION_LEVEL: AnimationLevel;
|
|
4
|
+
export declare function isAnimationLevel(value: unknown): value is AnimationLevel;
|
|
5
|
+
export declare function parseAnimationLevel(raw: unknown): AnimationLevel | null;
|
|
6
|
+
export declare function defaultAnimationLevel(prefersReduced: boolean): AnimationLevel;
|
|
7
|
+
export declare function cycleAnimationLevel(level: AnimationLevel): AnimationLevel;
|
|
8
|
+
export declare function canAnimate(level: AnimationLevel): boolean;
|
|
9
|
+
export declare function pickAnimationLevelFromRatio(t: number): AnimationLevel;
|
|
10
|
+
export declare function stepAnimationLevel(level: AnimationLevel, delta: number): AnimationLevel;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Playback } from './types';
|
|
2
|
+
export declare function createPlayback(): {
|
|
3
|
+
playback: Playback;
|
|
4
|
+
resolve: (ran: boolean) => void;
|
|
5
|
+
isCancelled: () => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function animateElement(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dualRaf(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prefersReducedMotion(): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Playback } from './types';
|
|
2
|
+
export declare function easeOutCubic(t: number): number;
|
|
3
|
+
export declare function lerp(from: number, to: number, t: number): number;
|
|
4
|
+
export type TweenOptions = {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
easing?: (t: number) => number;
|
|
9
|
+
onUpdate: (value: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function tween(options: TweenOptions): Playback;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const DIGIT_FLIP_EASING: string;
|
|
3
|
+
export declare const PRESENCE_POP_MS: number;
|
|
4
|
+
export declare const PRESENCE_POP_EASING: string;
|
|
5
|
+
export declare function playDigitFlip(el: HTMLElement, options?: {
|
|
6
|
+
durationMs?: number;
|
|
7
|
+
easing?: string;
|
|
8
|
+
}): Playback;
|
|
9
|
+
export declare function playPresencePop(el: HTMLElement, options?: {
|
|
10
|
+
durationMs?: number;
|
|
11
|
+
easing?: string;
|
|
12
|
+
}): Playback;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const DIGIT_FLIP_MS: number;
|
|
2
|
+
export declare const MAX_SIMULTANEOUS_DIGIT_FLIPS: number;
|
|
3
|
+
export type DigitSlot = {
|
|
4
|
+
kind: "static";
|
|
5
|
+
char: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "flip";
|
|
8
|
+
char: string;
|
|
9
|
+
prevChar: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function buildDigitSlots(text: string, prevText: string | undefined, shouldAnimate: boolean): DigitSlot[];
|
|
12
|
+
export declare function formatCounterText(value: number): string;
|
|
13
|
+
export declare function shouldPresencePop(prev: number | undefined, next: number): boolean;
|
|
14
|
+
export declare function scheduleDigitFlip(condition: boolean): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
import { DockEdge, DockMode } from './transforms';
|
|
3
|
+
export type { DockEdge, DockMode, DockPanelState, DockTransforms } from './transforms';
|
|
4
|
+
export { DOCK_EASING, DOCK_FADE_OFFSET, DOCK_MS, dockTransforms } from './transforms';
|
|
5
|
+
export type DockConfig = {
|
|
6
|
+
getMode: () => DockMode;
|
|
7
|
+
edge?: DockEdge;
|
|
8
|
+
durationMs?: number;
|
|
9
|
+
easing?: string;
|
|
10
|
+
};
|
|
11
|
+
export type DockHandle = {
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type Dock = {
|
|
15
|
+
readonly mounted: boolean;
|
|
16
|
+
readonly leaving: boolean;
|
|
17
|
+
readonly animating: boolean;
|
|
18
|
+
setOpen: (open: boolean) => Playback;
|
|
19
|
+
attach: (panel: HTMLElement) => DockHandle;
|
|
20
|
+
attachBackdrop: (el: HTMLElement) => DockHandle;
|
|
21
|
+
destroy: () => void;
|
|
22
|
+
};
|
|
23
|
+
export declare function createDock(config: DockConfig): Dock;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DockMode = "none" | "fade" | "slide";
|
|
2
|
+
export type DockEdge = "right" | "left" | "top" | "bottom";
|
|
3
|
+
export type DockPanelState = {
|
|
4
|
+
transform: string;
|
|
5
|
+
opacity: string;
|
|
6
|
+
};
|
|
7
|
+
export type DockTransforms = {
|
|
8
|
+
closed: DockPanelState;
|
|
9
|
+
open: DockPanelState;
|
|
10
|
+
};
|
|
11
|
+
export declare const DOCK_FADE_OFFSET: string;
|
|
12
|
+
export declare const DOCK_MS: number;
|
|
13
|
+
export declare const DOCK_EASING: string;
|
|
14
|
+
export declare function dockTransforms(mode: Exclude<DockMode, "none">, edge: DockEdge): DockTransforms;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const FADE_MS: number;
|
|
3
|
+
export declare const FADE_EASING: string;
|
|
4
|
+
export type FadeOptions = {
|
|
5
|
+
durationMs?: number;
|
|
6
|
+
easing?: string;
|
|
7
|
+
};
|
|
8
|
+
export type Fade = {
|
|
9
|
+
setVisible: (visible: boolean) => Playback;
|
|
10
|
+
};
|
|
11
|
+
export declare function createFade(el: HTMLElement, options?: FadeOptions): Fade;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type { AttachHandle, Key, Playback } from './core/types';
|
|
2
|
+
export { prefersReducedMotion } from './core/reduced-motion';
|
|
3
|
+
export { dualRaf } from './core/raf';
|
|
4
|
+
export type { AnimationLevel } from './core/level';
|
|
5
|
+
export { ANIMATION_LEVELS, DEFAULT_ANIMATION_LEVEL, isAnimationLevel, parseAnimationLevel, defaultAnimationLevel, cycleAnimationLevel, canAnimate, pickAnimationLevelFromRatio, stepAnimationLevel, } from './core/level';
|
|
6
|
+
export type { TweenOptions } from './core/tween';
|
|
7
|
+
export { easeOutCubic, lerp, tween } from './core/tween';
|
|
8
|
+
export type { Rect, Size, Insets, ObjectFit } from './rect/types';
|
|
9
|
+
export { fitContain, centerFitInViewport } from './rect/fit';
|
|
10
|
+
export type { Flight, OpenFlightOpts, CloseFlightOpts } from './shared-element/math';
|
|
11
|
+
export { uncoverByAspect, computeFlight, resolveNaturalSize, computeOpenFlight, computeCloseFlight, isRectFullyVisibleIn, isRectInViewport, offViewportLandingRect, } from './shared-element/math';
|
|
12
|
+
export type { SharedElementSeed, SharedElementPlayOptions, SharedElementController } from './shared-element/player';
|
|
13
|
+
export { SHARED_ELEMENT_MS, SHARED_ELEMENT_EASING, SHARED_ELEMENT_END_MS, createSharedElement, playSharedElement, } from './shared-element/player';
|
|
14
|
+
export type { SlideDirection, ViewSlideMode, ViewSlideKind, ViewSlideMountPolicy, PanelRole, SlidePanelState, SlideTransforms, } from './view-slide/transforms';
|
|
15
|
+
export { VIEW_SLIDE_FADE_OFFSET, VIEW_SLIDE_MS, VIEW_SLIDE_EASING, VIEW_SLIDE_COVER_MS, VIEW_SLIDE_COVER_EASING, VIEW_SLIDE_ZOOM_MS, VIEW_SLIDE_ZOOM_EASING, VIEW_SLIDE_REVEAL_MS, VIEW_SLIDE_REVEAL_EASING, slideDirectionByIndex, resolveViewSlideMode, viewSlideDurationMs, viewSlideEasing, viewSlideTransforms, } from './view-slide/transforms';
|
|
16
|
+
export type { ViewSlideConfig, ViewSlide } from './view-slide/session';
|
|
17
|
+
export { VIEW_SLIDE_SETTLE_SLACK_MS, createViewSlide } from './view-slide/session';
|
|
18
|
+
export type { SlidingIndicator, SlidingIndicatorOptions } from './sliding-indicator/indicator';
|
|
19
|
+
export { INDICATOR_MS, INDICATOR_EASING, createSlidingIndicator, } from './sliding-indicator/indicator';
|
|
20
|
+
export type { ReorderAnimKind, OrderDiffByKey } from './list-reorder/classify';
|
|
21
|
+
export { buildOrderDiff, classifyReorderAnim } from './list-reorder/classify';
|
|
22
|
+
export type { ListReorder } from './list-reorder/reorder';
|
|
23
|
+
export { LIST_REORDER_MS, LIST_REORDER_EASING, LIST_REORDER_EPSILON_PX, createListReorder, } from './list-reorder/reorder';
|
|
24
|
+
export type { Fade, FadeOptions } from './fade/fade';
|
|
25
|
+
export { FADE_MS, FADE_EASING, createFade } from './fade/fade';
|
|
26
|
+
export type { Dock, DockConfig, DockEdge, DockHandle, DockMode, DockPanelState, DockTransforms, } from './dock/dock';
|
|
27
|
+
export { DOCK_EASING, DOCK_FADE_OFFSET, DOCK_MS, createDock, dockTransforms } from './dock/dock';
|
|
28
|
+
export type { Popover, PopoverPlayOptions } from './popover/popover';
|
|
29
|
+
export { POPOVER_EASING, POPOVER_MS, POPOVER_ORIGIN, createPopover } from './popover/popover';
|
|
30
|
+
export type { DigitSlot } from './digit-flip/slots';
|
|
31
|
+
export { DIGIT_FLIP_MS, MAX_SIMULTANEOUS_DIGIT_FLIPS, buildDigitSlots, formatCounterText, scheduleDigitFlip, shouldPresencePop, } from './digit-flip/slots';
|
|
32
|
+
export { DIGIT_FLIP_EASING, PRESENCE_POP_EASING, PRESENCE_POP_MS, playDigitFlip, playPresencePop, } from './digit-flip/play';
|
|
33
|
+
export type { SendFlightOptions } from './send-flight/flight';
|
|
34
|
+
export { SEND_FLIGHT_EASING, SEND_FLIGHT_MS, playSendFlight } from './send-flight/flight';
|
|
35
|
+
export type { SwipeReveal, SwipeRevealOptions } from './swipe-reveal/swipe';
|
|
36
|
+
export { SWIPE_MAX, SWIPE_THRESHOLD, SWIPE_TWEEN_MS, createSwipeReveal, rubberSwipeOffset, shouldCommitSwipe, } from './swipe-reveal/swipe';
|
|
37
|
+
export type { ScrollTweenOptions } from './scroll-tween/scroll';
|
|
38
|
+
export { SCROLL_TWEEN_MS, playScrollTween } from './scroll-tween/scroll';
|
|
39
|
+
export type { RippleOptions } from './ripple/ripple';
|
|
40
|
+
export { RIPPLE_COLOR, RIPPLE_EASING, RIPPLE_MS, RIPPLE_SIZE_PX, playRipple } from './ripple/ripple';
|
|
41
|
+
export type { Point, Translate, ZoomState, PinchZoom, PinchZoomConfig } from './pinch-zoom/pinch';
|
|
42
|
+
export { PINCH_MAX_SCALE, PINCH_MIN_SCALE, PINCH_WHEEL_FACTOR, boundTranslate, clampScale, createPinchZoom, maxTranslate, nextScaleFromWheel, resetZoom, zoomAtOrigin, zoomTransform, } from './pinch-zoom/pinch';
|
|
43
|
+
export { decodeWaveform, fitWaveform } from './waveform/decode';
|
|
44
|
+
export type { Spoiler, SpoilerOptions } from './spoiler/spoiler';
|
|
45
|
+
export { SPOILER_EASING, SPOILER_MS, createSpoiler } from './spoiler/spoiler';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Key } from '../core/types';
|
|
2
|
+
export type ReorderAnimKind = "move" | "opacity" | "none";
|
|
3
|
+
export type OrderDiffByKey = Map<Key, number>;
|
|
4
|
+
/** orderDiff = newIndex − oldIndex for keys in curr; new keys → −Infinity. */
|
|
5
|
+
export declare function buildOrderDiff(prev: Map<Key, number>, curr: Map<Key, number>): OrderDiffByKey;
|
|
6
|
+
/**
|
|
7
|
+
* Majority vertical direction → move; minority / non-finite → opacity; zero → none.
|
|
8
|
+
* Adjacent swap (1 up, 1 down): up is opacity, down is move.
|
|
9
|
+
*/
|
|
10
|
+
export declare function classifyReorderAnim(orderDiffByKey: OrderDiffByKey, key: Key): ReorderAnimKind;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AttachHandle, Key } from '../core/types';
|
|
2
|
+
export declare const LIST_REORDER_MS: number;
|
|
3
|
+
export declare const LIST_REORDER_EASING: string;
|
|
4
|
+
export declare const LIST_REORDER_EPSILON_PX: number;
|
|
5
|
+
export type ListReorder<T> = {
|
|
6
|
+
register: (el: HTMLElement, key: Key) => AttachHandle;
|
|
7
|
+
sync: (items: readonly T[]) => void;
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function createListReorder<T>(options: {
|
|
12
|
+
getItemHeight: () => number;
|
|
13
|
+
getKey: (item: T, index: number) => Key;
|
|
14
|
+
isEnabled?: () => boolean;
|
|
15
|
+
isReduced?: () => boolean;
|
|
16
|
+
isSuppressed?: () => boolean;
|
|
17
|
+
durationMs?: number;
|
|
18
|
+
easing?: string;
|
|
19
|
+
}): ListReorder<T>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const PINCH_MIN_SCALE: number;
|
|
2
|
+
export declare const PINCH_MAX_SCALE: number;
|
|
3
|
+
export declare const PINCH_WHEEL_FACTOR: number;
|
|
4
|
+
export type Point = {
|
|
5
|
+
offsetX: number;
|
|
6
|
+
offsetY: number;
|
|
7
|
+
};
|
|
8
|
+
export type Translate = {
|
|
9
|
+
translateX: number;
|
|
10
|
+
translateY: number;
|
|
11
|
+
};
|
|
12
|
+
export type ZoomState = Translate & {
|
|
13
|
+
scale: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function clampScale(scale: number, min: number, max: number): number;
|
|
16
|
+
export declare function maxTranslate(scale: number, layoutW: number, layoutH: number, viewportW: number, viewportH: number): Translate;
|
|
17
|
+
export declare function boundTranslate(translateX: number, translateY: number, scale: number, layoutW: number, layoutH: number, viewportW: number, viewportH: number): Translate;
|
|
18
|
+
export declare function zoomAtOrigin(state: ZoomState, nextScale: number, origin: Point | null | undefined, layoutW: number, layoutH: number, viewportW: number, viewportH: number, minScale?: number, maxScale?: number): ZoomState;
|
|
19
|
+
export declare function resetZoom(): ZoomState;
|
|
20
|
+
export declare function zoomTransform(state: ZoomState): string;
|
|
21
|
+
export declare function nextScaleFromWheel(scale: number, deltaY: number, minScale?: number, maxScale?: number): number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Size } from '../rect/types';
|
|
2
|
+
import { ZoomState } from './math';
|
|
3
|
+
export type { Point, Translate, ZoomState } from './math';
|
|
4
|
+
export { PINCH_MAX_SCALE, PINCH_MIN_SCALE, PINCH_WHEEL_FACTOR, boundTranslate, clampScale, maxTranslate, nextScaleFromWheel, resetZoom, zoomAtOrigin, zoomTransform, } from './math';
|
|
5
|
+
export type PinchZoomConfig = {
|
|
6
|
+
getEl: () => HTMLElement | null;
|
|
7
|
+
getLayout: () => Size;
|
|
8
|
+
getViewport: () => Size;
|
|
9
|
+
};
|
|
10
|
+
export type PinchZoom = {
|
|
11
|
+
setState: (next: ZoomState) => ZoomState;
|
|
12
|
+
reset: () => ZoomState;
|
|
13
|
+
destroy: () => void;
|
|
14
|
+
};
|
|
15
|
+
export declare function createPinchZoom(config: PinchZoomConfig): PinchZoom;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const POPOVER_MS: number;
|
|
3
|
+
export declare const POPOVER_EASING: string;
|
|
4
|
+
export declare const POPOVER_ORIGIN: string;
|
|
5
|
+
export type PopoverPlayOptions = {
|
|
6
|
+
origin?: string;
|
|
7
|
+
durationMs?: number;
|
|
8
|
+
easing?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Popover = {
|
|
11
|
+
playOpen: (el: HTMLElement, options?: PopoverPlayOptions) => Playback;
|
|
12
|
+
playClose: (el: HTMLElement, options?: PopoverPlayOptions) => Playback;
|
|
13
|
+
};
|
|
14
|
+
export declare function createPopover(): Popover;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Insets, Rect, Size } from './types';
|
|
2
|
+
/** Fit natural size into box without upscaling past natural (CSS contain-like). */
|
|
3
|
+
export declare function fitContain(natural: Size, box: Size): Size | null;
|
|
4
|
+
/** Center a fitted size inside a padded viewport. */
|
|
5
|
+
export declare function centerFitInViewport(fit: Size, viewport: Size, insets: Insets): Rect;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Rect = {
|
|
2
|
+
top: number;
|
|
3
|
+
left: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export type Size = {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
export type Insets = {
|
|
12
|
+
top: number;
|
|
13
|
+
right: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
left: number;
|
|
16
|
+
};
|
|
17
|
+
export type ObjectFit = "cover" | "contain";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const RIPPLE_MS: number;
|
|
3
|
+
export declare const RIPPLE_EASING: string;
|
|
4
|
+
export declare const RIPPLE_COLOR: string;
|
|
5
|
+
export declare const RIPPLE_SIZE_PX: number;
|
|
6
|
+
export type RippleOptions = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
durationMs?: number;
|
|
11
|
+
easing?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function playRipple(host: HTMLElement, options: RippleOptions): Playback;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const SCROLL_TWEEN_MS: number;
|
|
3
|
+
export type ScrollTweenOptions = {
|
|
4
|
+
left?: number;
|
|
5
|
+
top?: number;
|
|
6
|
+
durationMs?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function playScrollTween(el: HTMLElement, options: ScrollTweenOptions): Playback;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
import { Rect } from '../rect/types';
|
|
3
|
+
export declare const SEND_FLIGHT_MS: number;
|
|
4
|
+
export declare const SEND_FLIGHT_EASING: string;
|
|
5
|
+
export type SendFlightOptions = {
|
|
6
|
+
host: HTMLElement;
|
|
7
|
+
from: Rect;
|
|
8
|
+
to: Rect;
|
|
9
|
+
node?: HTMLElement;
|
|
10
|
+
imageUrl?: string | null;
|
|
11
|
+
durationMs?: number;
|
|
12
|
+
easing?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function playSendFlight(options: SendFlightOptions): Playback | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Insets, ObjectFit, Rect, Size } from '../rect/types';
|
|
2
|
+
export type Flight = {
|
|
3
|
+
to: Rect;
|
|
4
|
+
fromTranslateX: number;
|
|
5
|
+
fromTranslateY: number;
|
|
6
|
+
fromScaleX: number;
|
|
7
|
+
fromScaleY: number;
|
|
8
|
+
};
|
|
9
|
+
/** Expand a cover-cropped thumb so its aspect matches destination aspect. */
|
|
10
|
+
export declare function uncoverByAspect(aspectWidth: number, aspectHeight: number, thumb: Rect): Rect;
|
|
11
|
+
/** Center-based translate/scale so an element at `to` visually matches `from`. */
|
|
12
|
+
export declare function computeFlight(from: Rect, to: Rect): Flight | null;
|
|
13
|
+
/** Prefer natural size; fall back to thumb so fit is never empty. */
|
|
14
|
+
export declare function resolveNaturalSize(naturalWidth: number | undefined, naturalHeight: number | undefined, thumb: Rect): Size;
|
|
15
|
+
export type OpenFlightOpts = {
|
|
16
|
+
thumb: Rect;
|
|
17
|
+
naturalWidth?: number;
|
|
18
|
+
naturalHeight?: number;
|
|
19
|
+
objectFit: ObjectFit;
|
|
20
|
+
viewport: Size;
|
|
21
|
+
insets?: Insets;
|
|
22
|
+
/** Prefer live destination rect when already laid out. */
|
|
23
|
+
to?: Rect | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Open flight: (possibly uncovered) thumb → stage fit box (or explicit live `to`).
|
|
27
|
+
* Cover thumbs uncover against destination aspect so scale is uniform.
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeOpenFlight(opts: OpenFlightOpts): Flight | null;
|
|
30
|
+
export type CloseFlightOpts = {
|
|
31
|
+
fromStage: Rect;
|
|
32
|
+
thumb: Rect;
|
|
33
|
+
objectFit: ObjectFit;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Close flight: stage box → thumb.
|
|
37
|
+
* Cover uses Math.min(sx, sy) so the land crop matches.
|
|
38
|
+
*/
|
|
39
|
+
export declare function computeCloseFlight(opts: CloseFlightOpts): Flight | null;
|
|
40
|
+
/** Whether rect is fully inside clip (within epsilon). */
|
|
41
|
+
export declare function isRectFullyVisibleIn(rect: Rect, clip: Rect, epsilon?: number): boolean;
|
|
42
|
+
/** Whether rect intersects the viewport enough to land on. */
|
|
43
|
+
export declare function isRectInViewport(rect: Rect, viewport: Size, minVisiblePx?: number): boolean;
|
|
44
|
+
/** Off-viewport landing: fly above or below toward the thumb's side. */
|
|
45
|
+
export declare function offViewportLandingRect(from: Rect, thumb: Rect, viewportHeight: number): Rect;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
import { Insets, ObjectFit, Rect, Size } from '../rect/types';
|
|
3
|
+
export declare const SHARED_ELEMENT_MS: number;
|
|
4
|
+
export declare const SHARED_ELEMENT_EASING: string;
|
|
5
|
+
export declare const SHARED_ELEMENT_END_MS: number;
|
|
6
|
+
export type SharedElementSeed = {
|
|
7
|
+
rect: Rect;
|
|
8
|
+
imageUrl?: string | null;
|
|
9
|
+
objectFit?: ObjectFit;
|
|
10
|
+
naturalWidth?: number;
|
|
11
|
+
naturalHeight?: number;
|
|
12
|
+
};
|
|
13
|
+
export type SharedElementPlayOptions = {
|
|
14
|
+
host: HTMLElement;
|
|
15
|
+
from: Rect;
|
|
16
|
+
to: Rect;
|
|
17
|
+
imageUrl?: string | null;
|
|
18
|
+
objectFit?: ObjectFit;
|
|
19
|
+
durationMs?: number;
|
|
20
|
+
easing?: string;
|
|
21
|
+
fadeOut?: boolean;
|
|
22
|
+
roundedStart?: boolean;
|
|
23
|
+
roundedEnd?: boolean;
|
|
24
|
+
hideTarget?: HTMLElement | null;
|
|
25
|
+
onLand?: () => void | Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
export type SharedElementController = {
|
|
28
|
+
play: (opts: SharedElementPlayOptions) => Playback | null;
|
|
29
|
+
playOpen: (opts: {
|
|
30
|
+
host: HTMLElement;
|
|
31
|
+
seed: SharedElementSeed;
|
|
32
|
+
viewport?: Size;
|
|
33
|
+
insets?: Insets;
|
|
34
|
+
to?: Rect | null;
|
|
35
|
+
durationMs?: number;
|
|
36
|
+
hideTarget?: HTMLElement | null;
|
|
37
|
+
onLand?: () => void | Promise<void>;
|
|
38
|
+
}) => Playback | null;
|
|
39
|
+
playClose: (opts: {
|
|
40
|
+
host: HTMLElement;
|
|
41
|
+
fromStage: Rect;
|
|
42
|
+
target: SharedElementSeed | null;
|
|
43
|
+
imageUrl?: string | null;
|
|
44
|
+
fadeOut?: boolean;
|
|
45
|
+
durationMs?: number;
|
|
46
|
+
viewport?: Size;
|
|
47
|
+
hideTarget?: HTMLElement | null;
|
|
48
|
+
}) => Playback | null;
|
|
49
|
+
cancel: () => void;
|
|
50
|
+
};
|
|
51
|
+
export declare function createSharedElement(): SharedElementController;
|
|
52
|
+
export declare function playSharedElement(opts: SharedElementPlayOptions): Playback | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const INDICATOR_MS: number;
|
|
2
|
+
export declare const INDICATOR_EASING: string;
|
|
3
|
+
export type SlidingIndicator = {
|
|
4
|
+
measure: () => void;
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type SlidingIndicatorOptions = {
|
|
8
|
+
getTrack: () => HTMLElement | null;
|
|
9
|
+
getIndicator: () => HTMLElement | null;
|
|
10
|
+
getActive: () => HTMLElement | null;
|
|
11
|
+
enabled?: () => boolean;
|
|
12
|
+
durationMs?: number;
|
|
13
|
+
easing?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function createSlidingIndicator(options: SlidingIndicatorOptions): SlidingIndicator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Playback } from '../core/types';
|
|
2
|
+
export declare const SPOILER_MS: number;
|
|
3
|
+
export declare const SPOILER_EASING: string;
|
|
4
|
+
export type SpoilerOptions = {
|
|
5
|
+
revealed: () => boolean;
|
|
6
|
+
durationMs?: number;
|
|
7
|
+
easing?: string;
|
|
8
|
+
};
|
|
9
|
+
export type Spoiler = {
|
|
10
|
+
reveal: () => Playback;
|
|
11
|
+
reset: () => Playback;
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function createSpoiler(el: HTMLElement, options: SpoilerOptions): Spoiler;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const SWIPE_THRESHOLD: number;
|
|
2
|
+
export declare const SWIPE_MAX: number;
|
|
3
|
+
export declare const SWIPE_TWEEN_MS: number;
|
|
4
|
+
export declare function shouldCommitSwipe(offset: number, threshold: number): boolean;
|
|
5
|
+
export declare function rubberSwipeOffset(delta: number, max: number): number;
|
|
6
|
+
export type SwipeRevealOptions = {
|
|
7
|
+
axis?: "x";
|
|
8
|
+
threshold?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
durationMs?: number;
|
|
11
|
+
onCommit: () => void;
|
|
12
|
+
};
|
|
13
|
+
export type SwipeReveal = {
|
|
14
|
+
destroy: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function createSwipeReveal(el: HTMLElement, options: SwipeRevealOptions): SwipeReveal;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AttachHandle, Key } from '../core/types';
|
|
2
|
+
import { PanelRole, SlideDirection, SlidePanelState, SlideTransforms, ViewSlideMode, ViewSlideMountPolicy } from './transforms';
|
|
3
|
+
export { VIEW_SLIDE_COVER_EASING, VIEW_SLIDE_COVER_MS, VIEW_SLIDE_EASING, VIEW_SLIDE_MS } from './transforms';
|
|
4
|
+
export declare const VIEW_SLIDE_SETTLE_SLACK_MS: number;
|
|
5
|
+
export type { PanelRole, SlideDirection, SlidePanelState, SlideTransforms, ViewSlideMode, ViewSlideMountPolicy };
|
|
6
|
+
export type ViewSlideConfig = {
|
|
7
|
+
getMode: () => ViewSlideMode;
|
|
8
|
+
getDirection: (from: Key, to: Key) => SlideDirection | null;
|
|
9
|
+
transforms?: (dir: SlideDirection, mode: Exclude<ViewSlideMode, "none">) => SlideTransforms;
|
|
10
|
+
durationMs?: (mode: Exclude<ViewSlideMode, "none">) => number;
|
|
11
|
+
easing?: (mode: Exclude<ViewSlideMode, "none">) => string;
|
|
12
|
+
mountPolicy?: ViewSlideMountPolicy;
|
|
13
|
+
settleSlackMs?: number;
|
|
14
|
+
};
|
|
15
|
+
export type ViewSlide = {
|
|
16
|
+
readonly mountedKeys: readonly Key[];
|
|
17
|
+
readonly animating: boolean;
|
|
18
|
+
readonly leavingKey: Key | undefined;
|
|
19
|
+
setActive: (key: Key | undefined) => void;
|
|
20
|
+
attach: (el: HTMLElement, key: Key) => AttachHandle;
|
|
21
|
+
isMounted: (key: Key) => boolean;
|
|
22
|
+
isVisible: (key: Key) => boolean;
|
|
23
|
+
role: (key: Key) => PanelRole;
|
|
24
|
+
cancel: () => void;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
};
|
|
27
|
+
export declare function createViewSlide(config: ViewSlideConfig): ViewSlide;
|