Giter VIP home page Giter VIP logo

move.js's Introduction

封装原生 Touch eventsMouseEvent 事件

  • 使回调数据结构只有一维,多手指触摸单独回调处理更方便
  • 提供了坐标、实时位移量、累计位移量

安装

npm install sao_move

使用简单

传入要监听的对象即可

const elecomnt = this.$refs.app

new SaoMove(elecomnt, (e) => {
    console.log(e)
})

回调参数内容

{
    "type": "touch",
    "event": "start",
    "identifier": 0,
    "x": 204.41114807128906,
    "y": 376.5450744628906,
    "moving_x": 0,
    "moving_y": 0,
    "total_x": 0,
    "total_y": 0,
    "e": "原生事件"
}
字段 含义 备注
type 移动类型 touch / mouse
event 事件类型 start / moving / stop
identifier 触摸手指标识 数字标识,鼠标类型为0
x 实时x坐标
y 实时y坐标
moving_x 实时x位移
moving_y 实时y位移
total_x 累计x位移
total_y 累计y位移

其他

  • total_x,total_y

是指从此次动作开始,到当前坐标的位移

  • moving_xmoving_x

是指从上个坐标到当前坐标的实时位移

  • identifier

通过identifier来区分每个手指单独的 start、moving、stop,多手指互不干扰

更新

  • 2.1 新增返回原生事件

move.js's People

Contributors

saopanda avatar

Watchers

 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.