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

touch-simulate

v0.1.1

Published

simulate touch event without browser support touch

Downloads

267

Readme

Touch-simulate

Build Status

Simulate touch event(A fake one with pageX, pageY, clientX, clientY available) even at desktop browser for testing.

You can have touches by e.touches[0] e.changedTouches[0] or e.targetTouches[0], they are the same.

Already used for testing my components like iscroll, pull-to-refresh and sweet-sortable

Features

  • Automatic emit touchmove when moving
  • Corrent e.clientX, e.clientY and many others
  • Promise based, chainaible methods
  • Confige movemoment by speed and ease function

Install

npm i touch-simulate -D

Usage

var el = document.getElementById('demo')
var TouchSimulate = require('touch-simulate')
moveable(el)

var touch = new TouchSimulate(el, {
  point: true
})

touch.start() // fire touchstart at center of element
.moveRight(150, false) // move right 150px, no touchend event
.wait(100) // wait 100ms
.moveDown(150, false)
.wait(100)
.moveLeft(150, false)
.wait(100)
.moveUp(150) // move up 150px and fire touchend

You can chain the methods, the function call would wait for previous one to be fullfilled, the chainable method list:

start moveUp moveDown moveLeft moveRight moveTo move wait

API

TouchSimulate(el, option)

Create TouchSimulate instance with element and options

  • option.speed set speed of px/s default 40
  • option.fixTarget use the real target at the point instead of el to dispatch the event
  • option.point show a transparent point at the screen, can not use with fixTarget
  • option.ease define a ease function for the movemonent, default linear

.speed(number)

Set the speed to number

.ease(string)

Set the ease function name

.start([position])

Set the touch start el and optional position(default is center) position could be t l r b for alias for top, left, right and bottom position could also be an array, which contains [x, y] for clientX and clientY This function would throw error if the movemonent not finished

.moveUp(distance, [end])

.moveDown(distance, [end])

.moveLeft(distance, [end])

.moveRight(distance, [end])

If not started, start at the center of element, or the current position Move to one direction, return promise which resolved with event of touchend If end is set to false, no touchend event is fired.

.moveTo(x, y, [end])

Insread of move direction, set move monent destination, x and y are clientX and clientY (relative to viewport, regardless of scrollbar)

.move(angel, distance, [end])

Use angel which should be (0 ~ 2*PI) instead of up down left nad right

.tap([position], [duration])

Helper to emit tap event, return promise, resolved with event of touchend

.wait(ms)

Helper to return a promise after wait for ms