0.0.5 • Published 5 years ago

drop-animation v0.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

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:

属性类型是否必填默认值说明
elementElement | String-掉落元素
containerElementdocument.body父级容器
startPosition.xNumber0起点位置横坐标,单位:px
startPosition.yNumber0起点位置纵坐标,单位:px
endPosition.xNumber0终点位置横坐标,单位:px
endPosition.yNumber0终点位置纵坐标,单位:px
widthNumber0掉落元素宽度,单位:px
heightNumber0掉落元素高度,单位:px
durationNumber600掉落时间,单位:ms
jumpHeightNumber60弹跳的高度,单位:px
scaleNumber1缩放值
rotateNumber360旋转度数
onEndFunction() => {}动画结束回调
endAnimationBooleantrue是否需要收尾动画
endRotateNumber360收尾旋转角度
endJumpHeightNumber40收尾弹跳的高度,单位:px
endAnimationDurationNumber400收尾动画时间,单位:ms

Demo

cd demo
npm install
npm start

访问 http://localhost:3000 查看