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) // `@wardic/dom`'s: a spring
defaults.transitionFor("opacity", 1) // `@wardic/dom`'s: a 0.3 s tween

Classes

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

Transition

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

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.