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

@miracle-web/touch-emulator

v0.0.1

Published

Miracle touch emulator

Downloads

75

Readme

Miracle Touch Emulator

在桌面端上模拟移动端 touch 事件,实现方式来自于 hammerjs/touchemulator.

具体实现

1. 环境检测:检查当前环境是否支持触摸事件。
2. Polyfill:为不支持 createTouch 和 createTouchList 的浏览器提供兼容性实现。
3. Touch 和 TouchList 构造函数:定义触摸点和触摸列表的构造函数。
4. 事件监听:监听鼠标事件(mousedown, mousemove, mouseup),并在适当的时候触发对应的触摸事件(touchstart, touchmove, touchend)。
5. 事件触发:创建并派发触摸事件,确保事件的属性与鼠标事件一致。

流程图

Install

# with npm
npm i @miracle-web/touch-emulator

# with yarn
yarn add @miracle-web/touch-emulator

# with pnpm
pnpm add @miracle-web/touch-emulator

# with Bun
bun add @miracle-web/touch-emulator

使用指南

直接在代码中引入模块即可,模块会自动完成初始化并生效

import '@miracle-web/touch-emulator';

CDN 引入

<script src="https://fastly.jsdelivr.net/npm/@miracle-web/touch-emulator"></script>

禁用 touch 模拟

在标签上添加 data-no-touch-simulate 属性后,可以使这个标签(以及它的子元素)不触发 touch 模拟事件。

<div data-no-touch-simulate />