admin管理员组

文章数量:1355026

I want to check the image quality of the selected image on canvas.

My following code:

var canvas = $(".canvas-container").children('canvas').get(0);
//console.log(canvas.getActiveObject().get('type'));
console.log(canvas);

The getActiveObject() log gives an error: undefined is not a function.

The other log returns:

<canvas class="lower-canvas" width="850" height="230" style="position: absolute; width: 850px; height: 230px; left: 0px; top: 0px; -webkit-user-select: none;"></canvas>

The canvas is created in another js file:

      //create fabric stage
        var canvas = $productStage.children('canvas').get(0);

        stage = new fabric.Canvas(canvas, {
            selection: false,
            hoverCursor: 'pointer',
            rotationCursor: 'default',
            controlsAboveOverlay: true,
            centeredScaling: true
        });

What must I change so I can use so I can use canvas.getActiveObject()?

See for reference.

Thanks in advance.

I want to check the image quality of the selected image on canvas.

My following code:

var canvas = $(".canvas-container").children('canvas').get(0);
//console.log(canvas.getActiveObject().get('type'));
console.log(canvas);

The getActiveObject() log gives an error: undefined is not a function.

The other log returns:

<canvas class="lower-canvas" width="850" height="230" style="position: absolute; width: 850px; height: 230px; left: 0px; top: 0px; -webkit-user-select: none;"></canvas>

The canvas is created in another js file:

      //create fabric stage
        var canvas = $productStage.children('canvas').get(0);

        stage = new fabric.Canvas(canvas, {
            selection: false,
            hoverCursor: 'pointer',
            rotationCursor: 'default',
            controlsAboveOverlay: true,
            centeredScaling: true
        });

What must I change so I can use so I can use canvas.getActiveObject()?

See http://www.panel-it.eu/shop/straatnaambord-3/# for reference.

Thanks in advance.

Share Improve this question asked Nov 19, 2014 at 15:25 Robin RiegmanRobin Riegman 391 gold badge1 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

getActiveObject() is a method of a fabric.Canvas object.

With the above code, you would use stage.getActiveObject() instead of canvas.getActiveObject()

本文标签: javascriptCannot use getActiveObject() in FabricjsStack Overflow