我想在移动设备上使用Kineticjs以双指旋转手势旋转图像。
显示图像here。基本上就是这个:
<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>
可以使用
添加触摸事件imageObj.on('touchmove', function() {
// do something
});
如何围绕图像中心用双指触摸手势旋转图像?
答案 0 :(得分:0)
您可以将HammerJS
与KineticJS
(来自Kinetic v5.1.0)一起用于手势事件:
var startRotate = 0;
var hammertime = Hammer(image);
hammertime.on("transformstart", function(e) {
startRotate = image.rotation();
}).on("transform", function(e) {
image.rotation(startRotate + e.gesture.rotation);
layer.draw();
});