Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

javascript - Callback function inside loadFromJSON is not working in fabric js

I've a readymade JSON object created for rendering on canvas in fabric. But, when I try to set & change values of object inside a rendered canvas then it's not taking effect. Here in code, I'm locking X & Y movements after redering but it's not applied. What can be reasons and how to resolve it?

var canvas = new fabric.Canvas('canvasLoaded');
 canvas.selection = false;
 fabric.loadFromJSON(JSON_of_Canvas, function(objects) {
    canvas.add.apply(canvas, objects);
    canvas.renderAll();

    //do the iteration here
    obj = canvas.getObjects();
    obj.forEach(function(item, i) {
       item.set('lockMovementX', false);
       item.set('lockMovementY', false);
       canvass.renderAll();
    });
 });

this is the code, i've done so far but I'm not able to figure it out that what I'm missing. To me, it seems like callback function inside loadFromJson method is not working properly. But, if there's any way to fix this issue then I'd be glad to know about it.

question from:https://stackoverflow.com/questions/65640738/callback-function-inside-loadfromjson-is-not-working-in-fabric-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...