Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
better-gesture
Advanced tools
A gesture library compatible with multiple terminals (native, PC, mobile, Vue, applet)
文档地址: https://wensiyuanseven.github.io/better-gesture
3.77KB
npm install better-gesture
目前可以通过 unpkg.com/获取到最新版本的资源,在页面上引入js
文件即可开始使用。
<!-- 最新版本 -->
<script src='https://unpkg.com/better-gesture/lib/better-gesture.umd.min.js'></script>
<!-- 指定版本 -->
<script src='https://unpkg.com/better-gesture@0.2.1/lib/better-gesture.umd.min.js'></script>
<script src='https://unpkg.com/better-gesture/lib/better-gesture.umd.min.js'></script>
<div id="example"></div>
<script>
new BetterGesture(document.getElementById('example'), {
//拖拽
pressMove(evt) {
console.log(evt.deltaX, evt.deltaY)
},
// 旋转
rotate(evt) {
console.log(evt.angle)
},
// 缩放
pinch(evt) {
console.log(evt.zoom)
},
// 滑动
swipe(evt) {
console.log(evt.direction)
}
//......
})
</script>
import Vue from 'vue'
import gesture from 'better-gesture'
Vue.use(gesture)
<template>
<section class="example">
<div v-gesture:pressMove="pressMove" v-gesture:doubleTap="doubleTap"> </div>
</section>
</template>
<script>
export default {
methods: {
//拖拽
pressMove(evt) {
console.log(evt.deltaX, evt.deltaY)
},
// 旋转
rotate(evt) {
console.log(evt.angle)
},
// 缩放
pinch(evt) {
console.log(evt.zoom)
},
// 滑动
swipe(evt) {
console.log(evt.direction)
}
//......
}
}
</script>
npm构建引入
在小程序 package.json 所在的目录中执行命令安装 npm 包
npm install better-gesture
点击开发者工具中的菜单栏:工具 --> 构建 npm
或者CDN下载引入
// npm构建引入
import BetterGesture from './../miniprogram_npm/better-gesture/better-gesture.umd.min.js'
// cdn下载引入
import BetterGesture from './../utils/better-gesture.js'
使用
建议使用catch捕获事件,否则易造成监听动画卡顿
<!-- wxml -->
<!-- 必须初始化事件touchstart,touchmove,touchend,touchcancel-->
<!-- 函数名必须定义为start,move,end,cancel -->
<!-- 函数start,move,end,cancel已经在new BetterGesture()时注入到了Page中,不需要在Page中再次定义-->
<view class='container'>
<view
catch:touchstart="start"
catch:touchmove="move"
catch:touchend="end"
catch:touchcancel="cancel">
</view>
</view>
// js
import BetterGesture from './../utils/better-gesture.js'
Page({
onLoad() {
new BetterGesture(this, {
//拖拽
pressMove(evt) {
console.log(evt.deltaX, evt.deltaY)
},
// 旋转
rotate(evt) {
console.log(evt.angle)
},
// 缩放
pinch(evt) {
console.log(evt.zoom)
},
// 滑动
swipe(evt) {
console.log(evt.direction)
}
//......
})
}
})
小程序代码片段: 点击查看
FAQs
A gesture library compatible with multiple terminals (native, PC, mobile, Vue, applet)
We found that better-gesture demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.