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

vue-mb-touch

v1.0.4

Published

vue-mb-touch是一个vue的移动端的事件项目,内置了点击(tap)事件,长按(press)事件

Downloads

27

Readme

vue-mb-touch

vue-mb-touch 是一个vue的移动端的事件项目,内置了点击(tap)事件,长按(press)事件

demo 后面会抽空写出来


安装

npm install vue-mb-touch

使用方法

  1. 安装
  2. 引入
  3. 在需要监听tap或者press的元素上添加 v-touch 指令 ,后面就可以 像监听 click 事件 一样 使用v-on:tap="fn"的方式监听tap和press事件了

示例


<template>
  <div  v-touch.press.tap @tap="tap" @press="press">
   
  </div>
</template>


<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import vueMobileTouch from "vue-mb-touch";

Vue.use(vueMobileTouch);

@Component
export default class Home extends Vue {
  public tap() {
    /** tap  */
  }

  public press(e: Event) {
    /** press  */
  }

  public data() {
    return {
     
    };
  }
}
</script>

开启代理模式


<template>
  <ul  v-touch.proxy @tap="tap($event)" >
    <li data-proxy data-index="1"></li>
    <li data-proxy data-index="2"></li>
    <li data-proxy data-index="3"></li>
  </ul>
</template>


<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import vueMobileTouch from "vue-mb-touch";

Vue.use(vueMobileTouch);

@Component
export default class Home extends Vue {
  public tap(e: event) {
    const currentTarget = e.currentTarget as HTMLElement;
    console.log(currentTarget.tagName.toLowerCase());   // li
    console.log(JSON.stringify(currentTarget.dataset)); // {proxy: "", index: "1"}
  }


  public data() {
    return {
     
    };
  }
}
</script>

全局配置

在引入 vue-mb-touch 时,可以传入一个全局配置对象。该对象目前支持 maxDistance 与 pressTime, maxDistance 用于手指在屏幕上移动多长距离内可触发事件默认10,pressTime 用于手机按住屏幕多长时间触发长按事件,默认650。具体操作如下:

import Vue from 'vue';
import vueMobileTouch from "vue-mb-touch";

Vue.use(vueMobileTouch, {maxDistance: 10,pressTime: 650});

指令参数

| 参数名 | 描述 | |----------|--------------| | tap | 是否开启tap事件,默认不开启,但是在tap和press都不开启时,则自动开启 | | press | 是否开启press事件,默认不开启| | stop | 是否阻止事件冒泡,默认不阻止| | prevent | 是否阻止游览器默认行为,默认不阻止| | passive | 是否为passive监听器,如果有该参数,则阻止游览器默认行为无效| | capture | 是否为捕获监听器,默认不是| | proxy | 是否开启事件代理模式,默认不开启, 开启后台 在需要触发事件的目标元素上添加 data-proxy 即可 |


注意

如果是在vue封装的组件上使用 v-touch 指令, 在监听事件时,需要加上 native 参数