@pg-labs-incubator/cobweb 0.0.0-stage → 0.0.2
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 +163 -0
- package/README.md +82 -2
- package/package.json +112 -3
- package/src/action/action.yaml +291 -0
- package/src/action/button-group.yaml +56 -0
- package/src/action/button.yaml +239 -0
- package/src/action/split-button.yaml +87 -0
- package/src/color/color.yaml +181 -0
- package/src/color/palette.yaml +147 -0
- package/src/container/card.yaml +170 -0
- package/src/container/corner-radius.yaml +50 -0
- package/src/container/elevation.yaml +19 -0
- package/src/design.yaml +41 -0
- package/src/feedback/feedback.yaml +225 -0
- package/src/icon/icon-font.yaml +28 -0
- package/src/icon/icon.yaml +31 -0
- package/src/input/date-picker.yaml +144 -0
- package/src/input/date-range-input.yaml +162 -0
- package/src/input/range-slider.yaml +161 -0
- package/src/input/select.yaml +230 -0
- package/src/input/slider.yaml +172 -0
- package/src/input/text-field.yaml +240 -0
- package/src/input/time-picker.yaml +220 -0
- package/src/motion/motion.yaml +371 -0
- package/src/navigation/app-bar.yaml +147 -0
- package/src/navigation/navigation.yaml +339 -0
- package/src/navigation/scroll.yaml +23 -0
- package/src/navigation/search.yaml +112 -0
- package/src/navigation/tabs.yaml +144 -0
- package/src/navigation/toolbar.yaml +130 -0
- package/src/selection/checkbox.yaml +162 -0
- package/src/selection/chip.yaml +219 -0
- package/src/selection/radio.yaml +125 -0
- package/src/selection/segmented-group.yaml +11 -0
- package/src/selection/segmented.yaml +69 -0
- package/src/selection/switch.yaml +209 -0
- package/src/spacing/measurement.yaml +80 -0
- package/src/state/state.yaml +38 -0
- package/src/surface/surface.yaml +483 -0
- package/src/text/line-height.yaml +144 -0
- package/src/text/typeface.yaml +31 -0
- package/src/text/typescale.yaml +726 -0
- package/target/esbuild/action/action.css +1 -0
- package/target/esbuild/action/base.jsx +1 -0
- package/target/esbuild/action/button.jsx +17 -0
- package/target/esbuild/action/fab-menu-context.jsx +1 -0
- package/target/esbuild/action/fab-menu.jsx +15 -0
- package/target/esbuild/action/fab.jsx +7 -0
- package/target/esbuild/action/group.jsx +22 -0
- package/target/esbuild/action/icon-button.jsx +5 -0
- package/target/esbuild/action/index.jsx +1 -0
- package/target/esbuild/action/split-button.jsx +12 -0
- package/target/esbuild/color/contrast.jsx +1 -0
- package/target/esbuild/color/dynamic.jsx +1 -0
- package/target/esbuild/color/hct.jsx +1 -0
- package/target/esbuild/color/index.css +1 -0
- package/target/esbuild/color/index.jsx +1 -0
- package/target/esbuild/color/palette.jsx +1 -0
- package/target/esbuild/color/scheme.jsx +1 -0
- package/target/esbuild/color/temperature.jsx +1 -0
- package/target/esbuild/container/card.css +1 -0
- package/target/esbuild/container/card.jsx +1 -0
- package/target/esbuild/container/elevation-shadow.css +1 -0
- package/target/esbuild/container/elevation-shadow.jsx +1 -0
- package/target/esbuild/container/index.jsx +1 -0
- package/target/esbuild/dom/client.jsx +1 -0
- package/target/esbuild/dom/index.jsx +1 -0
- package/target/esbuild/dom/server.jsx +1 -0
- package/target/esbuild/dom/types.jsx +1 -0
- package/target/esbuild/feedback/badge.jsx +15 -0
- package/target/esbuild/feedback/feedback.css +1 -0
- package/target/esbuild/feedback/focus.jsx +1 -0
- package/target/esbuild/feedback/index.jsx +1 -0
- package/target/esbuild/feedback/loading.jsx +7 -0
- package/target/esbuild/feedback/observe.jsx +1 -0
- package/target/esbuild/feedback/progress.jsx +35 -0
- package/target/esbuild/feedback/snackbar.jsx +23 -0
- package/target/esbuild/feedback/tooltip.jsx +24 -0
- package/target/esbuild/icon/icon.css +1 -0
- package/target/esbuild/icon/icon.jsx +1 -0
- package/target/esbuild/icon/index.jsx +1 -0
- package/target/esbuild/index.css +1 -0
- package/target/esbuild/index.jsx +1 -0
- package/target/esbuild/input/autocomplete.jsx +5 -0
- package/target/esbuild/input/base.jsx +4 -0
- package/target/esbuild/input/date-picker.css +1 -0
- package/target/esbuild/input/date-picker.jsx +104 -0
- package/target/esbuild/input/date-range-input.css +1 -0
- package/target/esbuild/input/date-time.jsx +21 -0
- package/target/esbuild/input/index.css +1 -0
- package/target/esbuild/input/index.jsx +1 -0
- package/target/esbuild/input/paired-input.jsx +1 -0
- package/target/esbuild/input/picker-dialog.css +1 -0
- package/target/esbuild/input/picker-dialog.jsx +14 -0
- package/target/esbuild/input/select.css +1 -0
- package/target/esbuild/input/select.jsx +63 -0
- package/target/esbuild/input/slider.css +1 -0
- package/target/esbuild/input/slider.jsx +51 -0
- package/target/esbuild/input/text-field.css +1 -0
- package/target/esbuild/input/text-field.jsx +67 -0
- package/target/esbuild/input/time-picker.css +1 -0
- package/target/esbuild/input/time-picker.jsx +29 -0
- package/target/esbuild/motion/frame.jsx +1 -0
- package/target/esbuild/motion/index.css +1 -0
- package/target/esbuild/motion/index.jsx +1 -0
- package/target/esbuild/motion/material.jsx +1 -0
- package/target/esbuild/motion/motion.jsx +1 -0
- package/target/esbuild/motion/spring.jsx +1 -0
- package/target/esbuild/motion/transition.css +1 -0
- package/target/esbuild/motion/transition.jsx +1 -0
- package/target/esbuild/motion/velocity.jsx +1 -0
- package/target/esbuild/navigation/app-bar.jsx +51 -0
- package/target/esbuild/navigation/base.jsx +1 -0
- package/target/esbuild/navigation/drawer.jsx +25 -0
- package/target/esbuild/navigation/index.jsx +1 -0
- package/target/esbuild/navigation/navigation.css +1 -0
- package/target/esbuild/navigation/navigation.jsx +29 -0
- package/target/esbuild/navigation/scroll.jsx +1 -0
- package/target/esbuild/navigation/search.jsx +29 -0
- package/target/esbuild/navigation/tabs.jsx +7 -0
- package/target/esbuild/navigation/toolbar.jsx +23 -0
- package/target/esbuild/selection/base.jsx +1 -0
- package/target/esbuild/selection/checkbox.jsx +14 -0
- package/target/esbuild/selection/chip.jsx +23 -0
- package/target/esbuild/selection/index.jsx +1 -0
- package/target/esbuild/selection/radio.jsx +9 -0
- package/target/esbuild/selection/segmented.jsx +15 -0
- package/target/esbuild/selection/selection.css +1 -0
- package/target/esbuild/selection/switch.jsx +14 -0
- package/target/esbuild/shape/corner-rounding.jsx +1 -0
- package/target/esbuild/shape/cubic.jsx +1 -0
- package/target/esbuild/shape/index.jsx +1 -0
- package/target/esbuild/shape/material-shapes.jsx +1 -0
- package/target/esbuild/shape/morph.jsx +1 -0
- package/target/esbuild/shape/path.jsx +1 -0
- package/target/esbuild/shape/point.jsx +1 -0
- package/target/esbuild/shape/rounded-polygon.jsx +1 -0
- package/target/esbuild/shape/shapes.jsx +1 -0
- package/target/esbuild/spacing/index.jsx +1 -0
- package/target/esbuild/state/component.css +1 -0
- package/target/esbuild/state/component.jsx +1 -0
- package/target/esbuild/state/controller.jsx +1 -0
- package/target/esbuild/state/index.jsx +1 -0
- package/target/esbuild/state/ripple.jsx +1 -0
- package/target/esbuild/state/state.jsx +1 -0
- package/target/esbuild/state/style.jsx +1 -0
- package/target/esbuild/surface/carousel-layout.jsx +1 -0
- package/target/esbuild/surface/carousel.css +1 -0
- package/target/esbuild/surface/carousel.jsx +10 -0
- package/target/esbuild/surface/dialog.jsx +35 -0
- package/target/esbuild/surface/divider.jsx +1 -0
- package/target/esbuild/surface/drag.jsx +1 -0
- package/target/esbuild/surface/gestures.css +1 -0
- package/target/esbuild/surface/gestures.jsx +7 -0
- package/target/esbuild/surface/index.css +1 -0
- package/target/esbuild/surface/index.jsx +1 -0
- package/target/esbuild/surface/interactive.jsx +1 -0
- package/target/esbuild/surface/list-patterns.jsx +26 -0
- package/target/esbuild/surface/list.css +1 -0
- package/target/esbuild/surface/list.jsx +9 -0
- package/target/esbuild/surface/menu.css +1 -0
- package/target/esbuild/surface/menu.jsx +12 -0
- package/target/esbuild/surface/scaffold.jsx +47 -0
- package/target/esbuild/surface/sheet.jsx +21 -0
- package/target/esbuild/surface/side-sheet.jsx +17 -0
- package/target/esbuild/surface/slots.jsx +1 -0
- package/target/esbuild/surface/surface.css +1 -0
- package/target/esbuild/surface/surface.jsx +1 -0
- package/target/esbuild/text/index.css +1 -0
- package/target/esbuild/text/index.jsx +1 -0
- package/target/esbuild/text/text.css +1 -0
- package/target/esbuild/text/text.jsx +3 -0
- package/target/esbuild/text/typography.css +1 -0
- package/target/esbuild/text/typography.jsx +1 -0
- package/target/esbuild/util/box-side.jsx +1 -0
- package/target/esbuild/util/debug.jsx +1 -0
- package/target/esbuild/util/dom.jsx +1 -0
- package/target/esbuild/util/event.jsx +1 -0
- package/target/esbuild/util/index.jsx +1 -0
- package/target/esbuild/util/preconditions.jsx +1 -0
- package/target/esbuild/util/reactive.jsx +1 -0
- package/target/tsc/action/action.css.d.ts +3 -0
- package/target/tsc/action/base.d.ts +211 -0
- package/target/tsc/action/button.d.ts +126 -0
- package/target/tsc/action/fab-menu-context.d.ts +16 -0
- package/target/tsc/action/fab-menu.d.ts +112 -0
- package/target/tsc/action/fab.d.ts +98 -0
- package/target/tsc/action/group.d.ts +166 -0
- package/target/tsc/action/icon-button.d.ts +79 -0
- package/target/tsc/action/index.d.ts +24 -0
- package/target/tsc/action/split-button.d.ts +78 -0
- package/target/tsc/color/contrast.d.ts +48 -0
- package/target/tsc/color/dynamic.d.ts +203 -0
- package/target/tsc/color/hct.d.ts +114 -0
- package/target/tsc/color/index.css.d.ts +3 -0
- package/target/tsc/color/index.d.ts +23 -0
- package/target/tsc/color/palette.d.ts +30 -0
- package/target/tsc/color/scheme.d.ts +446 -0
- package/target/tsc/color/temperature.d.ts +24 -0
- package/target/tsc/container/card.css.d.ts +3 -0
- package/target/tsc/container/card.d.ts +110 -0
- package/target/tsc/container/elevation-shadow.css.d.ts +3 -0
- package/target/tsc/container/elevation-shadow.d.ts +23 -0
- package/target/tsc/container/index.d.ts +44 -0
- package/target/tsc/dom/client.d.ts +387 -0
- package/target/tsc/dom/index.d.ts +93 -0
- package/target/tsc/dom/server.d.ts +65 -0
- package/target/tsc/dom/types.d.ts +134 -0
- package/target/tsc/feedback/badge.d.ts +116 -0
- package/target/tsc/feedback/feedback.css.d.ts +3 -0
- package/target/tsc/feedback/focus.d.ts +20 -0
- package/target/tsc/feedback/index.d.ts +17 -0
- package/target/tsc/feedback/loading.d.ts +194 -0
- package/target/tsc/feedback/observe.d.ts +75 -0
- package/target/tsc/feedback/progress.d.ts +281 -0
- package/target/tsc/feedback/snackbar.d.ts +398 -0
- package/target/tsc/feedback/tooltip.d.ts +326 -0
- package/target/tsc/icon/icon.css.d.ts +3 -0
- package/target/tsc/icon/icon.d.ts +69 -0
- package/target/tsc/icon/index.d.ts +13 -0
- package/target/tsc/index.css.d.ts +3 -0
- package/target/tsc/index.d.ts +7 -0
- package/target/tsc/input/autocomplete.d.ts +119 -0
- package/target/tsc/input/base.d.ts +282 -0
- package/target/tsc/input/date-picker.css.d.ts +3 -0
- package/target/tsc/input/date-picker.d.ts +351 -0
- package/target/tsc/input/date-range-input.css.d.ts +3 -0
- package/target/tsc/input/date-time.d.ts +171 -0
- package/target/tsc/input/index.css.d.ts +3 -0
- package/target/tsc/input/index.d.ts +27 -0
- package/target/tsc/input/paired-input.d.ts +435 -0
- package/target/tsc/input/picker-dialog.css.d.ts +3 -0
- package/target/tsc/input/picker-dialog.d.ts +84 -0
- package/target/tsc/input/select.css.d.ts +3 -0
- package/target/tsc/input/select.d.ts +267 -0
- package/target/tsc/input/slider.css.d.ts +3 -0
- package/target/tsc/input/slider.d.ts +372 -0
- package/target/tsc/input/text-field.css.d.ts +3 -0
- package/target/tsc/input/text-field.d.ts +415 -0
- package/target/tsc/input/time-picker.css.d.ts +3 -0
- package/target/tsc/input/time-picker.d.ts +212 -0
- package/target/tsc/motion/frame.d.ts +36 -0
- package/target/tsc/motion/index.css.d.ts +3 -0
- package/target/tsc/motion/index.d.ts +34 -0
- package/target/tsc/motion/material.d.ts +110 -0
- package/target/tsc/motion/motion.d.ts +235 -0
- package/target/tsc/motion/spring.d.ts +223 -0
- package/target/tsc/motion/transition.css.d.ts +3 -0
- package/target/tsc/motion/transition.d.ts +597 -0
- package/target/tsc/motion/velocity.d.ts +54 -0
- package/target/tsc/navigation/app-bar.d.ts +473 -0
- package/target/tsc/navigation/base.d.ts +331 -0
- package/target/tsc/navigation/drawer.d.ts +301 -0
- package/target/tsc/navigation/index.d.ts +25 -0
- package/target/tsc/navigation/navigation.css.d.ts +3 -0
- package/target/tsc/navigation/navigation.d.ts +537 -0
- package/target/tsc/navigation/scroll.d.ts +218 -0
- package/target/tsc/navigation/search.d.ts +332 -0
- package/target/tsc/navigation/tabs.d.ts +497 -0
- package/target/tsc/navigation/toolbar.d.ts +248 -0
- package/target/tsc/selection/base.d.ts +100 -0
- package/target/tsc/selection/checkbox.d.ts +194 -0
- package/target/tsc/selection/chip.d.ts +358 -0
- package/target/tsc/selection/index.d.ts +21 -0
- package/target/tsc/selection/radio.d.ts +198 -0
- package/target/tsc/selection/segmented.d.ts +333 -0
- package/target/tsc/selection/selection.css.d.ts +3 -0
- package/target/tsc/selection/switch.d.ts +165 -0
- package/target/tsc/shape/corner-rounding.d.ts +36 -0
- package/target/tsc/shape/cubic.d.ts +215 -0
- package/target/tsc/shape/index.d.ts +35 -0
- package/target/tsc/shape/material-shapes.d.ts +176 -0
- package/target/tsc/shape/morph.d.ts +91 -0
- package/target/tsc/shape/path.d.ts +177 -0
- package/target/tsc/shape/point.d.ts +165 -0
- package/target/tsc/shape/rounded-polygon.d.ts +289 -0
- package/target/tsc/shape/shapes.d.ts +76 -0
- package/target/tsc/spacing/index.d.ts +19 -0
- package/target/tsc/state/component.css.d.ts +3 -0
- package/target/tsc/state/component.d.ts +276 -0
- package/target/tsc/state/controller.d.ts +257 -0
- package/target/tsc/state/index.d.ts +19 -0
- package/target/tsc/state/ripple.d.ts +50 -0
- package/target/tsc/state/state.d.ts +129 -0
- package/target/tsc/state/style.d.ts +22 -0
- package/target/tsc/surface/carousel-layout.d.ts +212 -0
- package/target/tsc/surface/carousel.css.d.ts +3 -0
- package/target/tsc/surface/carousel.d.ts +231 -0
- package/target/tsc/surface/dialog.d.ts +582 -0
- package/target/tsc/surface/divider.d.ts +92 -0
- package/target/tsc/surface/drag.d.ts +92 -0
- package/target/tsc/surface/gestures.css.d.ts +3 -0
- package/target/tsc/surface/gestures.d.ts +292 -0
- package/target/tsc/surface/index.css.d.ts +3 -0
- package/target/tsc/surface/index.d.ts +29 -0
- package/target/tsc/surface/interactive.d.ts +22 -0
- package/target/tsc/surface/list-patterns.d.ts +384 -0
- package/target/tsc/surface/list.css.d.ts +3 -0
- package/target/tsc/surface/list.d.ts +340 -0
- package/target/tsc/surface/menu.css.d.ts +3 -0
- package/target/tsc/surface/menu.d.ts +590 -0
- package/target/tsc/surface/scaffold.d.ts +337 -0
- package/target/tsc/surface/sheet.d.ts +384 -0
- package/target/tsc/surface/side-sheet.d.ts +183 -0
- package/target/tsc/surface/slots.d.ts +21 -0
- package/target/tsc/surface/surface.css.d.ts +3 -0
- package/target/tsc/surface/surface.d.ts +192 -0
- package/target/tsc/text/index.css.d.ts +3 -0
- package/target/tsc/text/index.d.ts +18 -0
- package/target/tsc/text/text.css.d.ts +3 -0
- package/target/tsc/text/text.d.ts +94 -0
- package/target/tsc/text/typography.css.d.ts +3 -0
- package/target/tsc/text/typography.d.ts +82 -0
- package/target/tsc/util/box-side.d.ts +76 -0
- package/target/tsc/util/debug.d.ts +20 -0
- package/target/tsc/util/dom.d.ts +35 -0
- package/target/tsc/util/event.d.ts +93 -0
- package/target/tsc/util/index.d.ts +12 -0
- package/target/tsc/util/preconditions.d.ts +79 -0
- package/target/tsc/util/reactive.d.ts +36 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation and transition definitions.
|
|
3
|
+
*
|
|
4
|
+
* This package provides the {@link applyMotion} function and {@link Transition} component for
|
|
5
|
+
* directly applying arbitrary motions to an element and applying motions to elements upon render
|
|
6
|
+
* change. These APIs use Web Animations. {@link createMaterialTransition} supplies motion pairs
|
|
7
|
+
* for the Material transition patterns through the same transition lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* Components animate discrete state changes with CSS transitions whose easing and duration come
|
|
10
|
+
* from the `cw-Motion` spring roles, sampled from the Material springs at build time. {@link
|
|
11
|
+
* applySpringMotion} animates a numeric CSS property with a runtime spring instead, for motion a
|
|
12
|
+
* gesture drives or user input retargets mid-flight: it reads its stiffness and damping ratio from
|
|
13
|
+
* the same roles, preserves its velocity when retargeted, and accepts the release velocity
|
|
14
|
+
* estimated by a {@link VelocityTracker}. Runtime springs of a window share one animation-frame
|
|
15
|
+
* callback, available to other per-frame motion through {@link subscribeMotionFrames}.
|
|
16
|
+
*
|
|
17
|
+
* Web Animation motion completes without animating during server rendering or when the API is
|
|
18
|
+
* unavailable. Runtime springs settle immediately during server rendering, without an animation
|
|
19
|
+
* frame clock, or when reduced motion is requested. Both motion APIs honor reduced motion unless
|
|
20
|
+
* explicitly configured otherwise. {@link SUPPORTS_MOTION} describes Web Animations support only.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
export type { MotionFrameListener } from "./frame";
|
|
25
|
+
export type { MaterialTransition, MaterialTransitionOptions, MaterialTransitionPattern } from "./material";
|
|
26
|
+
export type { Motion, MotionDuration, MotionEasing, MotionKeyframe, MotionOptions } from "./motion";
|
|
27
|
+
export type { SpringMotion, SpringOptions, SpringRole, SpringScheme, SpringSpeed } from "./spring";
|
|
28
|
+
export type { TransitionElement, TransitionMotion, TransitionProps, TransitionState, TransitionTarget } from "./transition";
|
|
29
|
+
export { subscribeMotionFrames } from "./frame";
|
|
30
|
+
export { createMaterialTransition } from "./material";
|
|
31
|
+
export { SUPPORTS_MOTION, applyMotion } from "./motion";
|
|
32
|
+
export { applySpringMotion } from "./spring";
|
|
33
|
+
export { EnterSequenceBegin, EnterSequenceEnd, ExitSequenceBegin, ExitSequenceEnd, Transition, TransitionBegin, TransitionEnd } from "./transition";
|
|
34
|
+
export { VelocityTracker } from "./velocity";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { MotionDuration } from "./motion";
|
|
2
|
+
import type { TransitionMotion } from "./transition";
|
|
3
|
+
/**
|
|
4
|
+
* Material transition pattern.
|
|
5
|
+
*
|
|
6
|
+
* | Pattern | Relationship between the outgoing and incoming elements |
|
|
7
|
+
* | -------------------- | ------------------------------------------------------------------- |
|
|
8
|
+
* | `containerTransform` | Incoming element expands from, or returns to, the outgoing one. |
|
|
9
|
+
* | `fade` | Elements enter or exit within the bounds of the screen. |
|
|
10
|
+
* | `fadeThrough` | Elements have no strong relationship, such as top-level destinations. |
|
|
11
|
+
* | `sharedAxis` | Elements have a spatial or navigational relationship. |
|
|
12
|
+
*
|
|
13
|
+
* @see {@link createMaterialTransition}
|
|
14
|
+
*/
|
|
15
|
+
export type MaterialTransitionPattern = "containerTransform" | "fade" | "fadeThrough" | "sharedAxis";
|
|
16
|
+
/**
|
|
17
|
+
* Options of a {@link createMaterialTransition | Material transition}.
|
|
18
|
+
*/
|
|
19
|
+
export interface MaterialTransitionOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Axis of a shared-axis transition.
|
|
22
|
+
*
|
|
23
|
+
* | Axis | Motion |
|
|
24
|
+
* | ---- | ----------------------------------------------------------- |
|
|
25
|
+
* | `x` | Horizontal slide, mirrored for right-to-left text direction. |
|
|
26
|
+
* | `y` | Vertical slide. |
|
|
27
|
+
* | `z` | Scale. |
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `"x"`
|
|
30
|
+
*/
|
|
31
|
+
axis?: "x" | "y" | "z";
|
|
32
|
+
/**
|
|
33
|
+
* Navigation direction.
|
|
34
|
+
*
|
|
35
|
+
* Forward shared-axis transitions move towards the inline end, the bottom, or the viewer, and
|
|
36
|
+
* backward transitions in the opposite direction. A forward container transform enters the
|
|
37
|
+
* incoming element, and a backward container transform returns to it.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue `true`
|
|
40
|
+
*/
|
|
41
|
+
forward?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Slide distance of `x` and `y` shared-axis transitions, in CSS pixels.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue `30`
|
|
46
|
+
*/
|
|
47
|
+
distance?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Duration overriding the duration roles of the pattern.
|
|
50
|
+
*/
|
|
51
|
+
duration?: MotionDuration;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Inline motions which can be spread onto {@link ./transition#Transition} properties.
|
|
55
|
+
*/
|
|
56
|
+
export interface MaterialTransition {
|
|
57
|
+
/**
|
|
58
|
+
* Motion applied to the incoming transition element.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link ./transition#TransitionProps.enterMotion}
|
|
61
|
+
*/
|
|
62
|
+
readonly enterMotion: Readonly<TransitionMotion>;
|
|
63
|
+
/**
|
|
64
|
+
* Motion applied to the outgoing transition element.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link ./transition#TransitionProps.exitMotion}
|
|
67
|
+
*/
|
|
68
|
+
readonly exitMotion: Readonly<TransitionMotion>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create the motions of a Material transition pattern.
|
|
72
|
+
*
|
|
73
|
+
* The returned motions are spread onto a {@link ./transition#Transition}, which runs them in its
|
|
74
|
+
* default parallel order:
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <Transition {...createMaterialTransition("sharedAxis", { forward: forward() })}>
|
|
78
|
+
* {page}
|
|
79
|
+
* </Transition>
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* | Pattern | Motion |
|
|
83
|
+
* | -------------------- | --------------------------------------------------------------------- |
|
|
84
|
+
* | `containerTransform` | Containers morph between their bounds and shapes over a scrim. |
|
|
85
|
+
* | `fade` | Incoming element fades in by 30% progress while scaling up from 80%. |
|
|
86
|
+
* | `fadeThrough` | Outgoing element fades out by 35%, then incoming fades in from 92%. |
|
|
87
|
+
* | `sharedAxis` | Fade through while sliding 30px along `x`/`y`, or scaling along `z`. |
|
|
88
|
+
*
|
|
89
|
+
* These are web adaptations of MDC-Android's `MaterialContainerTransform`, `MaterialFade`,
|
|
90
|
+
* `MaterialFadeThrough`, and `MaterialSharedAxis`, with their default thresholds, scales, and
|
|
91
|
+
* distances, and the themed `cw-Motion` duration and easing roles they use: fade enters over
|
|
92
|
+
* `medium-4` with emphasized decelerate easing and exits over `short-3` with emphasized accelerate
|
|
93
|
+
* easing; fade through and shared axis last `long-1`, and a container transform `long-2` when
|
|
94
|
+
* entering and `medium-4` when returning, all with emphasized easing. Reduced motion is honored
|
|
95
|
+
* through {@link ./motion#applyMotion}.
|
|
96
|
+
*
|
|
97
|
+
* A container transform measures both elements when it begins, so both must be laid out at their
|
|
98
|
+
* resting bounds at the same time, typically positioned in a shared stacking context. Each element
|
|
99
|
+
* is scaled, rather than resized, into the transforming container and clipped to its shape, so its
|
|
100
|
+
* content does not reflow and its own shadow is clipped while it transforms. The containers should
|
|
101
|
+
* be opaque; the incoming one appears above the outgoing one. The scrim is an element inserted
|
|
102
|
+
* immediately before the outgoing element for the duration of the transition.
|
|
103
|
+
*
|
|
104
|
+
* @param pattern - relationship between the outgoing and incoming elements
|
|
105
|
+
* @param opts - axis, navigation direction, distance, and duration
|
|
106
|
+
* @returns motions for a {@link ./transition#Transition}
|
|
107
|
+
* @throws {@link Error} `pattern` or `opts` are invalid
|
|
108
|
+
* @see MDC-Android `lib/java/com/google/android/material/transition/`
|
|
109
|
+
*/
|
|
110
|
+
export declare function createMaterialTransition(pattern: MaterialTransitionPattern, opts?: Readonly<MaterialTransitionOptions>): MaterialTransition;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {@link Motion} easing function.
|
|
3
|
+
*
|
|
4
|
+
* Easing functions can be either literal easing functions, CSS variable name, or, the
|
|
5
|
+
* `animation-timing-function` or `transition-timing-function` CSS properties. Non-literal values
|
|
6
|
+
* are resolved from the style of the target element the motion is applied to. When resolving from
|
|
7
|
+
* CSS property values, if the CSS property is assigned to multiple easing functions, the last
|
|
8
|
+
* easing function is used.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link MotionOptions.easing}
|
|
11
|
+
*/
|
|
12
|
+
export type MotionEasing = string | `--${string}` | `${"animation" | "transition"}-timing-function`;
|
|
13
|
+
/**
|
|
14
|
+
* {@link Motion} duration.
|
|
15
|
+
*
|
|
16
|
+
* Durations can be either a `number` of milliseconds, CSS variable name, or, the
|
|
17
|
+
* `animation-duration` or `transition-duration` CSS properties. Like {@link MotionEasing},
|
|
18
|
+
* non-literal values are resolved from the style of the target element the motion is applied to.
|
|
19
|
+
* See {@link MotionEasing} for more information.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link MotionOptions.duration}
|
|
22
|
+
* @see {@link MotionOptions.endDelay}
|
|
23
|
+
* @see {@link MotionOptions.startDelay}
|
|
24
|
+
*/
|
|
25
|
+
export type MotionDuration = number | `--${string}` | `${"animation" | "transition"}-duration`;
|
|
26
|
+
/**
|
|
27
|
+
* {@link Motion} keyframe.
|
|
28
|
+
*
|
|
29
|
+
* A keyframe may be a literal string constant or an object. Literal string constants evaluate to
|
|
30
|
+
* one or more keyframes representing the specific predefined motion type. Object values are
|
|
31
|
+
* expected to be `Keyframe` objects, whose `easing` key may be mapped to an {@link MotionEasing}
|
|
32
|
+
* value.
|
|
33
|
+
*
|
|
34
|
+
* | Predefined Motion | Description |
|
|
35
|
+
* | ------------------- | ---------------------------------------------------------------------- |
|
|
36
|
+
* | `clip-in-block` | Clip element in, along block axis, using `clip-path`. |
|
|
37
|
+
* | `clip-in-inline` | Clip element in, along inline axis, using `clip-path`. |
|
|
38
|
+
* | `clip-out-block` | Clip element out, along block axis, using `clip-path`. |
|
|
39
|
+
* | `clip-out-inline` | Clip element out, along inline axis, using `clip-path`. |
|
|
40
|
+
* | `expand-in-block` | Expand element, along block axis, from `0` to resting size. |
|
|
41
|
+
* | `expand-in-inline` | Expand element, along inline axis from `0` to resting size. |
|
|
42
|
+
* | `expand-out-block` | Shrink element, along block axis, from current size to `0`. |
|
|
43
|
+
* | `expand-out-inline` | Shrink element, along inline axis, from current size to `0`. |
|
|
44
|
+
* | `fade-in` | Transition `opacity` from `0` to resting value. |
|
|
45
|
+
* | `fade-out` | Transition `opacity` from current value to `0`. |
|
|
46
|
+
* | `slide-in-block` | Slide element in, along block axis, using `translate` and `clip-path`. |
|
|
47
|
+
* | `slide-in-inline` | Slide element in, along inline axis, using `translate` and `clip-path`. |
|
|
48
|
+
* | `slide-out-block` | Slide element out, along block axis, using `translate` and `clip-path`. |
|
|
49
|
+
* | `slide-out-inline` | Slide element out, along inline axis, using `translate` and `clip-path`. |
|
|
50
|
+
* | `zoom-in` | Transition `scale` from `0` to resting value. |
|
|
51
|
+
* | `zoom-out` | Transition `scale` from current value to `0`. |
|
|
52
|
+
*
|
|
53
|
+
* Predefined motions which rely on current or resting style property values, the property values
|
|
54
|
+
* are resolved from the *current* value of the property, when motion is first constructed, to the
|
|
55
|
+
* value of the property *after* motion playback begins.
|
|
56
|
+
*/
|
|
57
|
+
export type MotionKeyframe = (Omit<Keyframe, "easing"> & {
|
|
58
|
+
easing?: MotionEasing | undefined;
|
|
59
|
+
}) | `clip-${"in" | "out"}-${"block" | "inline"}` | `expand-${"in" | "out"}-${"block" | "inline"}` | `fade-${"in" | "out"}` | `slide-${"in" | "out"}-${"block" | "inline"}` | `zoom-${"in" | "out"}`;
|
|
60
|
+
/**
|
|
61
|
+
* Options controlling how a motion is {@link applyMotion | applied} to a target element.
|
|
62
|
+
*/
|
|
63
|
+
export interface MotionOptions {
|
|
64
|
+
/**
|
|
65
|
+
* Honor the target document's reduced-motion preference.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `true`
|
|
68
|
+
*/
|
|
69
|
+
respectReducedMotion?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Cache to use for persisting CSS styles.
|
|
72
|
+
*
|
|
73
|
+
* This cache, when specified, is populated with CSS properties and variables which are
|
|
74
|
+
* accessed when resolving easing functions, durations, etc. If CSS properties and
|
|
75
|
+
* variables may change between subsequent invocations of {@link applyMotion}, for the
|
|
76
|
+
* same target element and keyframes, then this should *not* be specified.
|
|
77
|
+
*/
|
|
78
|
+
cache?: Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* CSS selector of pseudo-element to apply motion to.
|
|
81
|
+
*
|
|
82
|
+
* When omitted or `undefined`, the motion is applied to the target element; otherwise,
|
|
83
|
+
* the motion is applied to the specified pseudo-element of the target element.
|
|
84
|
+
* Additionally, any option assigned to a CSS property name or variable name will be
|
|
85
|
+
* resolved from the styling of the pseudo element.
|
|
86
|
+
*/
|
|
87
|
+
pseudoElement?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Direction in which the motion is applied.
|
|
90
|
+
*
|
|
91
|
+
* | Direction | Description |
|
|
92
|
+
* | ------------------- | ----------------------------------------------------------- |
|
|
93
|
+
* | `alternate` | Alternate between `normal` and `reverse` at each iteration. |
|
|
94
|
+
* | `alternate-reverse` | Alternate between `reverse` and `normal` at each iteration. |
|
|
95
|
+
* | `normal` | Interpolate from start values to end values. |
|
|
96
|
+
* | `reverse` | Interpolate from end values to start values. |
|
|
97
|
+
*
|
|
98
|
+
* @defaultValue `"normal"`
|
|
99
|
+
*/
|
|
100
|
+
direction?: "alternate" | "alternate-reverse" | "normal" | "reverse";
|
|
101
|
+
/**
|
|
102
|
+
* Persist motion effects to element.
|
|
103
|
+
*
|
|
104
|
+
* | Fill | Description |
|
|
105
|
+
* | ----------- | ---------------------------------------- |
|
|
106
|
+
* | `backwards` | Persist prior to starting motion. |
|
|
107
|
+
* | `both` | Implies both `backwards` and `forwards`. |
|
|
108
|
+
* | `forwards` | Persist after motion end. |
|
|
109
|
+
* | `none` | Do not persist. |
|
|
110
|
+
*
|
|
111
|
+
* @defaultValue `"none"`
|
|
112
|
+
*/
|
|
113
|
+
fill?: "backwards" | "both" | "forwards" | "none";
|
|
114
|
+
/**
|
|
115
|
+
* Value composition between motion and other motions applied in parallel.
|
|
116
|
+
*
|
|
117
|
+
* | Composite | Description |
|
|
118
|
+
* | ------------ | --------------------------------------------------------------------- |
|
|
119
|
+
* | `accumulate` | Effective value is sum of value defined by this motion and other motions. |
|
|
120
|
+
* | `add` | Effective value is additive. |
|
|
121
|
+
* | `replace` | Value of other motion is replaced with value defined by this motion. |
|
|
122
|
+
*
|
|
123
|
+
* @defaultValue `"replace"`
|
|
124
|
+
*/
|
|
125
|
+
composite?: "accumulate" | "add" | "replace";
|
|
126
|
+
/**
|
|
127
|
+
* Number of iterations.
|
|
128
|
+
*
|
|
129
|
+
* @defaultValue `1`
|
|
130
|
+
*/
|
|
131
|
+
iterations?: number;
|
|
132
|
+
/**
|
|
133
|
+
* Easing function.
|
|
134
|
+
*
|
|
135
|
+
* @defaultValue `"linear"`
|
|
136
|
+
*/
|
|
137
|
+
easing?: MotionEasing;
|
|
138
|
+
/**
|
|
139
|
+
* Duration of motion.
|
|
140
|
+
*/
|
|
141
|
+
duration?: MotionDuration;
|
|
142
|
+
/**
|
|
143
|
+
* Start delay of motion.
|
|
144
|
+
*/
|
|
145
|
+
startDelay?: MotionDuration;
|
|
146
|
+
/**
|
|
147
|
+
* End delay of motion.
|
|
148
|
+
*/
|
|
149
|
+
endDelay?: MotionDuration;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Controller of an {@link applyMotion | applied} motion.
|
|
153
|
+
*/
|
|
154
|
+
export interface Motion {
|
|
155
|
+
/**
|
|
156
|
+
* Promise which resolves once motion has finished playing.
|
|
157
|
+
*
|
|
158
|
+
* This property is updated with a new promise each time a motion exits the `finished`
|
|
159
|
+
* play {@link Motion.playState | state}.
|
|
160
|
+
*/
|
|
161
|
+
readonly finished: Promise<Motion>;
|
|
162
|
+
/**
|
|
163
|
+
* Promise which resolves once motion can begin playback.
|
|
164
|
+
*
|
|
165
|
+
* This property is updated with a new promise each time a motion enters into the `pending`
|
|
166
|
+
* play {@link Motion.playState | state}.
|
|
167
|
+
*/
|
|
168
|
+
readonly ready: Promise<Motion>;
|
|
169
|
+
/**
|
|
170
|
+
* Motion is pending an asynchronous operation.
|
|
171
|
+
*/
|
|
172
|
+
readonly pending: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Playback state of motion.
|
|
175
|
+
*
|
|
176
|
+
* This is set to `"idle"`, `"running"`, `"paused"`, or `"finished"` based on whether
|
|
177
|
+
* motion timeline has not yet been resolved, motion is running, motion was suspended, or
|
|
178
|
+
* motion has reached end of its timeline, respectively.
|
|
179
|
+
*/
|
|
180
|
+
readonly playState: "finished" | "idle" | "paused" | "running";
|
|
181
|
+
/**
|
|
182
|
+
* Update motion playback rate after synchronizing playback position.
|
|
183
|
+
*
|
|
184
|
+
* @param rate - value greater than, less than, or equal to zero to speed up or reverse,
|
|
185
|
+
* play backwards, or pause motion
|
|
186
|
+
*/
|
|
187
|
+
updatePlaybackRate(rate: number): void;
|
|
188
|
+
/**
|
|
189
|
+
* Clear all pending keyframes and abort playback.
|
|
190
|
+
*
|
|
191
|
+
* Upon return, if play {@link Motion.playState | state} was not `"idle"`, then the {@link
|
|
192
|
+
* Motion.finished | finished} promise, prior to when this method was invoked, is rejected
|
|
193
|
+
* with a `DOMException`.
|
|
194
|
+
*/
|
|
195
|
+
cancel(): void;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Motion is supported by user-agent.
|
|
199
|
+
*
|
|
200
|
+
* This is `true` if, and only if:
|
|
201
|
+
*
|
|
202
|
+
* 1. Executing environment is not {@link solid-js/web#isServer | server}.
|
|
203
|
+
*
|
|
204
|
+
* 2. User-agent supports Web Animations API required by motion functions and components.
|
|
205
|
+
*/
|
|
206
|
+
export declare const SUPPORTS_MOTION: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Apply motion to an element or pseudo-element.
|
|
209
|
+
*
|
|
210
|
+
* If {@link MotionOptions.pseudoElement | `opts.pseudoElement`} is specified, then the motion is
|
|
211
|
+
* applied to the specified pseudo-element of `elem`; otherwise, the motion is applied to `elem`.
|
|
212
|
+
* The motion applied is composed of keyframes defined in `frames`. The `frames` array may contain
|
|
213
|
+
* explicit keyframe objects or predefined motion name strings.
|
|
214
|
+
*
|
|
215
|
+
* Predefined motion strings evaluate to keyframe objects, computed for the target element,
|
|
216
|
+
* usually with a start and end keyframe. Predefined motions whose computed frames contain an end
|
|
217
|
+
* frame, the end frame will applied at an offset of `1`. Computed start frames, however, are
|
|
218
|
+
* applied in the order the predefined motion name appears within `frames`.
|
|
219
|
+
*
|
|
220
|
+
* If the user-agent does not {@link SUPPORTS_MOTION | support} motion, this returns a motion in
|
|
221
|
+
* a finished play {@link Motion.playState | state}.
|
|
222
|
+
*
|
|
223
|
+
* @param elem - target element
|
|
224
|
+
* @param frames - frames of motion to apply
|
|
225
|
+
* @param opts - options to apply motion with
|
|
226
|
+
* @returns resulting motion
|
|
227
|
+
* @throws {@link Error} `opts` are malformed
|
|
228
|
+
*
|
|
229
|
+
* @remarks
|
|
230
|
+
* A motion which honors reduced motion listens for preference changes until it finishes or is
|
|
231
|
+
* {@link Motion.cancel | cancelled}. Cancel a motion which never finishes, such as one with
|
|
232
|
+
* infinite {@link MotionOptions.iterations | iterations} or a zero playback rate, once it is no
|
|
233
|
+
* longer needed; otherwise, the listener retains the motion and its target.
|
|
234
|
+
*/
|
|
235
|
+
export declare function applyMotion(elem: Element, frames: readonly MotionKeyframe[], opts: Readonly<MotionOptions>): Motion;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { StyleElement } from "../dom";
|
|
2
|
+
/**
|
|
3
|
+
* Material spring scheme.
|
|
4
|
+
*
|
|
5
|
+
* | Scheme | Spatial springs | Effect springs |
|
|
6
|
+
* | ------------ | -------------------------------------------------- | ----------------- |
|
|
7
|
+
* | `expressive` | Bounce; for prominent and hero interactions. | Critically damped |
|
|
8
|
+
* | `standard` | Barely overshoot; for utilitarian interactions. | Critically damped |
|
|
9
|
+
*
|
|
10
|
+
* @see {@link SpringOptions.scheme}
|
|
11
|
+
*/
|
|
12
|
+
export type SpringScheme = "expressive" | "standard";
|
|
13
|
+
/**
|
|
14
|
+
* Category of the property a spring animates.
|
|
15
|
+
*
|
|
16
|
+
* Use `"spatial"` for position, size and shape, which may overshoot, and `"effect"` for color,
|
|
17
|
+
* opacity, and other values which must not overshoot.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link SpringOptions.role}
|
|
20
|
+
*/
|
|
21
|
+
export type SpringRole = "effect" | "spatial";
|
|
22
|
+
/**
|
|
23
|
+
* Relative speed of a spring within its scheme and role.
|
|
24
|
+
*
|
|
25
|
+
* Use `"fast"` for small component feedback, `"default"` for motion covering part of the screen,
|
|
26
|
+
* and `"slow"` for full-screen motion.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link SpringOptions.speed}
|
|
29
|
+
*/
|
|
30
|
+
export type SpringSpeed = "default" | "fast" | "slow";
|
|
31
|
+
/**
|
|
32
|
+
* Options of a {@link applySpringMotion | spring motion}.
|
|
33
|
+
*
|
|
34
|
+
* Springs have unit mass. Unless given, the stiffness and damping ratio are those of the Material
|
|
35
|
+
* spring selected by {@link SpringOptions.role | `role`} and {@link SpringOptions.speed | `speed`}.
|
|
36
|
+
*/
|
|
37
|
+
export interface SpringOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Spring scheme whose presets supply an omitted stiffness or damping ratio.
|
|
40
|
+
*
|
|
41
|
+
* When omitted, the stiffness and damping ratio are read from the
|
|
42
|
+
* `--cw-Motion-spring-<role>-<speed>-stiffness` and `--cw-Motion-spring-<role>-<speed>-damping`
|
|
43
|
+
* roles of the element, which follow the nearest `cw-theme-standard` or `cw-theme-expressive`
|
|
44
|
+
* scope like every other motion role. The standard presets apply when these roles are
|
|
45
|
+
* unavailable, such as during server rendering, for an element outside its document, or
|
|
46
|
+
* without the motion stylesheet.
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue scheme of the motion roles applied to the element
|
|
49
|
+
*/
|
|
50
|
+
scheme?: SpringScheme;
|
|
51
|
+
/**
|
|
52
|
+
* Category of the animated property.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue `"spatial"`
|
|
55
|
+
*/
|
|
56
|
+
role?: SpringRole;
|
|
57
|
+
/**
|
|
58
|
+
* Relative speed of the spring.
|
|
59
|
+
*
|
|
60
|
+
* @defaultValue `"default"`
|
|
61
|
+
*/
|
|
62
|
+
speed?: SpringSpeed;
|
|
63
|
+
/**
|
|
64
|
+
* Positive, finite stiffness.
|
|
65
|
+
*
|
|
66
|
+
* Overrides the stiffness selected by {@link SpringOptions.scheme | `scheme`}, {@link
|
|
67
|
+
* SpringOptions.role | `role`}, and {@link SpringOptions.speed | `speed`}.
|
|
68
|
+
*/
|
|
69
|
+
stiffness?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Positive, finite damping ratio.
|
|
72
|
+
*
|
|
73
|
+
* Ratios below `1` overshoot, `1` is critically damped, and ratios above `1` are over-damped.
|
|
74
|
+
* Overrides the ratio selected by {@link SpringOptions.scheme | `scheme`}, {@link
|
|
75
|
+
* SpringOptions.role | `role`}, and {@link SpringOptions.speed | `speed`}.
|
|
76
|
+
*/
|
|
77
|
+
damping?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Finite initial velocity, in property units per second.
|
|
80
|
+
*
|
|
81
|
+
* Pass the release velocity of a gesture, for example from a {@link ./velocity#VelocityTracker
|
|
82
|
+
* | velocity tracker}, so the spring continues the gesture's momentum.
|
|
83
|
+
*
|
|
84
|
+
* @defaultValue `0`
|
|
85
|
+
*/
|
|
86
|
+
velocity?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Positive, finite settle threshold, in property units.
|
|
89
|
+
*
|
|
90
|
+
* The spring settles at its destination once its displacement is below this threshold *and*
|
|
91
|
+
* its speed is below {@link VELOCITY_THRESHOLD_MULTIPLIER | 62.5} thresholds per second, that
|
|
92
|
+
* is, once it would move less than the threshold within a 16ms frame. The default depends on
|
|
93
|
+
* {@link SpringOptions.unit | `unit`}:
|
|
94
|
+
*
|
|
95
|
+
* | Unit | Threshold | Source |
|
|
96
|
+
* | ----------- | --------- | --------------------------------------------------------- |
|
|
97
|
+
* | `px` | `0.4` | Compose `Dp.VisibilityThreshold` |
|
|
98
|
+
* | `deg` | `0.1` | Android `MIN_VISIBLE_CHANGE_ROTATION_DEGREES` |
|
|
99
|
+
* | `%` | `0.1` | `0.4px` of a `400px` reference box |
|
|
100
|
+
* | none, other | `0.002` | Android `MIN_VISIBLE_CHANGE_SCALE` |
|
|
101
|
+
*
|
|
102
|
+
* The Android values are constants of `androidx.dynamicanimation.animation.DynamicAnimation`.
|
|
103
|
+
*
|
|
104
|
+
* @defaultValue threshold of {@link SpringOptions.unit | `unit`}, see above
|
|
105
|
+
*/
|
|
106
|
+
threshold?: number;
|
|
107
|
+
/**
|
|
108
|
+
* CSS unit appended to the numeric value, such as `"px"`.
|
|
109
|
+
*
|
|
110
|
+
* Use an empty string for unitless properties, and for custom properties whose consumers
|
|
111
|
+
* supply the unit.
|
|
112
|
+
*
|
|
113
|
+
* @defaultValue `""`
|
|
114
|
+
*/
|
|
115
|
+
unit?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Settle immediately while the element's document prefers reduced motion.
|
|
118
|
+
*
|
|
119
|
+
* A change of preference to reduced motion also settles a running spring at its destination.
|
|
120
|
+
*
|
|
121
|
+
* @defaultValue `true`
|
|
122
|
+
*/
|
|
123
|
+
respectReducedMotion?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Controller of a {@link applySpringMotion | spring motion}.
|
|
127
|
+
*
|
|
128
|
+
* A spring changes its destination without discarding its velocity. Its sampled value remains
|
|
129
|
+
* applied as an inline style after it settles or is cancelled, so a caller can retarget it from its
|
|
130
|
+
* current position. Retargeting a settled or cancelled spring starts a new run, with a new {@link
|
|
131
|
+
* SpringMotion.finished | completion promise}.
|
|
132
|
+
*/
|
|
133
|
+
export interface SpringMotion {
|
|
134
|
+
/**
|
|
135
|
+
* Most recently sampled value, in property units.
|
|
136
|
+
*
|
|
137
|
+
* Reading this does not advance the spring, and does not establish a Solid dependency.
|
|
138
|
+
*/
|
|
139
|
+
readonly value: number;
|
|
140
|
+
/**
|
|
141
|
+
* Most recently sampled velocity, in property units per second.
|
|
142
|
+
*
|
|
143
|
+
* Settling sets this to `0`; cancellation retains the sampled velocity.
|
|
144
|
+
*/
|
|
145
|
+
readonly velocity: number;
|
|
146
|
+
/**
|
|
147
|
+
* Lifecycle state.
|
|
148
|
+
*
|
|
149
|
+
* | State | Description |
|
|
150
|
+
* | ---------- | --------------------------------------------- |
|
|
151
|
+
* | `finished` | Spring settled at its destination. |
|
|
152
|
+
* | `idle` | Spring was cancelled before it settled. |
|
|
153
|
+
* | `running` | Spring is moving towards its destination. |
|
|
154
|
+
*
|
|
155
|
+
* This is not a Solid signal.
|
|
156
|
+
*/
|
|
157
|
+
readonly playState: "finished" | "idle" | "running";
|
|
158
|
+
/**
|
|
159
|
+
* Completion promise of the current run.
|
|
160
|
+
*
|
|
161
|
+
* Resolves with this controller once the spring settles, and rejects with an `AbortError`
|
|
162
|
+
* `DOMException` once it is cancelled. Retargeting a running spring retains the promise;
|
|
163
|
+
* retargeting a settled or cancelled spring replaces it, so read this again after restarting.
|
|
164
|
+
*/
|
|
165
|
+
readonly finished: Promise<SpringMotion>;
|
|
166
|
+
/**
|
|
167
|
+
* Change the destination, preserving the current value and velocity.
|
|
168
|
+
*
|
|
169
|
+
* A running spring is first sampled at the current time of its document. A settled or
|
|
170
|
+
* cancelled spring starts a new run from its retained value and velocity.
|
|
171
|
+
*
|
|
172
|
+
* @param value - finite destination, in property units
|
|
173
|
+
* @throws {@link Error} `value` is not finite
|
|
174
|
+
*/
|
|
175
|
+
retarget(value: number): void;
|
|
176
|
+
/**
|
|
177
|
+
* Stop the current run, retaining its sampled value and velocity.
|
|
178
|
+
*
|
|
179
|
+
* Rejects {@link SpringMotion.finished | `finished`} with an `AbortError` `DOMException`. This
|
|
180
|
+
* has no effect on a settled or cancelled spring.
|
|
181
|
+
*/
|
|
182
|
+
cancel(): void;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Animate a numeric CSS property with a Material spring.
|
|
186
|
+
*
|
|
187
|
+
* The spring moves the property of `elem` from `from` towards `to`, writing the sampled value,
|
|
188
|
+
* followed by {@link SpringOptions.unit | `opts.unit`}, as an inline style on every animation
|
|
189
|
+
* frame. Its stiffness and damping ratio come from the `cw-Motion` spring roles of `elem`, so the
|
|
190
|
+
* nearest `cw-theme-standard` or `cw-theme-expressive` scope selects its scheme (see {@link
|
|
191
|
+
* SpringOptions.scheme}). Use effect springs for opacity and other bounded values, and spatial
|
|
192
|
+
* springs for position, size or shape.
|
|
193
|
+
*
|
|
194
|
+
* Unlike CSS transitions, a spring is interruptible without a velocity discontinuity: {@link
|
|
195
|
+
* SpringMotion.retarget | retargeting} it continues from its current value and velocity, and
|
|
196
|
+
* {@link SpringOptions.velocity | `opts.velocity`} hands it the release velocity of a gesture.
|
|
197
|
+
* All springs of a window share one animation-frame callback and frame clock. A spring settles
|
|
198
|
+
* immediately during server rendering, without an animation-frame clock, or while reduced motion
|
|
199
|
+
* is preferred (unless {@link SpringOptions.respectReducedMotion | `respectReducedMotion`} is
|
|
200
|
+
* `false`). Its value remains applied after it settles.
|
|
201
|
+
*
|
|
202
|
+
* ```ts
|
|
203
|
+
* const spring = applySpringMotion(thumb, "translate", 0, 20, { speed: "fast", unit: "px" });
|
|
204
|
+
*
|
|
205
|
+
* // a later toggle reverses the motion without a velocity jump:
|
|
206
|
+
* spring.retarget(0);
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @param elem - element receiving the property
|
|
210
|
+
* @param property - CSS property name, including custom properties
|
|
211
|
+
* @param from - finite initial value
|
|
212
|
+
* @param to - finite destination
|
|
213
|
+
* @param opts - spring characteristics and CSS unit
|
|
214
|
+
* @returns interruptible spring controller
|
|
215
|
+
* @throws {@link Error} `from`, `to`, or `opts` are invalid
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* The stiffness, damping ratio, and window are resolved when the spring is created; reading the
|
|
219
|
+
* motion roles costs one `getComputedStyle()` call. Moving the element to another scope or
|
|
220
|
+
* document does not reconfigure the spring. Within a Solid owner the spring is cancelled when the
|
|
221
|
+
* owner is disposed; otherwise, the caller must cancel a spring it no longer needs.
|
|
222
|
+
*/
|
|
223
|
+
export declare function applySpringMotion(elem: StyleElement, property: string, from: number, to: number, opts?: Readonly<SpringOptions>): SpringMotion;
|