Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set fabric js to view only?

Tags:

fabricjs

I'm trying to display a previously saved drawing in Fabric.js, and then turn it into a view only, no editing mode. Here's what I have:

canvas1.loadFromJSON(cavasData, canvas1.renderAll.bind(canvas1));
canvas1.isDrawingMode = false;
canvas1.deactivateAll();
canvas1.selection = false;

But it isn't untouchable. Displays fine, but objects are still select-able and change-able.

like image 581
Mark Avatar asked Dec 14 '22 14:12

Mark


1 Answers

When loading from json you should disable object selection,

canvas.loadFromJSON(json, canvas.renderAll.bind(canvas), function(o, object) {
    object.set('selectable', false);
});

FIDDLE

like image 110
Khawer Zeshan Avatar answered Apr 27 '23 21:04

Khawer Zeshan