npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-touch-gesture

v1.0.1

Published

A touch gesture plugin for Vue 3 using Hammer.js.

Downloads

5

Readme

vue3-touch-gesture

vue3-touch-gesture 是一个基于 Hammer.jsVue 3 的触控手势插件,支持多种手指触控操作,如平移、缩放、滑动等。该插件易于集成并提供了灵活的配置选项。

特性

  • 支持多种手势事件:pinch, pan, swipe, rotate, tap 等。
  • 可配置的手势选项和方向。
  • 简单易用,支持自定义手势注册。

安装

使用 npm 安装:

npm install vue3-touch-gesture

或者使用 yarn:

yarn add vue3-touch-gesture

快速开始

  • 在你的 Vue 项目中引入并注册插件:
import { createApp } from 'vue'
import App from './App.vue'
import vue3Touch from 'vue3-touch-gesture'

const app = createApp(App)
app.use(vue3Touch, { name: 'v-touch' })
app.mount('#app')
  • 在组件中使用 v-touch 组件,并监听手势事件:
<template>
	<v-touch @pinchout="onPinchOut" @pinchin="onPinchIn" :pinch-options="{ threshold: 0.1 }">
		<div class="content">
			<p>尝试使用双指缩放手势!</p>
		</div>
	</v-touch>
</template>

<script>
	export default {
		data() {
			return {
				scale: 1,
			}
		},
		methods: {
			onPinchOut() {
				this.scale += 0.1
			},
			onPinchIn() {
				this.scale = Math.max(this.scale - 0.1, 1)
			},
		},
	}
</script>

<style scoped>
	.content {
		transform: scale(var(--scale));
	}
</style>

支持的手势

  • Pan 手势:@panstart, @panmove, @panend, @pancancel 等。
  • Pinch 手势:@pinch, @pinchout, @pinchin, @pinchstart, @pinchend 等。
  • Swipe 手势:@swipeleft, @swiperight, @swipeup, @swipedown 等。
  • Rotate 手势:@rotate, @rotatestart, @rotateend, @rotatecancel 等。
  • Tap 手势:@tap, @press, @pressup 等。

配置选项

所有手势都可以通过选项进行配置。以下是 pinch 手势的配置示例:

<v-touch :pinch-options="{ threshold: 0.1 }">
	<div>Pinch 手势</div>
</v-touch>

可以传递的选项包括:

  • threshold: 手势的触发阈值。
  • direction:手势的方向,支持 up, down, left, right, horizontal, vertical, all 等。