V
V
Vitaliy Semyanchuk2014-06-18 11:20:15
Canvas
Vitaliy Semyanchuk, 2014-06-18 11:20:15

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 question

Ask a Question

731 491 924 answers to any question