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

ghosture

v0.2.0

Published

Simulate touch gestures in your unit tests.

Downloads

4

Readme

ghosture.js

Simulate and automate touch gestures in your user interface unit tests. Designed to be used especially with PhantomJS.

Install

npm install ghosture

Usage

// "swipe left"
ghosture.start(200, 50)
  .moveTo(100, 50, '500ms')
  .end()
  .run();

// "tap"
ghosture.start(50, 50)
  .hold('50ms')
  .end()
  .run();

// execute functions between
ghosture.start(50, 50)
  .then(function () { console.log('started'); })
  .moveBy(50, 50)
  .then(function () { console.log('moved to (100, 100)'); })

API

ghosture

ghosture.start(x, y)

Creates and initiates a new Gesture instance. Does not emit a touchstart event until run() is called.

var g = ghosture.start(100, 20);

ghosture.endTouches()

End all ongoing ghosture-created touches.

ghosture.numTouches()

Number of ongoing ghosture-created touches.

Gesture

g.cancel()

Cancel the gesture by emitting a touchcancel. The gesture cannot be restarted.

g.end()

End the gesture by emitting a touchend. The gesture cannot be restarted.

g.hold(duration)

Keep the gesture still. Duration is a CSS time string, such as '0.5s' or '500ms'.

g.moveBy(dx, dy, [duration='50ms'], [easing='linear'])

Move the gesture in a relative manner. For available easing functions, see component/ease.

g.moveTo(x, y, [duration='50ms'], [easing='linear'])

Move the gesture to absolute clientX and clientY coordinates.

g.run([fn])

Run the gesture and execute optional fn function when finished.

g.then(fn)

Execute an arbitrary fn function during the gesture.

Future plans

Logo

Example apps

Premade gestures (Not yet implemented)

var tap = ghosture.tap(100, 200);
tap.run();
ghosture.doubletap(100, 50).run();
ghosture.tripletap(100, 50).run();
ghosture.doubletap({
  x: 100,
  y: 50,
  interval: 10 // default
}).run();

Multitouch gestures (Not yet implemented)

ghosture.transform({
  pointers: 2,
  centerXStart: 100,
  centerYStart: 50,
  duration: 500,
  ease: 'in-out',
  centerXEnd: 200,
  centerYEnd: 60,
  radiusStart: 50,
  radiusEnd: 100,
  angleStartDeg: 0,
  angleEndRad: 0
}).run();

Recording (Not yet implemented)

Train your ghost fingers by tracking a real touch gesture.

ghosture.recordNext()
  .save(function (recordedData) {
    alert(recordedData);
  });

Records the gesture from the touchstart of the first finger touching the document to the touchend of the last finger leaving the document.

The default element to track is document.body. You can track specific element by .recordNext(myElement).

Replay (Not yet implemented)

Play the recorded gesture in your unit tests by:

var gesture = "ghosture,v1;0,1,s,730,343;100,1,m,733,342;";
ghosture(gesture).end();

or

ghosture.start(gesture).end();

Format (Not yet implemented)

Example of two events:

"ghosture,v1;0,1,s,730,343;100,1,m,733,342;"

The format in the Backus-Naur notation for geeks:

<engine>          ::= <string>
<version>         ::= "v" + <positive integer>
<format-id>       ::= <engine> + "," + <version>

<elapsed-time-ms> ::= <positive integer>
<pointer-id>      ::= <positive integer>
<pointer-start>   ::= "s"
<pointer-move>    ::= "m"
<pointer-end>     ::= "e"
<pointer-cancel>  ::= "c"
<event-type>      ::= <pointer-start> | <pointer-move> |
                      <pointer-end> | <pointer-cancel>
<x>               ::= <positive integer>
<y>               ::= <positive integer>
<event>           ::= <elapsed-time-ms> + "," + <pointer-id> + "," +
                      <event-type> + "," + <x> + "," + <y>
<event-sequence>  ::= "" | <event-sequence> + <event> + ";"

<gesture>         ::= <format-id> + ";" + <event-sequence>

Additional constraints:

  • Events must be ordered by time i.e. in ascending order by elapsed-time-ms.

Versioning

Semantic Versioning 2.0.0

License

MIT License