DefaultTransition
What a key runs on when its own transition isn't defined. Which keys get what is an Environment's to
say, as Motion picks by value: @wardic/dom's gives the transforms springs and the rest a short tween. A
binding asks it for each key that has no transition, and for keyframes through more than two stops.
import * as DefaultTransition from "@wardic/core/DefaultTransition"
const defaults = yield* DefaultTransition.DefaultTransition
defaults.transitionFor("x", 100) // `byKey`'s, `@wardic/dom`'s: a spring
defaults.transitionFor("opacity", 1) // `byKey`'s: a 0.3 s tweenClasses
DefaultTransition
An Environment's Default transition: the transition a key runs on when its own isn't defined.
Extends
Context.Service
Properties
keyframes
readonly keyframes: KeyframesTransition;The transition a key runs on through more than two stops, one for every key, as Motion's
keyframesTransition is. A key with two stops runs on transitionFor's, toward its last.
transitionFor
readonly transitionFor: (key, target) => Transition;The transition key runs on toward target. The same object for the same answer, so a binding can
run the keys that share one together.
Parameters
key
string
target
string | number
Returns
Type Aliases
KeyframesTransition
type KeyframesTransition = object & KeyframesOptions;A transition a key runs on through its stops: a tween, as Motion's keyframes are, with an ease per stretch if it likes.
Type Declaration
type
readonly type: "tween";Transition
type Transition =
| object & SpringOptions
| object & AnimateOptions;A transition a key runs on: a spring, or a tween.
Variables
KEYFRAMES_TWEEN
const KEYFRAMES_TWEEN: KeyframesTransition;The transition through more than two stops by key, as Motion's keyframesTransition: a 0.8 s tween, eased out.
layerByKey
const layerByKey: Layer.Layer<DefaultTransition>;The Default transition by key: byKey for each key, and KEYFRAMES_TWEEN through more
than two stops. An Environment's whose transform keys are core's; one with keys of its own gives them
a transition too, as @wardic/dom and @wardic/object do.
Example
program.pipe(Effect.provide(DefaultTransition.layerByKey))layerOneSpring
const layerOneSpring: Layer.Layer<DefaultTransition>;A Default transition with no opinion: every key on ONE_SPRING, and more than two stops on
ONE_TWEEN. The Test Environment's.
Example
program.pipe(Effect.provide(DefaultTransition.layerOneSpring))ONE_SPRING
const ONE_SPRING: Transition;One spring with core's defaults: stiffness 170, damping 26, mass 1.
ONE_TWEEN
const ONE_TWEEN: KeyframesTransition;One tween with core's defaults, 0.3 s and linear: oneSpring's for more than two stops.
Functions
byKey()
function byKey(key, target): Transition;The transition key runs on toward target by its name, as Motion picks it: a transform but a scale
(x, rotateY, rotateZ…) on a spring of 500 / 25, at rest under 10 a second; a scale on a spring of
550, critically damped toward 0, else damped 30; any other key on a 0.3 s tween, eased by the cubic
Bézier (0.25, 0.1, 0.35, 1). The same object for the same answer.
Parameters
key
string
target
string | number
Returns
Example
DefaultTransition.byKey("x", 100) // { type: "spring", stiffness: 500, damping: 25, restSpeed: 10 }
DefaultTransition.byKey("uProgress", 1) // a 0.3 s tween