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

@dsh-prose/event

v1.0.3

Published

js event

Downloads

20

Readme

移动端自定义事件

import Event from '@dsh-prose/event';

const event = new Event(HTMLElement, {
  onLongPressUp() {
    console.log("onLongPressUp");
  },
  onLongPress() {
    console.log("onLongPress");
  },
  onSwipeLeft(distance) {
    console.log("onSwipeLeft");
  },
  onSwipeRight(distance) {
    console.log("onSwipeRight");
  },
  onSwipeUp(distance) {
    console.log("onSwipeUp");
  },
  onSwipeDown(distance) {
    console.log("onSwipeDown");
  },
  onSwipeVertical({type, distance, origin}) {
    console.log("onSwipeVertical", type, distance, origin);
  },
  onSwipeHorizontal({type, distance, origin}) {
    console.log("onSwipeHorizontal", type, distance, origin);
  }, 
  onSwipeRound: ({ type, current, origin }) => {
    console.log("onSwipeRound", type, current, origin);
  },
  onScale(scale) {
    console.log("onScale");
  },
});

Event 事件参数

onLongPressUp (长按抬起)

(回调值: ) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | minTime | 触发最小时间 包含此值 | 700 | number | × | | maxTime | 触发最大时间 包含此值 | Infinity | number | × | | minMove | 触发最小移动距离 包含此值 | 0 | number | × | | maxMove | 触发最大移动距离 包含此值 | 4 | number | × | | preventDefault | (start)时阻止默认事件 | true | boolean | × |

onLongPress (长按)

(回调值: ) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | minTime | 触发最小时间 包含此值 | 700 | number | × | | minMove | 触发最小移动距离 包含此值 | 0 | number | × | | maxMove | 触发最大移动距离 包含此值 | 4 | number | × | | preventDefault | (start)时阻止默认事件 | true | boolean | × |

onSwipeLeft (左向滑动) | onSwipeRight (右向滑动) | onSwipeUp (上向滑动) | onSwipeDown (下向滑动)

(回调值: distance移动距离。 单位: px) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | minMove | 触发最小移动距离 包含此值 | 10 | number | × | | allowBack | 在触发滑动事件后,再往回划 distance 是否能得到负值 | false | boolean | × | | minAngle | 最小大于此角度 不包含此值 | (Left-Right-Up-Down) (135-315-225-45) | number | × | | maxAngle | 最大小于此角度 不包含此值 | (Left-Right-Up-Down) (225-45-315-135) | number | × | | preventDefault | (start)时阻止默认事件,垂直滚动时适用(Up Down) | (Up Down-Left Right) (true-false) | boolean | × | | triggerPreventDefault | (move 达到触发条件)时阻止默认事件,垂直滚动时适用(Left Right) | (Up Down-Left Right) (false-true) | boolean | × |

onSwipeVertical (竖向滑动) | onSwipeHorizontal (横向滑动)

(回调值: type触发类型, distance移动距离。 单位: px, origin触发事件的坐标) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | angles | 触发角度| vertical: [{ min: 225, max: 315 }, { min: 45, max: 135 }] horizontal: [{ min: 135, max: 225 }, { min: 315, max: 45 }] | Array<{ min: number; max: number }> | × | | preventDefault | (start)时阻止默认事件,垂直滚动时适用(vertical) | (vertical-horizontal) (true-false) | boolean | × | | triggerPreventDefault | (move 达到触发条件)时阻止默认事件,垂直滚动时适用(horizontal) | (vertical-horizontal) (false-true) | boolean | × |

onSwipeRound (滑动)

(回调值: type触发类型, current当前的坐标, origin触发事件的坐标) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | preventDefault | start 时阻止默认事件 | true | boolean | × |

onScale (双指缩放)

(回调值: scale缩放距离。 单位: px) | 参数 | 说明 | 默认值 | 类型 | 必选 | |---------|-------------------------|--------|--------|:----:| | preventDefault | start 时阻止默认事件 | true | boolean | × |

Event 解绑事件

event.destroy()