1.0.1 • Published 3 years ago

touch-move-scale v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

touch-move-scale 移动端画布移动缩放库

touch-move-scale 是原生写的移动端画布移动缩放库, 你可以给元素添加单指移动和双指缩放的功能

Demo

touch-move-scale 请在移动端打开

Install

npm i touch-move-scale -S

Quick Start

<div id="touchBox">
  <img id="transformDom" />
</div>

import TouchMoveScale from './index.js'
const touchMoveScale = new TouchMoveScale({
  touchDom: document.getElementById('touchBox'),
  transformDom: document.getElementById('transformDom')
})

Options

参数默认值含义
touchDom-必填手指操作的区域元素
transformDom-必填缩放应用的元素
transformData-位移缩放初始值
transformData.x0初始x轴偏移
transformData.y0初始y轴偏移
transformData.scale1初始缩放
maxScaleInfinity最大缩放值
minScale0最小缩放值
dampingfalse感觉像是有阻尼感,可以开启试试
perspectivefalse是否有透视效果

Function

方法名参数含义
enlargeScalesize: 放大倍数进行放大操作
narrowScalesize: 缩小倍数进行缩小操作
getTransformData-获得当前的位移和缩放, 其中的位移没有被缩放, 是先缩放然后再位移
setPerspectivevalue: Boolean设置perspective
setDampingvalue: Boolean设置damping
distory-销毁监听