BaseValue

Where a key starts, and where it returns: an element's Base value for a key is the first of its base target (its animate, else an inherited variant, else its initial), its initial, its own style, the values it started at, and its Own value, which its Environment reads off it. of finds it, and start finds where a key with no value yet starts. Pure, and shared by every binding and Environment.

import * as BaseValue from "@wardic/core/BaseValue"

BaseValue.of("opacity", { base: {}, initial: { opacity: 0 }, style: () => Option.none(), own: readOwn })
// Option.some({ value: 0, source: "initial" }): where opacity returns once nothing sets it

Interfaces

BaseSources

The links of a key's chain, in order.

  • base: the base of the element's Override stack: its own animate, else an inherited variant, else its initial.
  • initial: the element's initial values, an inherited initial among them.
  • style: the element's user style for the key, coerced to the key's shape; a surface with no style link passes () => Option.none().
  • started: the values an element with initial={false} started at, its animate at mount, as Motion's baseTarget; such an element passes an empty initial. Optional: left out, no value.
  • own: the element's Own value, read by its Environment; asked only when every earlier link misses.

Properties

base
readonly base: Values;
initial
readonly initial: Values;
own
readonly own: ValueLookup;
started?
readonly started?: Values;
style
readonly style: ValueLookup;

BaseValue

A Base value and the link it came from.

Properties

source
readonly source: BaseSource;
value
readonly value: string | number;

Type Aliases

BaseSource

type BaseSource = "base" | "initial" | "style" | "started" | "own";

Which link of the chain a Base value came from.


ValueLookup

type ValueLookup = (key) => Option.Option<number | string>;

A per-key lookup: a value, or None for none.

Parameters

key

string

Returns

Option.Option<number | string>

Variables

TRANSFORM_IDENTITY

const TRANSFORM_IDENTITY: Readonly<Record<string, number>>;

Each transform key's identity: the value that leaves an element untransformed, 1 for a scale and 0 for a translation, rotation or skew. A transform key's Own value is its identity, as Motion's is. These are the keys an Environment builds one transform from.

Functions

of()

function of(key, sources): Option<BaseValue>;

A key's Base value: where it returns once no layer sets it. The first link that has the key wins: base, then initial, then style, then started, then own. A later link is never asked once one hits. None means no link has it, so the key doesn't return (it stays where it is).

Parameters

key

string

sources

BaseSources

Returns

Option<BaseValue>


start()

function start(key, sources): Option<BaseValue>;

Where a key with no value yet starts: its style value, else its Own value. None when neither has one: start the key at its target, with no motion, as Motion does.

Parameters

key

string

sources

Pick<BaseSources, "style" | "own">

Returns

Option<BaseValue>


transformIdentity()

function transformIdentity(key): Option<number>;

A transform key's identity (see TRANSFORM_IDENTITY), or None for any other key, prototype names included.

Parameters

key

string

Returns

Option<number>