Giter Site home page Giter Site logo

bestraino / touchmovescale Goto Github PK

View Code? Open in Web Editor NEW

This project forked from windstormrage/touchmovescale

0.0 0.0 0.0 345 KB

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

Home Page: http://htmlpreview.github.io/?https://github.com/WindStormrage/touchMoveScale/blob/master/index.html

JavaScript 37.48% HTML 62.52%

touchmovescale's Introduction

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

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

Demo

看看呗 请在移动端打开 试试呗

jpgesV8iv2KYNu9

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.x 0 初始x轴偏移
transformData.y 0 初始y轴偏移
transformData.scale 1 初始缩放
maxScale Infinity 最大缩放值
minScale 0 最小缩放值
damping false 感觉像是有阻尼感,可以开启试试
perspective false 是否有透视效果

Function

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

touchmovescale's People

Contributors

windstormrage avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.