JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q23980F
  • License MIT

Simple, yet powerful touch-force handler

Package Exports

  • forceify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (forceify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Forceify

Simple, yet powerful touch-force handler

Features

  • Lightweight
  • Blazing fast
  • No dependecies
  • Active tweening
  • Compatible with any mobile/desktop browser
  • Handles everything for you
  • Clean code
  • Performant
  • Easy
  • UMD compatible

Note

When your device doesn't support 3D Touch/Force Touch, this library does not force your device work this feature, instead of library polyfills with pointer events + tweening (like Instagram post/Telegram app chat)

Installing

$ npm install forceify
# or
$ yarn add forceify

CDN

# unpkg.com
https://unpkg.com/forceify

# npmcdn
https://npmcdn.com/forceify

# jsDelivr
https://cdn.jsdelivr.net/npm/forceify

Usage

It's browser-only mode, so please use it carefully and don't use with NodeJS server-side apps. You should load script first for working snippet...

In React

For React apps, please use React wrapper for Forceify

const myElement = document.querySelector("#myElement");
const forceTouchInstance = new Forceify(myElement);
forceTouchInstance.onForce(({ force }) => {
  console.log(force);
});

Methods

Name Type Description
on Function addEventListener alternative
isIOS3DTouch Function returns support of real 3D Touch
isChrome Function returns true if Chrome browser/OS
isIOS Function returns true if iOS devices
isMouse Function returns true if it's mouse-powered device

Compatibility

It's compatible with any ES6 supported browser

License

MIT