[英]Move the background when drag mouse Fabric.js
I'm using Fabric.js to present a floor plan, I use a background image and use Fabric.js to add icons for electrical devices, when i drag the mouse, only the icons moving and the background wallpaper standing still, so how can i make the background move as well ? 我正在使用Fabric.js来展示平面图,我使用背景图像,并使用Fabric.js来添加用于电气设备的图标,当我拖动鼠标时,只有图标移动并且背景墙纸保持静止,因此如何我也使背景移动了吗?
var canvas = new fabric.Canvas('c');
canvas.selection = false;
var circle = new fabric.Circle({
radius: 20,
fill: 'green',
left: 100,
top: 100,
selectable: false
});
canvas.add(circle);
var panning = false;
canvas.on('mouse:up', function (e) {
panning = false;
});
canvas.on('mouse:down', function (e) {
panning = true;
});
canvas.on('mouse:move', function (e) {
if (panning && e && e.e) {
debugger;
var units = 10;
var delta = new fabric.Point(e.e.movementX, e.e.movementY);
canvas.relativePan(delta);
}
});
$(function () {
$('#zoomIn').click(function () {
canvas.setZoom(canvas.getZoom() * 1.1);
});
$('#zoomOut').click(function () {
canvas.setZoom(canvas.getZoom() / 1.1);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.