drop-animation

0.0.5 • Public • Published

drop-animation

npm npm

浏览器中的掉落动画 🎾

Install

npm install drop-animation --save

Start

import Dropper from 'drop-animation';
 
// 新建实例
function onClick() {
  new Dropper({
    element: '<div class="dropper"></div>',
    startPosition: {
      x: x + width / 2,
      y: y + height / 2,
    },
    endPosition,
    width,
    height,
  });
}

Document

new Dropper(Object opts)

参数 Object opts:

属性 类型 是否必填 默认值 说明
element Element | String - 掉落元素
container Element document.body 父级容器
startPosition.x Number 0 起点位置横坐标,单位:px
startPosition.y Number 0 起点位置纵坐标,单位:px
endPosition.x Number 0 终点位置横坐标,单位:px
endPosition.y Number 0 终点位置纵坐标,单位:px
width Number 0 掉落元素宽度,单位:px
height Number 0 掉落元素高度,单位:px
duration Number 600 掉落时间,单位:ms
jumpHeight Number 60 弹跳的高度,单位:px
scale Number 1 缩放值
rotate Number 360 旋转度数
onEnd Function () => {} 动画结束回调
endAnimation Boolean true 是否需要收尾动画
endRotate Number 360 收尾旋转角度
endJumpHeight Number 40 收尾弹跳的高度,单位:px
endAnimationDuration Number 400 收尾动画时间,单位:ms

Demo

cd demo
npm install
npm start

访问 http://localhost:3000 查看

Package Sidebar

Install

npm i drop-animation

Weekly Downloads

4

Version

0.0.5

License

ISC

Unpacked Size

15.1 kB

Total Files

7

Last publish

Collaborators

  • wangdagen