我正在使用带有手势演示的Fabric.js,注意到只有在触摸图像时,捏缩放才能起作用-我想在画布级别上允许缩放,而不仅仅是元素。
https://codepen.io/anon/pen/mzvGmV
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Fabric.js Touch Events Demo</title>
<script src="//jakedup.com/_test/fabric-js/lib/fabric_with_gestures.js"></script>
</head>
<body>
<style>
body {
margin: 0;
padding: 0;
}
</style>
<canvas id="canvas"></canvas>
<script>
var canvas = new fabric.Canvas('canvas');
fabric.Image.fromURL('http://fabricjs.com/assets/pug_small.jpg', function(img) {
img.scale(0.5).set({
left: 150,
top: 150,
angle: -15
});
canvas.add(img).setActiveObject(img);
});
var resizeCanvas = function() {
canvas.setHeight(window.innerHeight);
canvas.setWidth(window.innerWidth);
canvas.renderAll();
}
window.addEventListener('resize', resizeCanvas, false);
resizeCanvas();
</script>
</body>
</html>