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

cordova-plugin-taptic-engine

v2.2.0

Published

Use Apple's Taptic Engine to vibrate your iPhone 6s (or up) in a variety of ways.

Downloads

3,513

Readme

Taptic Engine Cordova plugin

by Eddy Verbruggen

Try before you "buy"

The awesome Untappd app has a bunch of haptic feedback, powered by this plugin! 🍻

Supported platforms

  • Official API: iPhone 7 / 7 Plus or newer
  • Unofficial API: iPhone 6s / 6s Plus or newer
  • Requires Xcode 8 or newer to build

Installation

Latest stable version from npm:

$ cordova plugin add cordova-plugin-taptic-engine

Bleeding edge version from Github:

$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-taptic-engine

TapticEngine.js is brought in automatically. It adds a global TapticEngine object which you can use to interact with the plugin.

Usage

Check the demo code for all the tricks in the book, or read on for some copy-pasteable samples.

Make sure to wait for deviceready before using any of these functions.

Official API (requires at least iPhone 7)

It's recommended to use this API, but you're limited to iPhone 7 and higher. As per Apples guidelines there's no runtime way to determine if the device is capable of providing haptic feedback, so the success callback will always be invoked. The only check I've added is for running iOS < 10 or on the Simulator which both simply will never work, so those invoke the error callback.

Bottom line: just use these awesome features and ignore the callbacks.

The API names are modeled after what Apple has called them:

selection

Use selection feedback generators to indicate a change in selection.

TapticEngine.selection();

notification

Use notification feedback generators to indicate successes, failures, and warnings.

TapticEngine.notification({
  type: "error" // success | warning | error
});

impact

Use impact feedback generators to indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with something or snaps into place.

TapticEngine.impact({
  style: "heavy" // light | medium | heavy | rigid (iOS 13+) | soft (iOS 13+)
});

gestureSelection[start | changed | end]

The functions above are great for one-time events, not so much for gestures. Say for instance you want to tie this plugin to a range slider, then you can 'start' the selection first, invoke 'changed' upon changes in the range (there may be many during one gesture), then 'end' when the slider changes are done.

Tell the taptic engine that a gesture for a selection change is starting.

TapticEngine.gestureSelectionStart();

Tell the taptic engine that a selection changed during a gesture.

TapticEngine.gestureSelectionChanged();

Tell the taptic engine we are done with a gesture. This needs to be called lest resources are not properly recycled.

TapticEngine.gestureSelectionEnd();

Unofficial API (requires at least iPhone 6s)

BEWARE This uses an undocumented feature which may get your app rejected when reviewed by Apple. People have used this approach without problems though.

weakBoom

This triggers the same effect as the 'Peek' in 'Peek & Pop', a very brief vibration.

TapticEngine.unofficial.weakBoom(
  function() {
    // note that unsupported iOS devices like the simulator also end up here, at the moment
    console.log("Boomed weakly, if available.");
  }, function () {
    console.log("You're running on Android. Meh.");
  }
);

strongBoom

This triggers the 'Pop' effect of 'Peek & Pop', which is a bit more profound than the 'Peek' effect.

Codewise this is exactly the same as weakBoom, except for the function name of course.

burst

This triggers the 'Nope' effect you get when fi. force touching a home icon which doesn't have any action. It's a short burst of 3-ish 'weak booms'.

Codewise this is exactly the same as weakBoom and strongBoom, except for the function name of course.

Changelog

  • 2.1.0 Max Lynch added gestureSelection* methods. See the doc above why those matter!
  • 2.0.1 A crash was fixed for iPhone 7 devices (official API), thanks Max Lynch!
  • 2.0.0 Added official API for iPhone 7. Moved the old API to TapticEngine.unofficial.*. Requires Xcode 8 to build.
  • 1.0.0 Initial release, unofficial API only. Compatible with any Xcode version.