Change number with flipping animation

install

$ npm install --save number-flip
Copy the code

usage

import number-flip

import Flip from 'number-flip'
Copy the code

use it!

create one and make it flip:

new Flip({
  node: $('.flip'),
  from: 9527,
  to: 42
})
Copy the code

flip one with delay:

new Flip({
  node: $('.flip'),
  from: 9527,
  to: 42,
  delay: 1000
})
Copy the code

create one and flip it later:

const el = new Flip({
  node: $('.flip'),
  from: 9527
})

el.flipTo({to: 42})
Copy the code

costumize animate duration:

new Flip({
  node: $('.flip'),
  from: 9527,
  to: 42,
  duration: 2
})
Copy the code

more complex usage

new Flip({ node: $('.flip'), from: 73, to: 25, duration: 2, delay: 1, easeFn: Function (pos) {if (pos/=0.5) < 1) return 0.5* math.pow (pos,3); Return 0.5 * (math.pow ((pos-2),3) + 2); }, systemArr: [' zero ', '1', '2', '3', 'boss', 'wu', 'land', 'pure', ' ', 'nine']})Copy the code

TODO

  • flip with FLIP
  • browser compatibility list
  • thresh maybe

license

MIT

contributing

  1. fork this repo
  2. git checkout -b NEW-FEATURE
  3. git commit -am 'ADD SOME FEATURE'
  4. git push origin NEW-FEATURE