├── .eslintrc.js ├── .gitignore ├── .prettierrc ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── example-assets ├── 2squares.gif ├── broken_flip.png ├── browserstack.png ├── compressed-demo.gif ├── corrected_flip.png ├── debugging_flip.gif ├── dropdown.gif ├── enter-exit.gif ├── enter-update-delete.gif ├── list-transition.gif ├── listanimations.gif ├── listshuffle.gif ├── nested-example.gif ├── photogrid.gif ├── rft-logo.gif ├── shrug.png ├── sort-filter.gif ├── spring-options.gif ├── spring.gif ├── square.gif ├── stripe-menu.gif ├── swipe-simple.gif └── swipe.gif ├── package.json ├── packages ├── flip-toolkit │ ├── .babelrc │ ├── @types │ │ └── rematrix.d.ts │ ├── README.md │ ├── mocha │ │ ├── test-set-up.js │ │ ├── testrunner.html │ │ └── tests.js │ ├── package.json │ ├── src │ │ ├── Flipper.ts │ │ ├── Spring │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── constants.ts │ │ ├── flip │ │ │ ├── animateFlippedElements │ │ │ │ ├── __tests__ │ │ │ │ │ ├── animateFlippedElements.domtest.js │ │ │ │ │ ├── applyStyles.domtest.js │ │ │ │ │ ├── matrix.test.ts │ │ │ │ │ └── rectInViewport.test.ts │ │ │ │ ├── index.ts │ │ │ │ ├── spring │ │ │ │ │ ├── __tests__ │ │ │ │ │ │ └── spring.test.js │ │ │ │ │ └── index.ts │ │ │ │ └── types.ts │ │ │ ├── animateUnflippedElements │ │ │ │ ├── animateUnflippedElements.domtest.js │ │ │ │ ├── index.ts │ │ │ │ └── types.ts │ │ │ ├── getFlippedElementPositions │ │ │ │ ├── getFlippedElementPositions.domtest.js │ │ │ │ ├── getFlippedElementPositionsAfterUpdate │ │ │ │ │ ├── index.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── getFlippedElementPositionsBeforeUpdate │ │ │ │ │ ├── index.ts │ │ │ │ │ └── types.ts │ │ │ │ ├── types.ts │ │ │ │ └── utilities.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── forked-rebound │ │ │ ├── Loopers.js │ │ │ ├── README.md │ │ │ ├── Spring.js │ │ │ ├── SpringConfig.js │ │ │ ├── SpringSystem.js │ │ │ ├── index.js │ │ │ ├── onFrame.js │ │ │ ├── types.d.ts │ │ │ ├── types.ts │ │ │ └── util.js │ │ ├── index.ts │ │ ├── springSettings │ │ │ ├── index.test.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── types.ts │ │ └── utilities │ │ │ ├── index.ts │ │ │ ├── tweenProp.test.ts │ │ │ └── types.ts │ ├── test │ │ ├── index.html │ │ └── index.js │ └── tsconfig.json └── react-flip-toolkit │ ├── .babelrc │ ├── demo │ ├── CardsExample │ │ ├── Card.js │ │ ├── FocusedUser.js │ │ ├── UserGrid.js │ │ ├── index.js │ │ ├── styles.css │ │ └── userData.json │ ├── FancyDrawerSwipe │ │ └── index.js │ ├── FlipMove │ │ ├── Card.js │ │ ├── index.css │ │ └── index.js │ ├── GestureArticleSwipe │ │ └── index.js │ ├── GestureCardSwipe │ │ └── index.js │ ├── GestureSidebarExample │ │ ├── assets │ │ │ └── nighttime.jpg │ │ ├── index.js │ │ └── styles.css │ ├── GestureSidebarRightExample │ │ └── index.js │ ├── GestureStaggeredList │ │ ├── index.js │ │ └── styles.css │ ├── GuitarsExample │ │ ├── 200.html │ │ ├── GuitarItem.js │ │ ├── README.md │ │ ├── SelectedGuitar.js │ │ ├── css │ │ │ └── base.css │ │ ├── favicon.ico │ │ ├── guitarsData.js │ │ ├── img │ │ │ ├── 1.png │ │ │ ├── 10.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ ├── 8.png │ │ │ ├── 9.png │ │ │ ├── electric-guitar.svg │ │ │ └── related │ │ │ │ ├── GridItemAnimation.jpg │ │ │ │ └── ImageGridEffects.png │ │ ├── index.html │ │ ├── index.js │ │ └── pater │ │ │ ├── pater.css │ │ │ └── storyblocks.jpg │ ├── HandleEnterUpdateDelete │ │ ├── getRandomList.js │ │ ├── index.js │ │ └── styles.css │ ├── ListExample │ │ ├── index.css │ │ └── index.js │ ├── NestedFlipper │ │ ├── index.css │ │ └── index.js │ ├── PhotoGridExample │ │ ├── assets │ │ │ ├── detail-1.jpg │ │ │ ├── detail-5.jpg │ │ │ ├── detail-6.jpg │ │ │ └── detail-8.jpg │ │ ├── index.css │ │ └── index.js │ ├── PortalExample │ │ ├── IconGrid │ │ │ ├── Modal.js │ │ │ └── index.js │ │ ├── assets │ │ │ ├── creative │ │ │ │ ├── art_palette.svg │ │ │ │ ├── brush.svg │ │ │ │ ├── coffee.svg │ │ │ │ ├── device.svg │ │ │ │ └── fountain_pen.svg │ │ │ └── environment │ │ │ │ ├── bio_energy.svg │ │ │ │ ├── eco_friendly_vehicle.svg │ │ │ │ ├── electronic_recycling.svg │ │ │ │ ├── energy_saving_lightbulb.svg │ │ │ │ └── global_warming.svg │ │ ├── index.js │ │ └── styles.css │ ├── RemountedFlipperExample │ │ └── index.js │ ├── RotateExample │ │ ├── index.css │ │ └── index.js │ ├── SidebarExample │ │ ├── assets │ │ │ └── nighttime.jpg │ │ ├── index.js │ │ └── styles.css │ ├── StaggeredList │ │ ├── index.js │ │ └── styles.css │ ├── TransformExample │ │ ├── index.js │ │ └── styles.css │ ├── TransformExampleExitingParent │ │ ├── index.js │ │ └── styles.css │ ├── TransformFromZeroExample │ │ ├── index.js │ │ └── styles.css │ ├── ZeroJumpExample │ │ └── index.js │ ├── assets │ │ └── dogs │ │ │ ├── australian-shepard.jpg │ │ │ ├── black-doodle.jpg │ │ │ ├── border-collie.jpg │ │ │ ├── charles-451760-unsplash.jpg │ │ │ ├── corgi.jpg │ │ │ ├── fredrik-ohlander-520696-unsplash.jpg │ │ │ ├── french-bulldog.jpg │ │ │ ├── friends.jpg │ │ │ ├── golden-with-flower.jpg │ │ │ ├── husky.jpg │ │ │ ├── ian-dooley-325434-unsplash.jpg │ │ │ ├── ipet-photo-1316903-unsplash.jpg │ │ │ ├── oscar-sutton-719939-unsplash.jpg │ │ │ ├── pug.jpg │ │ │ └── samoyed.jpg │ ├── index.html │ └── index.js │ ├── package.json │ ├── src │ ├── ExitContainer │ │ └── index.tsx │ ├── Flipped │ │ ├── Flipped.test.tsx │ │ └── index.tsx │ ├── Flipper │ │ ├── Flipper.test.tsx │ │ ├── context.ts │ │ └── index.tsx │ ├── Spring │ │ └── index.ts │ └── index.ts │ └── tsconfig.json └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | plugins: ['@typescript-eslint'], 4 | extends: [ 5 | 'plugin:@typescript-eslint/recommended', 6 | 'plugin:react/recommended', 7 | ], 8 | settings: { 9 | react: { 10 | version: 'detect', 11 | }, 12 | }, 13 | rules: { 14 | indent: 'off', 15 | '@typescript-eslint/indent': 'off', 16 | '@typescript-eslint/camelcase': 'off', 17 | '@typescript-eslint/no-use-before-define': 'off', 18 | '@typescript-eslint/explicit-function-return-type': 'off', 19 | '@typescript-eslint/member-delimiter-style': 'off', 20 | '@typescript-eslint/no-non-null-assertion': 'off', 21 | '@typescript-eslint/no-explicit-any': 'off', 22 | '@typescript-eslint/explicit-member-accessibility': 'off', 23 | '@typescript-eslint/no-object-literal-type-assertion': 'off', 24 | '@typescript-eslint/array-type': 'off', 25 | '@typescript-eslint/explicit-member-accessibility': 'off', 26 | '@typescript-eslint/no-parameter-properties': 'off', 27 | '@typescript-eslint/ban-ts-ignore': 'off', 28 | '@typescript-eslint/explicit-module-boundary-types': 'off', 29 | '@typescript-eslint/ban-types': 'off', 30 | '@typescript-eslint/ban-ts-comment': 'off' 31 | }, 32 | } 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | demo/dist 4 | es 5 | core 6 | dist 7 | npm-debug.log* 8 | yarn-error.log* 9 | TODO 10 | .cache 11 | stats.json 12 | .idea 13 | .DS_STORE 14 | .vscode 15 | .rpt2_cache* 16 | .rts2_cache* 17 | lib 18 | temp 19 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "arrowParens": "avoid" 6 | } 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: node_js 4 | node_js: 5 | - 17 6 | 7 | before_install: 8 | - yarn add -W codecov.io coveralls 9 | 10 | install: 11 | - yarn 12 | 13 | script: yarn run lint && yarn run test 14 | 15 | after_success: 16 | - cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js 17 | - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js 18 | 19 | branches: 20 | only: 21 | - master 22 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Release Checklist 2 | 3 | Some unfortunately non-automated tasks that need to be done manually: 4 | 5 | 1. Run `yarn test` and `yarn test:dom` in the top level dir and make sure jest + mocha browser tests are passing (you'll need to check mocha tests in the browser) 6 | 2. Run `yarn format-and-fix` in the top level dir 7 | 3. Make sure readme is up-to-date 8 | 4. Verify that no unintended deps were added to `dependencies` in either package.json. 9 | 10 | 11 | ### Beta versions for testing 12 | 13 | Sometimes, you will want to test out changes before publishing them widely. In that case, do a pre-release by following these steps: 14 | 15 | 16 | 1. `npm version prepatch | preminor | premajor` 17 | 18 | 2. `npm publish --tag beta` 19 | 20 | 21 | ### Real release 22 | 23 | 1. Release `flip-toolkit`: 24 | - increment version number 25 | - run yarn build 26 | - commit with message formatted like: `git commit -m 'flip-toolkit@7.4.0'` 27 | - run npm publish 28 | 29 | Then, wait a bit (30mins+) and ensure the correct version shows up on: 30 | - npm: https://www.npmjs.com/package/flip-toolkit 31 | - unpkg: https://unpkg.com/flip-toolkit 32 | - package-phobia: https://packagephobia.com/result?p=flip-toolkit 33 | - bundle-phobia: https://bundlephobia.com/package/flip-toolkit 34 | - type declarations: https://arethetypeswrong.github.io/?p=flip-toolkit 35 | - and is working on this codesandbox which fetches the latest version of flip-toolkit: https://codesandbox.io/s/5v1k1nwz8l. Also check that type completions work in the sandbox. 36 | 37 | 2. Once everything looks good, release `react-flip-toolkit`: 38 | - `yarn upgrade flip-toolkit@^XXX` 39 | - increment version number 40 | - run yarn build 41 | - commit with message formatted like: `git commit -m 'react-flip-toolkit@7.4.0'` 42 | - run npm publish 43 | 44 | 45 | Once again, verify that everything looks good: 46 | - npm: https://www.npmjs.com/package/react-flip-toolkit 47 | - unpkg: https://unpkg.com/react-flip-toolkit 48 | - package-phobia: https://packagephobia.com/result?p=react-flip-toolkit 49 | - bundle-phobia: https://bundlephobia.com/package/react-flip-toolkit 50 | - type declarations: https://arethetypeswrong.github.io/?p=react-flip-toolkit 51 | - and is working on this codesandbox which fetches the latest version of react-flip-toolkit: https://codesandbox.io/s/8130rn9q2 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Holachek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example-assets/2squares.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/2squares.gif -------------------------------------------------------------------------------- /example-assets/broken_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/broken_flip.png -------------------------------------------------------------------------------- /example-assets/browserstack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/browserstack.png -------------------------------------------------------------------------------- /example-assets/compressed-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/compressed-demo.gif -------------------------------------------------------------------------------- /example-assets/corrected_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/corrected_flip.png -------------------------------------------------------------------------------- /example-assets/debugging_flip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/debugging_flip.gif -------------------------------------------------------------------------------- /example-assets/dropdown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/dropdown.gif -------------------------------------------------------------------------------- /example-assets/enter-exit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/enter-exit.gif -------------------------------------------------------------------------------- /example-assets/enter-update-delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/enter-update-delete.gif -------------------------------------------------------------------------------- /example-assets/list-transition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/list-transition.gif -------------------------------------------------------------------------------- /example-assets/listanimations.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/listanimations.gif -------------------------------------------------------------------------------- /example-assets/listshuffle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/listshuffle.gif -------------------------------------------------------------------------------- /example-assets/nested-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/nested-example.gif -------------------------------------------------------------------------------- /example-assets/photogrid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/photogrid.gif -------------------------------------------------------------------------------- /example-assets/rft-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/rft-logo.gif -------------------------------------------------------------------------------- /example-assets/shrug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/shrug.png -------------------------------------------------------------------------------- /example-assets/sort-filter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/sort-filter.gif -------------------------------------------------------------------------------- /example-assets/spring-options.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/spring-options.gif -------------------------------------------------------------------------------- /example-assets/spring.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/spring.gif -------------------------------------------------------------------------------- /example-assets/square.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/square.gif -------------------------------------------------------------------------------- /example-assets/stripe-menu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/stripe-menu.gif -------------------------------------------------------------------------------- /example-assets/swipe-simple.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/swipe-simple.gif -------------------------------------------------------------------------------- /example-assets/swipe.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aholachek/react-flip-toolkit/af8be42ce05045495effa687dac73e542db7cd45/example-assets/swipe.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-flip-toolkit", 3 | "private": true, 4 | "workspaces": [ 5 | "packages/*" 6 | ], 7 | "scripts": { 8 | "test": "yarn workspaces run build && yarn workspaces run test", 9 | "test:dom": "yarn workspace flip-toolkit test:dom", 10 | "lint": "yarn workspaces run lint", 11 | "format": "yarn workspaces run format", 12 | "format-and-fix": "yarn workspaces run format-and-fix", 13 | "fix": "yarn workspaces run fix", 14 | "check-types": "yarn workspaces run check-types", 15 | "build": "yarn workspaces run build", 16 | "build:debug": "yarn workspaces run build:debug", 17 | "demo": "yarn workspace react-flip-toolkit start", 18 | "watch": "yarn workspaces run watch" 19 | }, 20 | "version": "7.2.4" 21 | } 22 | -------------------------------------------------------------------------------- /packages/flip-toolkit/.babelrc: -------------------------------------------------------------------------------- 1 | // just for tests + parcel demo 2 | { 3 | "presets": [ 4 | "@babel/preset-typescript", 5 | "@babel/preset-react", 6 | "@babel/preset-env" 7 | ], 8 | "plugins": ["@babel/plugin-proposal-class-properties"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/flip-toolkit/@types/rematrix.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'rematrix' { 2 | export function parse(string: string): number[] 3 | export function translateX(num: number): number[] 4 | export function translateY(num: number): number[] 5 | export function scaleX(num: number): number[] 6 | export function scaleY(num: number): number[] 7 | export function multiply(arr1: number[], arr2: number[]): number[] 8 | } 9 | 10 | -------------------------------------------------------------------------------- /packages/flip-toolkit/README.md: -------------------------------------------------------------------------------- 1 | # flip-toolkit 2 | 3 | [](https://bundlephobia.com/result?p=flip-toolkit) 4 | [](http://opensource.org/licenses/MIT) 5 | [](https://npmjs.org/package/flip-toolkit 'View this project on npm') 6 | 7 | Using `Vue.js` ? Try [vue-flip-toolkit](https://github.com/mattrothenberg/vue-flip-toolkit). 8 | 9 | ## Basic Example 10 | 11 | [**Fork this example on CodeSandbox**](https://codesandbox.io/s/5v1k1nwz8l) 12 | 13 | ```js 14 | import { Flipper } from 'flip-toolkit' 15 | const container = document.querySelector('.container') 16 | const square = document.querySelector('.square') 17 | const innerSquare = document.querySelector('.inner-square') 18 | 19 | const flipper = new Flipper({ element: container }) 20 | 21 | // add flipped children to the parent 22 | flipper.addFlipped({ 23 | element: square, 24 | // assign a unique id to the element 25 | flipId: 'square', 26 | onStart: () => console.log('animation started!'), 27 | onSpringUpdate: springValue => 28 | console.log(`current spring value: ${springValue}`), 29 | onComplete: () => console.log('animation completed!') 30 | }) 31 | 32 | // to add an inverted child 33 | // (so that the text doesn't warp) 34 | // use this method with 35 | // a reference to the parent element 36 | flipper.addInverted({ 37 | element: innerSquare, 38 | parent: square 39 | }) 40 | 41 | square.addEventListener('click', () => { 42 | // record positions before they change 43 | flipper.recordBeforeUpdate() 44 | square.classList.toggle('big-square') 45 | // record new positions, and begin animations 46 | flipper.update() 47 | }) 48 | ``` 49 | 50 | To learn more about which configuration options are available, [check out the code for the `Flipper` class here](../react-flip-toolkit/src/FlipToolkit/Flipper.ts) or [read the docs for `react-flip-toolkit`](../react-flip-toolkit/README.md) 51 | 52 | ## Spring 53 | 54 | `flip-toolkit` also exports a utility function, `spring`, that can be used to orchestrate non-FLIP animations. 55 | 56 | [**Fork this example on CodeSandbox**](https://codesandbox.io/s/spring-example-6xw5p) 57 | 58 | ```js 59 | import { spring } from "flip-toolkit"; 60 | 61 | const container = document.querySelector(".container"); 62 | const squares = [...container.querySelectorAll(".square")]; 63 | 64 | squares.forEach((el, i) => { 65 | spring({ 66 | config: "wobbly", 67 | values: { 68 | translateY: [-15, 0], 69 | opacity: [0, 1] 70 | }, 71 | onUpdate: ({ translateY, opacity }) => { 72 | el.style.opacity = opacity; 73 | el.style.transform = `translateY(${translateY}px)`; 74 | }, 75 | delay: i * 25, 76 | onComplete: () => { 77 | // add callback logic here if necessary 78 | } 79 | }); 80 | }); 81 | ``` 82 | -------------------------------------------------------------------------------- /packages/flip-toolkit/mocha/test-set-up.js: -------------------------------------------------------------------------------- 1 | import 'regenerator-runtime/runtime' 2 | // mocha will be global 3 | require("mocha") 4 | const chai = require("chai") 5 | // we need a global "expect" function too 6 | window.expect = chai.expect 7 | mocha.setup("bdd") 8 | -------------------------------------------------------------------------------- /packages/flip-toolkit/mocha/testrunner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |