When I change the flip of an object, everything looks correct on the canvas, but when I serialize the canvas and serialize later, it accepts the wrong flip. Flip change method:
if(object) {
if(type === 'flip-x'){
(object.flipX ? object.set({ flipX: false }) : object.set({ flipX: true }));
}else{
(object.flipY ? object.set({ flipY: false }) : object.set({ flipY: true }));
}
}
canvas.renderAll();
After that, I clone the object in two different ways:
var clonedObj = jQuery.extend(true, {}, arr[i]);
savingOptions=['id'];
arr[i].clone(function(clonedObj){
},savingOptions);
Both works may need improvement at first, but on both, after serialization, the cloned object lost its flipX and flipY, regardless of what I do. The serialization I'm doing is:
var data=JSON.stringify(canvas.toObject(savingOptions));
canvas.loadFromJSON(data,function(){
canvas.renderAll();
});
I also check object.originalState, and all this is normal.
source
share