项目作者: ymzuiku

项目描述 :
适用于任何框架的 Javascript 动画库 \ Animation of all Javascript frame
高级语言: JavaScript
项目地址: git://github.com/ymzuiku/AnimJS.git
创建时间: 2017-03-21T03:56:58Z
项目社区:https://github.com/ymzuiku/AnimJS

开源协议:

下载


AnimJS

中文说明

Animation of all Javascript frame

Use bezier-easing: https://github.com/gre/bezier-easing

GIF
GIF
GIF
GIF

Use Anim.js in React or ReactNative

1.Download Anim.js, and import

  1. import Anim from './Anim.js'

2.Bind this.state value

  1. render() {
  2. return (
  3. <div style={{
  4. transform: `translateX(${this.state.x}px)`,
  5. width: 200,
  6. height: 200,
  7. backgroundColor: '#f00',
  8. color: '#fff',
  9. }}
  10. onClick={this.handleClick}
  11. >
  12. Touch Me!
  13. </div>
  14. )
  15. handleClick = ()=>{}
  16. }

3.Use Anim.js change this.state.x

  1. handleClick = () => {
  2. let move = Anim.init(0.5, (p) => {
  3. this.setState({
  4. x: Anim.motion(0, 100, p)
  5. })
  6. })
  7. move.play()
  8. }

API List

Anim.init()

Anim.init(time, function)

  1. let an = Anim.init(0.3, (value)=>{console.log(value)})
  2. an.play(()=>{console.log('animation is end')})

value is 0~1 in 0.3 second

Anim.motion()

Anim.motion(startValue, endValue, value)

  1. let an = Anim.init(0.3, (value)=>{
  2. let per = Anim.motion(50, 150, value)
  3. console.log(per)
  4. })
  5. an.play()

Anim.ease

  1. let an = Anim.init(0.3, (value)=>{
  2. let per = Anim.motion(50, 150, value)
  3. console.log(per)
  4. })
  5. an.easing = Anim.ease.spring
  6. //or
  7. an.easing = [0.25, 0.5, 0.7, 1]
  8. an.play()

delay, yoyo, replay, play, stop

  1. an.delay = 10
  2. an.yoyo = true
  3. an.replay = 10
  4. an.play()

play(callback()), stop()

  1. an.play(()=>{console.log('animation is end')})
  2. an.stop()