无法在 canvas (fabric.js) 中查看剪辑区域外的选择器控件
can not view selector controls outside the clipping area in canvas (fabric.js)
我使用下面的代码使用 fabric.js 插件
剪辑 canvas 的区域
//set it as a canvas fix parent element
var shape = canvas.item(0);
canvas.remove(shape);
canvas.clipTo = function(ctx) {
shape.render(ctx);
};
canvas.renderAll();
但是如果我将元素拖到裁剪区域之外,控件就会变得不可见。即使我们将元素拖到外面,也需要该控件在整个 canvas 中可见。
只需在 clipTo 函数后使用 canvas.controlsAboveOverlay = true;
。它不仅适用于叠加图像,还适用于裁剪对象。
我使用下面的代码使用 fabric.js 插件
剪辑 canvas 的区域//set it as a canvas fix parent element
var shape = canvas.item(0);
canvas.remove(shape);
canvas.clipTo = function(ctx) {
shape.render(ctx);
};
canvas.renderAll();
但是如果我将元素拖到裁剪区域之外,控件就会变得不可见。即使我们将元素拖到外面,也需要该控件在整个 canvas 中可见。
只需在 clipTo 函数后使用 canvas.controlsAboveOverlay = true;
。它不仅适用于叠加图像,还适用于裁剪对象。