手机 html5 hammer drag widget,javascript
I'm having trouble with the Hammer.js pinch function. The press function works wonderfully, but I'm trying to add a zoom in/zoom out function with Pinch. The app works fine without the pinch, until I add the mc.get('pinch') code. I've looked everywhere, can't find an answer. Please help :)
var myElement = document.getElementById('myCanvas');
var mc = new Hammer.Manager(myElement);
/*App does not load at all with this line of code*/
mc.get('pinch').set({ enable: true });
/****/
mc.add(new Hammer.Press({
event: 'press',
pointer: 1,
threshold: 20,
time: 10
}));
mc.add(new Hammer.Pinch({
event: 'pinch',
pointer: 2,
threshold: 10,
time: 10
}));
var diagnostics = 0;
mc.on("press", function(event)
{
x1 = event.center.x;
y1 = event.center.y;
});
mc.on("pinchout", function(event)
{
//This variable is declared.
diagnostics++;
});
mc.on("pinchin", function(event)
{
diagnostics--;
});
手机 html5 hammer drag widget,javascript - HTML5 Canvas Phonegap Hammer.js - Pinch