Giter Site home page Giter Site logo

dalisoft / forceify Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 295 KB

Simple, yet powerful touch-force handler

Home Page: https://forceify.js.org

License: MIT License

HTML 17.31% CSS 6.25% JavaScript 76.44%
touch-devices chrome-browser javascript 3d force level handle cross-platform webapp cordova

forceify's Introduction

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

forceify's People

Contributors

dalisoft avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.