[英]Undo and redo on drawing board with Fabric.js and Fabric-brush.js
I developed a drawing board with Fabric.js and Fabric-brush.js.我用 Fabric.js 和 Fabric-brush.js 开发了一个绘图板。 While when I add undo and redo functions, they doesn't work.当我添加撤消和重做功能时,它们不起作用。 But they can work when I don't refer fabric-brush.js.但是当我不参考fabric-brush.js时它们可以工作。 So how can I make the Spray Brush function with fabric-brush.js and Undo and Redo function together?那么如何使用fabric-brush.js和撤消和重做function一起制作喷雾刷function?
Here is its Jsfiddle link: https://jsfiddle.net/Miamiaoke/x68v7kn9/4/这是它的 Jsfiddle 链接: https://jsfiddle.net/Miamiaoke/x68v7kn9/4/
Here is references: 1.https://jsfiddle.net/Fidel90/7kmf3jz2/ 2.https://codepen.io/keerotic/pen/yYXeaR这里是参考: 1.https://jsfiddle.net/Fidel90/7kmf3jz2/ 2.https://codepen.io/keerotic/pen/yYXeaR
Many thanks.非常感谢。
//undo and redo
canvas.on('object:added', function() {
if (!isRedoing) {
h = [];
}
isRedoing = false;
});
var isRedoing = false;
var h = [];
function undo() {
if (canvas._objects.length > 0) {
h.push(canvas._objects.pop());
canvas.renderAll();
}
}
function redo() {
if (h.length > 0) {
isRedoing = true;
canvas.add(h.pop());
}
}
Try this https://github.com/lyzerk/fabric-history试试这个https://github.com/lyzerk/fabric-history
Importing order进口订单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.