Redo Crop functionality with js fabric

Playback Steps

Working with a graphical application using Fabric js. One functionality is the ability to crop the image, and then cancel and restore the crop.

Expected Behavior

When the repeat setting is selected, the image should be cropped again.

Actual behavior

If the redial option is selected, the image is not cropped again, and the rectangle used to control cropping is cropped.

Here is the fiddle for the full code: http://jsfiddle.net/Da7SP/835/

The following is the reprocessing function code.

Can anyone suggest how to overcome this rework problem?

Thank.

var redoCrop = function() {
    if(config.redoFinishedStatus){
        if (config.canvasState.length > config.currentStateIndex &&  config.canvasState.length != 0){
            config.redoFinishedStatus = 0;
            config.redoStatus = true;
            canvas.loadFromJSON(config.canvasState[config.currentStateIndex+1], function(){
                var jsonData = JSON.parse(config.canvasState[config.currentStateIndex+1]);
                canvas.renderAll();
                config.redoStatus = false;
                config.currentStateIndex += 1;
                config.redoFinishedStatus = 1;
            });
         }
     }
 } 
+4
source share

Source: https://habr.com/ru/post/1693531/


All Articles