# pose-core

> Factory for Pose animation state machines

Latest version **2.1.1** (published 2019-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install pose-core
pnpm add pose-core
yarn add pose-core
bun add pose-core
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score; popular repo.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2019-11-14 |
| First published | 2018-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 316.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20152 |
| Author | Matt Perry |
| Maintainers | popmotion |
| Keywords | animation, dom, declarative, popmotion |

## Links

- npm: https://www.npmjs.com/package/pose-core
- Repository: https://github.com/Popmotion/popmotion/tree/master/packages/pose-core
- npm.io page: https://npm.io/package/pose-core

## Dependencies (6)

- [tslib](https://npm.io/package/tslib.md) ^1.10.0
- [hey-listen](https://npm.io/package/hey-listen.md) ^1.0.5
- [typescript](https://npm.io/package/typescript.md) ^3.7.2
- [@types/node](https://npm.io/package/@types/node.md) ^10.0.5
- [@types/invariant](https://npm.io/package/@types/invariant.md) ^2.2.29
- [rollup-plugin-typescript2](https://npm.io/package/rollup-plugin-typescript2.md) ^0.25.2

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2019-11-14
- 2.0.1-rc (beta) — 2018-09-06
- 0.4.0 (rc) — 2018-05-08
- 2.1.0 — 2019-02-04
- 2.0.3 — 2019-01-28
- 2.0.2 — 2018-12-04
- 2.0.0 — 2018-09-06
- 2.0.3-rc — 2018-09-06
- 2.0.0-rc — 2018-09-06
- 1.0.4 — 2018-09-05
- 1.0.3 — 2018-08-26
- 1.0.2 — 2018-08-20
- 1.0.1 — 2018-08-19
- 1.0.0 — 2018-08-19
- 0.8.1 — 2018-08-18
- … 22 more at https://npm.io/package/pose-core/versions

## README

# Pose Core

## Factory for Pose animation state machines

[![npm version](https://img.shields.io/npm/v/pose-core.svg?style=flat-square)](https://www.npmjs.com/package/pose-core)
[![npm downloads](https://img.shields.io/npm/dm/pose-core.svg?style=flat-square)](https://www.npmjs.com/package/pose-core)
[![Twitter Follow](https://img.shields.io/twitter/follow/popmotionjs.svg?style=social&label=Follow)](http://twitter.com/popmotionjs)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/popmotion)

## Install

```
npm install pose-core --save
```

## Create a poser factory

### JavaScript

```javascript
import poseFactory from 'pose-core';

const pose = poseFactory(config);
```

### TypeScript

```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.

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

### `readValue`

Read and return from `Value`.

```typescript
(value: Value) => any;
```

### `createValue`

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

```typescript
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`.

```typescript
(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. 

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

### `bindOnChange`

Bind the `onChange` callbacks to their respective `Value`s. 

```typescript
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)

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

### `stopAction`

Takes an action subscription and stops it.

```typescript
(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.

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

### `addActionDelay`

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

```typescript
(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.

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

### `selectValueToRead`

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

```typescript
(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.

```typescript
(api: Poser) => Poser
```

---
_Source: https://npm.io/package/pose-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
