I want to use Kineticjs on a mobile device to rotate an image with a two finger rotation gesture.
Displaying an image is described here. Which is basically this:
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v5.0.1.min.js"></script>
<script defer="defer">
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var imageObj = new Image();
imageObj.onload = function() {
var yoda = new Kinetic.Image({
x: 200,
y: 50,
image: imageObj,
width: 106,
height: 118
});
// add the shape to the layer
layer.add(yoda);
// add the layer to the stage
stage.add(layer);
};
imageObj.src = 'http://www.html5canvastutorials.com/demos/assets/yoda.jpg';
</script>
Adding touch events can be done with
imageObj.on('touchmove', function() {
// do something
});
How can I rotate an image with a two finger touch gesture around the center of the image?
You can use
HammerJS
withKineticJS
(from Kinetic v5.1.0) for gesture events:Demo