Answer the question
In order to leave comments, you need to log in
How to make borders (template) for canvas object?
Good afternoon.
Help with canvas and fabric.js . At first glance, it is a simple task to create objects on fabric.js and make borders (template) around them for example, put triangles at the corners. I solved this problem by adding two divs, and setting up css styles, well, it seems to me that this can be done in a different, more correct way . Let me know if anyone has come across.
Example jsfiddle.net/fix2015/BCYBZ/1
An example of how I add divs to objects is here:
obj = canvas.getActiveObject();
var btnLeft = obj.getLeft();
var btnTop = obj.getTop();
var widthadjust= obj.getWidth();
var heightadjust= obj.getHeight();
bottom = heightadjust + btnTop;
borderText = '<div class="one" style="position:absolute;top:'+btnTop+'px;left:'+btnLeft+'px;width:'+widthadjust +'px" ></div>';
btnLeft =btnLeft+5;
borderText = borderText + '<div class="two" style="position:absolute;top:'+bottom+'px;left:'+btnLeft+'px;width:'+widthadjust+'px" ></div>';
jQuery(".canvas-container").before(borderText);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question