anam
anam

Reputation: 3913

Make canvas clip area dragable

is there a way to make canvas drag-able after clipping ? i want to drag triangle part which is created for clipping.

canvas.clipTo = function(ctx) {
    var shp = new fabric.Triangle({
                left : 90,
                top : 120,
                width : 80,
                height : 60,
                stroke : 'white',
                strokeWidth : 1
            });
    shp.render(ctx);

};

i am dragging canvas area to triangle now wants to make it draggable?

Upvotes: 0

Views: 140

Answers (1)

nkorth
nkorth

Reputation: 1694

You'll probably have to write the dragging code yourself (unless Fabric has a means to do this). Basically, do something like this pseudocode:

var lastPosition
when (mouse moved) and (mouse button is down):
    if lastPosition is defined:
        move draggable object by (mousePosition - lastPosition)
    lastPosition = mousePosition

Upvotes: 1

Related Questions