1
我有一个应用程序,与fabricjs。它与鼠标滚轮的缩放一起工作,当我做鼠标滚轮时,我的画布保存状态,就像我做鼠标滚轮一样。防止保存状态悬停在fabricjs
我在画布上有一个状态,当我把鼠标放在一个对象上时。 当您悬停一个对象并进行放大和缩小时,画布的状态将与悬停状态一起保存。我不希望发生这种情况。我如何防止这种情况发生?
//click on the rect to see that the color red is saved in the json
//shown in the console log, but i want the original State, the red fill
canvas.on("mouse:over", function(event){
if("target" in event){
color = event.target.fill;
event.target.fill="red";
canvas.renderAll();
}
});
canvas.on("mouse:out", function(event){
if("target" in event){
event.target.fill=color;
canvas.renderAll();
}
});
var rect = new fabric.Rect({
left: 100,
top: 100,
fill: 'blue',
width: 20,
height: 20,
angle: 45
});
canvas.add(rect);
您可以查看小提琴: https://jsfiddle.net/samael205/xtcmokuy/9/
感谢,做工精细。 –
'code' var state = canvas.toObject(propiedadesAdicionales); \t \t \t state.objects.forEach(函数(邻,索引){ \t \t \t \t如果在邻( “originalColor”){ \t \t \t \t \t开关(o.type){ \t \t \t \t \t \t情况下 “线”: \t \t \t \t \t \t \t o.stroke = o.originalColor; \t \t \t \t \t \t break; \t \t \t \t \t \t案 “图像”: \t \t \t \t \t \t中断; \t \t \t \t \t \t默认: \t \t \t \t \t \t \t o.fill = o.originalColor; \t \t \t \t \t} \t \t \t \t} \t \t \t \t如果(o.type == “图像”){ \t \t \t \t \t如果(matrix.get_filter_Tint(O)){ \t \t \t如果(矩阵。)(\t \t \t if(矩阵。get_filter_Tint_color(O)== “红”){ \t \t \t \t \t \t \t matrix.applyFilterTint( “红”,0.5,O); \t \t \t \t \t \t} \t \t \t \t \t} \t \t \t \t} \t \t \t}); \t \t return JSON.stringify(state); –
ups。对不起,我不知道如何插入代码......但是,这工作正常 –