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
Installing
$ npm install forceify
# or
$ yarn add forceifyCDN
# unpkg.com
https://unpkg.com/forceify
# npmcdn
https://npmcdn.com/forceify
# jsDelivr
https://cdn.jsdelivr.net/npm/forceifyNote
When device doesn't support native 3D-Touch, it's handles it via delayed call which works good, not implements 3D-Touch Dynamic Force level as it's impossible
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/Preact/Inferno
class MyApp extends Component {
componentDidMount () {
let node = this.findDOMNode(this);
Forceify.RegisterNode(node);
}
render () { <Lorem {...}><Ipsum/><Dolor/></Lorem> }
}
render(<MyApp/>, myMountTarget);Forceify.RegisterNode(yourDOMNodeReference)
// The easiest way do it
yourDOMNodeReference.addEventListener('force', function (e) {
var force = e.force;
console.log(force);
});
// or
var forceInstance = new Forceify(yourDOMNodeReference);
forceInstance.onForce(function(e){
var force = e.force;
console.log(force);
});Methods
forceInstance.on-@type Function- simplified and cross-browser(env)addEventListeneralternativeforceInstance.isTouch-@type Function- returnstrueif it's touch-device and runs on non-Chrome browserforceInstance.isChrome-@type Function- returnstrueif it's Chrome browserforceInstance.isMacOS,forceInstance.isIOS-@type Function- returnstrueif it's Apple device'sforceInstance.isMouse-@type Function- returnstrueif it's mouse-powered device
Compatibility
It's target is ES3 compatible-browsers, but it works best within following browser:
- IE9+
- Android 4+
- iOS9+
- Safari 5.1+ (iOS/OS X)
- Firefox 15+
License
MIT