Simple, yet powerful touch-force handler
- Lightweight
- Blazing fast
- No dependecies
- Active tweening
- Compatible with any mobile/desktop browser
- Handles everything for you
- Clean code
- Performant
- Easy
- UMD compatible
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)
$ npm install forceify
# or
$ yarn add forceify
# unpkg.com
https://unpkg.com/forceify
# npmcdn
https://npmcdn.com/forceify
# jsDelivr
https://cdn.jsdelivr.net/npm/forceify
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...
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);
});
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 |
It's compatible with any ES6 supported browser
MIT