• Stars
    star
    1,380
  • Rank 34,085 (Top 0.7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flipping awesome animations.

Flipping

A library (and collection of adapters) for implementing FLIP transitions.

For more information about the FLIP technique, view the flipping slides:

Examples

Installation

npm install flipping@latest --save

Or grab the files directly:

Quick Start

In your HTML, add the data-flip-key="..." attribute to shared elements (see HTML example below).

import Flipping from 'flipping';

const flipping = new Flipping();

// Before a layout change happens
flipping.read();

// Any effect that changes the layout
doSomething(); 

// After a layout change happens
// With an adapter, this will start the FLIP animation
flipping.flip();
<!-- first view -->
<section class="gallery">
  <div class="photo-1" data-flip-key="photo-1">
    <img src="/photo-1"/>
  </div>
  <div class="photo-2" data-flip-key="photo-2">
    <img src="/photo-2"/>
  </div>
  <div class="photo-3" data-flip-key="photo-3">
    <img src="/photo-3"/>
  </div>
</section>

<!-- second view -->
<section class="details">
  <div class="photo" data-flip-key="photo-1">
    <img src="/photo-1"/>
  </div>
  <p class="description">
    Lorem ipsum dolor sit amet...
  </p>
</section>

API

new Flipping(options?)

Creates a new Flipping instance. This is the thing that keeps track of all the changes made, and determines if any elements changed positions or size.

Parameters for options

For greater control and custom animations, you can pass in the following parameters (all optional):

  • selector?: (parent: Element) => Element[]; - Selects all "flippable" elements. Defaults to all elements that have a [data-flip-key] attribute.
  • activeSelector: (element) => Element[]; - Selects the currently active "flippable" elements. Defaults to selecting the visible flippable elements.
  • onFlip?: (state: IFlipStateMap) => void; - Event listener. Called with the entire state map of tracked flippable elements whenever .flip() is called.
  • onRead?: (state: IFlipStateMap) => void; - Event listener. Called with the entire state map of tracked flippable elements whenever .read() is called.
  • onEnter?: (state: IFlipStateMap) => void; - Event listener. Called with the state map of elements that enter (that is, not previously tracked).
  • onLeave?: (state: IFlipStateMap) => void; - Event listener. Called with the state map of elements that leave (that is, previously tracked but no longer active).
  • parent?: Element; - The root element to query all flippable elements. Defaults to the <body>.
  • plugins?: FlipPlugin[]; - An array of plugins that transform the state map before being emitted.
  • duration?: number - Animation duration in ms. Defaults to 300.
  • easing?: string - Easing function name e.g. ease-in-out. Defaults to cubic-bezier(.5, 0, .5, 1).

flipping.read(): void

Queries all the flippable selectors and reads their bounds (position and size). This must be called before layout changes are made.

Will call any onRead() event listeners with the entire state map.

flipping.flip(): void

Queries all the flippable selectors and reads their bounds (position and size), and then determines the deltas (changes in position and/or size)

Will call any onFlip() event listeners with the entire state map.

flipping.wrap(fn): void

  1. Calls flipping.read()
  2. Calls the wrapped fn()
  3. Returns the result of the wrapped fn()
  4. Calls flipping.flip()

It's a nice shorthand. Use it.

data-flip-key="..."

HTML data-attribute that tracks the same/shared elements and identifies them as the "same" element.

data-flip-no-scale

HTML data-attribute that prevents the Flipping adapters from trying to apply scale() to a transformed element.

More Repositories

1

react-redux-form

Create forms easily in React with Redux.
JavaScript
2,066
star
2

useEffectReducer

useReducer + useEffect = useEffectReducer
TypeScript
791
star
3

RxCSS

JavaScript
416
star
4

sassdash

The Sass implementation of lodash.
SCSS
386
star
5

sass-svg

Inline SVG for Sass.
CSS
314
star
6

frontend-masters-xstate-workshop

Frontend Masters State Machines & XState Workshop
JavaScript
242
star
7

frontend-masters-css

SCSS
169
star
8

sassport

Sass with JavaScript superpowers.
JavaScript
147
star
9

frontend-masters-react-workshop

Code for the Frontend Masters React State Modeling Workshop
JavaScript
128
star
10

nm8

Ridiculously small animation library.
TypeScript
122
star
11

frontend-masters-xstate-v2

Frontend Masters XState Workshop v2
JavaScript
121
star
12

react-simple-datepicker

Simple datepicker for React.
JavaScript
119
star
13

xstate-test-demo

Demo React project for model-based testing with @xstate/test
JavaScript
111
star
14

durable-entities-xstate

XState + Durable Entities = πŸš€
TypeScript
53
star
15

xstate-react-workshop

React Finland - Modeling React Applications with Statecharts Workshop
JavaScript
24
star
16

weatherboard

TypeScript
23
star
17

xviz

Small graph visualization library
TypeScript
19
star
18

propelcss

CSS
19
star
19

postcss-emoji-style

JavaScript
19
star
20

xstate-todomvc

Created with CodeSandbox
JavaScript
18
star
21

xstate-examples

Example XState Projects
17
star
22

xstate-command

Command palette with XState
TypeScript
12
star
23

react-finland-xstate-2022

React Finland 2022 XState Workshop
JavaScript
11
star
24

mbt-workshop

Model-Based Testing Workshop
JavaScript
11
star
25

react-finland-xstate-workshop

React Finland XState Workshop
JavaScript
11
star
26

sass-v

CSS Custom Properties + Sass = πŸš€
SCSS
10
star
27

RxAnimate

Reactive Animations
TypeScript
10
star
28

openapi-test

OpenAPI Testing Library
TypeScript
10
star
29

node-azure-mvc

Example application for creating an MVC Express + Node + TypeScript app and deploying it to Azure
TypeScript
10
star
30

redux-test-store

Test existing stores in Redux, the easy way
JavaScript
8
star
31

skylake

πŸ’Ž A light JavaScript library.
JavaScript
8
star
32

xstate-interpreter

Reactive statechart interpreter.
TypeScript
7
star
33

paz

Peaceful Azure deployments with node
6
star
34

movement

Sass/SCSS/CSS animation framework for creating, composing, sequencing, and using animations.
CSS
6
star
35

davidkpiano

5
star
36

getrect

TypeScript
5
star
37

rxio

TypeScript
4
star
38

xstate-tetris

TypeScript
4
star
39

issuspensereadyyet

...
JavaScript
4
star
40

tracker

Track DOM elements efficiently.
4
star
41

netlify-edge-machine

TypeScript
4
star
42

neo4j-workshop

Neo4j Statecharts Workshop
JavaScript
3
star
43

rxform

TypeScript
3
star
44

gulp-sassport

Sassport gulp plugin
JavaScript
3
star
45

sassport-reference

Import by Reference in Sass using Sassport
JavaScript
3
star
46

vanilla-todomvc-ts

TypeScript
3
star
47

cadenza-old

SCSS/CSS Framework
CSS
2
star
48

movi

Stately animations
2
star
49

cse-articles

Microsoft CSE Articles
2
star
50

rxstyle

Animation framework for RxJS
JavaScript
2
star
51

sassport-svgo

Inline, optimized SVG inside your Sass files.
JavaScript
2
star
52

sassport-dynamic

Dynamic imports for Node-Sass using Sassport
JavaScript
2
star
53

rrf-docs

CSS
2
star
54

react-redux-form-builder

React Redux Form Builder
JavaScript
2
star
55

webanimate

TypeScript
2
star
56

stately-site

HTML
2
star
57

cz-temp

CSS
2
star
58

angular-fluid

Form Logic User Interface Directive - Form Logic implementation for AngularJS
CSS
2
star
59

orlandodevs-site

HTML
1
star
60

react-redux-form-docs

1
star
61

styledash

JavaScript
1
star
62

react-state-machine

Finite State Machines for React.
1
star
63

logicapp-specflow-demo

C#
1
star
64

sassport-math

Math for Sass.
JavaScript
1
star
65

emojio

1
star
66

goatspresso

Goats and Espresso
JavaScript
1
star
67

test-gen-demo

TypeScript
1
star
68

react-redux-form-book

1
star
69

postcss-movement

1
star
70

rxy

For Atomic Hack Party
PHP
1
star
71

movt

Movement
JavaScript
1
star
72

react-dynamic

Dynamic.js Animation Library for React
1
star
73

styleguides

1
star
74

react-move

Nothing to see here
JavaScript
1
star
75

cadenza

1
star
76

sass-z

Z-index management for Sass.
1
star
77

generator-sass-guide

Yeoman generator for Sass Guidelines
JavaScript
1
star