Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pose-core

Popmotion172.1kMIT2.1.1TypeScript support: included

Factory for Pose animation state machines

animation, dom, declarative, popmotion

readme

Pose Core

Factory for Pose animation state machines

npm version npm downloads Twitter Follow Join the community on Spectrum

Install

npm install pose-core --save

Create a poser factory

JavaScript

import poseFactory from 'pose-core';

const pose = poseFactory(config);

TypeScript

const pose = poseFactory<Value, Action, Poser>(config);

Config options

All config options are mandatory.

getDefaultProps

Returns default properties to be injected into every poser's config.props property.

(config: PoserConfig) => { [key: string]: any }

readValue

Read and return from Value.

(value: Value) => any;

createValue

Create a new Value. Each Value is responsible for tracking a single value defined in the poser's poses.

type CreateValueProps = {
  passiveParent?: Value,
  passiveProps?: any // Passed as the second value in the `passive` tuple
}

(init: any, props?: CreateValueProps) => Value

resolveTarget

Accepts the target as defined in the pose, and returns an animatable version of it. For instance React Animated only animates raw numbers, so it runs every target through parseFloat.

(value: Value, target: any) => any

getTransitionProps

Takes the target as returned from resolveTarget and returns default props to be passed to the entered pose's transition function.

(value: Value, target: any) => { [key: string]: any }

bindOnChange

Bind the onChange callbacks to their respective Values.

type OnChangeMap = { [key: string]: (v: any) => void };
type ValuesMap = Map<string, Value>;

(values: Map<string, Value>, onChange: OnChangeMap) => (key: string) => void;

startAction

Takes an action (ie animation or interaction) and returns the subscription returned from its start (or equivalent) method. This subscription might be the same as the action (in the case of Animated) or different (in the case of Popmotion)

(action: Action, onComplete: Function) => ActionSubscription

stopAction

Takes an action subscription and stops it.

(actionSubscription: ActionSubscription) => void

getInstantTransition

Returns an Action that represents an instant transition. We do this rather than simply set on the corresponding Value because both Animated and Popmotion allow these "instant" actions to be composed with things like a delay action.

(value: Value, to: number) => Action

addActionDelay

Returns an action that delays the execution of the initially provided action.

(delay: number, action: Action) => Action

defaultTransitions

A Map that contains Action factory functions that match the signature of the pose's transition property.

The Map must contain at least a 'default' action factory.

Map<string, (props: Props) => Action>

selectValueToRead

Accepts Value and returns the value returned by poser.get(key: string)

(value: Value) => any

extendAPI

A chance to add methods to the output Poser. For instance the Popmotion Pose factory uses this to append DOM-specific FLIP methods. Simply return api for no change.

(api: Poser) => Poser

changelog

Changelog

Pose Core adheres to Semantic Versioning.

[2.1.1] 2019-11-14

Upgrade

  • Upgraded to Typescript 3.7.

Removed

  • Patreon notice.

[2.1.0] 2019-02-04

Added

  • forceRender option #703

[2.0.3] 2019-01-28

Updated

  • Tightened type definitions for TransitionMapFactory #714

[2.0.2] 2018-12-03

Fixed

  • Don't override child props with parent props. #594

[2.0.1] 2018-09-06

Fixed

  • Ensuring any values set in apply props are set upon mount.

[2.0.0] 2018-09-06

Added

  • Support for applyAtStart and applyAtEnd properties.

[1.0.4] 2018-09-06

Fixed

  • Exposing more types.

[1.0.3] 2018-08-26

Fixed

  • Fixing bug with init pose when initialPose was set.

[1.0.2] 2018-08-20

Fixed

  • Fixing bug in pose unsetting priority.

[1.0.1] 2018-08-19

Fixed

  • Updating unset logic.

[1.0.0] 2018-08-19

Added

  • New pose resolution logic.

[0.8.1] 2018-08-18

Added

  • Exporting TransitionMap type.

[0.8.0] 2018-06-14

Added

  • Passing passiveParentKey to createValue.

[0.7.4] 2018-06-08

Fixed

  • setProps wasn't updating state.props.

[0.7.3] 2018-05-29

Added

  • Support for default named transition

[0.7.0] 2018-05-28

Added

  • Tests
  • Support for transition definitions. Instead of defining animations with the native library:
transition: ({ value, ...props }) => Animated.spring(value, props)

This can be defined as:

transition: { type: 'spring' }

Removed

  • Removed support for transitionProps and setTransitionProps.

[0.6.2] 2018-05-17

Upgrade

[0.6.1] 2018-05-17

Fixed

  • Adding module path.

[0.6.0] 2018-05-17

Changed

  • Moving to Rollup for bundling.

[0.5.2] 2018-05-10

Fixed

  • Creating default ancestorValues if none exists.

[0.5.1] 2018-05-10

Fixed

  • Reversing logic for throwing transitionProps warning.

[0.5.0] 2018-05-09

Added

  • New readValueFromSource config option. Function that can read from the source target when no default pose is defined.

[0.4.1] 2018-05-09

Changed

  • Moving error messages to hey-listen.

[0.4.0@rc] 2018-05-07

  • Adding convertValue method. Allows users to define values like Popmotion's value or React Animated's Animated.Value and for the Pose flavour to upgrade that to a format it uses internally (for example with additional metadata)
  • Adding support for popmotion-pose setTransformProps and transformProps, adding deprecation warnings.
  • Adding invariant error message for when a pose is detected that isn't an object.

[0.3.0] 2018-05-06

  • Passing props through to createValue to allow it be mutated for special cases.

[0.2.0] 2018-05-05

  • Passing through all transition props to getInstantTransition

[0.1.7] 2018-04-24

  • Adding key to createValue.

[0.1.6] 2018-04-24

  • Adding setProps.

[0.1.5] 2018-04-23

  • Making config types optional.

[0.1.4] 2018-04-22

  • scale values default to 1.

[0.1.3] 2018-04-22

  • Fixing delay

[0.1.2] 2018-04-22

  • Adding initialPose to addChild.

[0.1.1] 2018-04-22

  • Adding lifecycle method for preTransition

[0.0.1] 2018-04-18

  • First publish