Undo-Redo feature in Fabric.js

In http://jsfiddle.net/SpgGV/9/, move the object and change its size. If the object state is changed, and then we do undo/redo, its previous state will be deleted when the next change comes. It makes it easier to do undo/redo. All events of canvas should be called before any element is added to canvas. I didn’t add … Read more

Move object within canvas boundary limit

canvas.on(‘object:moving’, function (e) { var obj = e.target; // if object is too big ignore if(obj.currentHeight > obj.canvas.height || obj.currentWidth > obj.canvas.width){ return; } obj.setCoords(); // top-left corner if(obj.getBoundingRect().top < 0 || obj.getBoundingRect().left < 0){ obj.top = Math.max(obj.top, obj.top-obj.getBoundingRect().top); obj.left = Math.max(obj.left, obj.left-obj.getBoundingRect().left); } // bot-right corner if(obj.getBoundingRect().top+obj.getBoundingRect().height > obj.canvas.height || obj.getBoundingRect().left+obj.getBoundingRect().width > obj.canvas.width){ obj.top … Read more

Interactive text fields with Fabric.js

The latest version of fabric.js includes a class IText which incorporates the interaction for editing and selection of text dynamically. try the code below with the latest version of fabric.js canvas.add(new fabric.IText(‘Tap and Type’, { fontFamily: ‘arial black’, left: 100, top: 100 , }));

Fabric.js – how to save canvas on server with custom attributes

Good question. If you’re adding custom properties to objects, those objects are likely “special” in some way. It seems like subclassing them would be a reasonable solution. For example, here’s how we would subclass a fabric.Image into a named image. Those image objects could then have names like “Gandalf” or “Samwise”. fabric.NamedImage = fabric.util.createClass(fabric.Image, { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)