picasso-plugin-hammer
A plugin that binds events using HammerJS.
This plugin provides an API for binding HammerJS recognizers to the chart element
in a declarative way. The documentation for the Hammer API is available here
Installation
npm install picasso-plugin-hammer
Register plugin
import picassoHammer from 'picasso-plugin-hammer';
import picasso from 'picasso.js';
picasso.use(picassoHammer);
HammerJS has to be loaded to be able to use this plugin so that the Hammer variable is available on the global namespace.
Usage
Hammer interaction settings
interactions: [{
type: 'hammer',
key: 'here',
enable: function() {
this.chart ;
return true;
},
gestures: [{
type: 'Pan',
options: {
enable: function() {
this.chart ;
},
event: 'thePan',
...
},
recognizeWith: 'otherEvent1 otherEvent2',
requireFailure: 'otherEvent',
events: {
thePanstart: function(e) {
},
thePan: function(e) {
},
thePanend: function(e) {
}
}
}]
}]
Another example
interactions: [
{
type: 'hammer',
key: 'akey',
gestures: [
{
type: 'Tap',
options: {
event: 'tripleTap',
taps: 3,
},
recognizeWith: 'doubleTap tap',
events: {
tripleTap: function (e) {
console.log('triple tapped');
},
},
},
{
type: 'Tap',
options: {
event: 'doubleTap',
taps: 2,
},
recognizeWith: 'tap',
requireFailure: 'tripleTap',
events: {
doubleTap: function (e) {
console.log('double tapped');
},
},
},
{
type: 'Tap',
options: {
taps: 1,
},
requireFailure: 'doubleTap tripleTap',
events: {
tap: function (e) {
console.log('tapped');
},
},
},
],
},
];