• Stars
    star
    303
  • Rank 137,655 (Top 3 %)
  • Language Vue
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

A Vue.js port of the wonderful react-flip-toolkit by @aholachek

vue-flip-toolkit

Vue Flip Toolkit Version Badge

A Vue.js port of the wonderful react-flip-toolkit, developed by @aholachek (to whom all credit is due here)

Quick Start

yarn add vue-flip-toolkit

Wrap the components you wish to animate with a single Flipper component that has a flipKey prop. This prop must change every time you want an animation to happen.

Wrap elements that should be animated with Flipped components that have a flipId prop matching them across renders.

A basic example can be found here: https://codesandbox.io/s/m354w1mmp9

Why even port this to Vue.js?

Fair question. In developing my own library, vue-overdrive, I've felt the pain of not being able to find a declarative library for animating a given DOM element between two states. Upon discovering react-flip-toolkit, which has a first-class "core" API that can be used outside of React, I wanted to take a crack at using it to re-implement vue-overdrive. The fruit of my attempt is the following library, vue-flip-toolkit.

What's in this library?

This library strives to imitate its parent, react-flip-toolkit, as closely as possible. It thus exports the following two components that you can use in your Vue applications. For the sake of brevity, I've lifted descriptions/verbiage from the README of react-flip-toolkit, indicated via blockquotes.

Flipper.vue

The parent wrapper component that contains all the elements to be animated. You'll most typically need only one of these per page. Read more โ€“>

Props

prop default type details
className โ€“ string A class that will apply to the div rendered by Flipper
flipKey (required) โ€“ string, number, boolean Changing this tells vue-flip-toolkit to transition child elements wrapped in Flipped components.
spring "noWobble" string, object Provide a string or referencing one of the spring presets โ€” noWobble, veryGentle, gentle, wobbly, or stiff. Otherwise, pass a custom spring object
staggerConfig {} object Provide configuration for staggered Flipped children.

Flipped.vue

Wraps an element that should be animated.

Props

prop default type details
flipId (required) โ€“ string Use this to tell vue-flip-toolkit how elements should be matched across renders so they can be animated.
inverseFlipId โ€“ string Refer to the id of the parent Flipped container whose transform you want to cancel out. If this prop is provided, the Flipped component will become a limited version of itself that is only responsible for cancelling out its parent transform. It will read from any provided transform props and will ignore all other props (besides inverseFlipId.)
stagger โ€“ string Provide a natural, spring-based staggering effect in which the spring easing of each item is pinned to the previous one's movement. If you want to get more granular, you can provide a string key and the element will be staggered with other elements with the same key.
delayUntil โ€“ string Delay an animation by providing a reference to another Flipped component that it should wait for before animating (the other Flipped component should have a stagger delay as that is the only use case in which this prop is necessary.)
shouldInvert โ€“ function A function provided with the current and previous decisionData props passed down by the Flipper component. Returns a boolean indicating whether to apply inverted transforms to all Flipped children that request it via an inverseFlipId.
shouldFlip โ€“ function A function provided with the current and previous decisionData props passed down by the Flipper component. Returns a boolean to indicate whether a Flipped component should animate at that particular moment or not.
opacity false boolean
scale false boolean Tween scaleX and scaleY
translate false boolean Tween translateX and translateY

Events

eventName args details
@on-start {el: DOMElement, id: String} Emitted when the flipped animation begins.
@on-complete {el: DOMElement, id: String} Emitted when the flipped animation begins.

Cool, so how do I use it?

Install the library

yarn add vue-flip-toolkit

Import the respective components.

import { Flipper, Flipped } from "vue-flip-toolkit";

Register the components.

// Example.vue
<script>
export default {
  components: {
    Flipped,
    Flipper
  }
};
</script>

OK, time for some examples.

You got it.

1) Simple, Expanding Div Animation

Source

2) Two Divs

Source

3) List Shuffle Animation

Source

4) List Shuffle Animation (Staggered)

Source

5) Accordion (Staggered)

Source

6) Scale Animation + Anime.js

Source

7) Material Design inspired animation

Source

8) Vue Router Example

This example is very much a WIP. Nonetheless, it illustrates at a high-level how to use vue-flip-toolkit with vue-router, as well as hook into the @on-complete and @on-start events.

Source

What's next?

A lot.

Primarily, I want to make sure that this basic set of functionality works for Vue developers, and that the API makes sense.

Once we check that box, I'd like to add support for additional props for both Flipped and Flipper. Right now, you can't do too too much with them.

More Repositories

1

vue-overdrive

Super easy magic-move transitions for Vue apps
Vue
684
star
2

vue-storybook

Custom <story> blocks for Vue single file components
JavaScript
149
star
3

use-gauge

A headless React hook for building beautiful gauge charts.
TypeScript
63
star
4

tailwind-fancy-tab

Headless UI tabs treated with a futuristic visual design
TypeScript
52
star
5

vue-elucidate

A library for documenting Vue components
Vue
34
star
6

react-comparison-slider

A keyboard accessible "before & after" component for React โฌ…๏ธโžก๏ธ
TypeScript
33
star
7

prototyping-playbook

A winner's guide to prototyping in the browser
CSS
27
star
8

gatsbygram

A Gatsby.js clone of Pentagram's website
JavaScript
20
star
9

vue-grid-styled

Lightweight set of functional grid components
JavaScript
17
star
10

styleguide-boilerplate

A project to help Designers build living styleguides with Sass and Hologram.
CSS
17
star
11

parcel-craft-example

A Craft CMS + ParcelJS Website
JavaScript
16
star
12

react-overflow-list

A headless React component that lets you control how visible and overflown items are rendered ๐Ÿ‘€
TypeScript
12
star
13

vue-storybook-example

Vue
11
star
14

inboxclone

JavaScript
9
star
15

statamic-mapbox-address

PHP
9
star
16

webmentions

A Webmentions Tag for Statamic V3
Vue
8
star
17

location

A Location Autocomplete Field for Statamic V3
Vue
5
star
18

flat-data-to-ts

TypeScript
4
star
19

remix-github

TypeScript
4
star
20

badger

Badge generator powered by Satori ๐Ÿชช
TypeScript
4
star
21

duckb-browser-block

A GitHub Next Folder Block for querying flat data in your repository
TypeScript
3
star
22

runway-cli

JavaScript
3
star
23

vscode-toolkit-ui-react

TypeScript
2
star
24

package-json-badge-block

TypeScript
2
star
25

airtable-clone

JavaScript
2
star
26

tusi

TypeScript
1
star
27

sentry-next-example

JavaScript
1
star
28

use-auto-scroll

TypeScript
1
star
29

quill-image-resize-interact

JavaScript
1
star
30

styleguide-block

TypeScript
1
star
31

labs-design-yeoman

Custom Yeoman project for Labs Designers
CSS
1
star
32

observable-plot-tooltip

TypeScript
1
star
33

directory-size-block

Visualizes the sizes of files in a directory
TypeScript
1
star
34

codeowners-block

A GUI for authoring and editing CODEOWNERS files
TypeScript
1
star
35

streeteasy-ads

Build your very own "Find Your Place" Streeteasy Ad
JavaScript
1
star
36

tailwindcss-stack-plugin

A Tailwind plugin for custom "stack" utility classes
JavaScript
1
star