项目作者: birjolaxew

项目描述 :
FLIP animation helper; animate DOM changes with ease
高级语言: JavaScript
项目地址: git://github.com/birjolaxew/flippy.js.git
创建时间: 2016-02-27T15:11:39Z
项目社区:https://github.com/birjolaxew/flippy.js

开源协议:MIT License

下载


FlippyJS

FlippyJS is a helper library for FLIP animations - it allows you to easily animate any changes you make to the DOM, without having to specify the animation manually. All animations are done using CSS animations.

It is exported as a UMD library, supporting both AMD, CommonJS and basic <script> usage.

Usage

Flippy.js exposes the function flip(elements, modifier, [options]). Pass it the elements you want to animate, a function which should modify the DOM when called, and an optional options object. It returns a Promise which resolves when the animation is finished.

For specifics, see our docs.

Here’s a quick example:

  1. const container = document.querySelector(".notification-container");
  2. flip(
  3. ".notification", // the elements to animate
  4. ()=>{ // called when we should make the DOM change
  5. container.insertBefore(
  6. generateNotification(),
  7. container.firstChild
  8. );
  9. }
  10. ).then(()=>{
  11. console.log("Animation finished");
  12. });
  13. function generateNotification() { /* ... */ }

Advanced usage

Internally, FlippyJS uses a FLIPElement class to represent elements that are being animated. This class is exposed as flip.FLIPElement, should you wish to play around with it.

More details at our docs.