rem
rem

Reputation: 161

new image in canvas with fabric js doesn't work for chrome

I use fabric.js to manage my canvas, however when I make new fabric.Image after dropped a picture in my canvas it's doesn't work in chrome!

there is my code :

var imgElement = document.getElementById(idImageToDrage);

var imgInstance = new fabric.Image(imgElement, {
    id: parseInt(idImageToDrage),
    left: calculPositionLeft, // position when I drop the picture
    top: calculPositionTop,
    scaleX: 0.147,
    scaleY: 0.147,
    angle: 0,
    zindex: $('#containerInnerImgToDrag').children().length,
    name: 'img'
});

imgInstance.setControlsVisibility({ 'bl': false, 'br': false, 'mb': false, 'ml': false, 'mr': false, 'mt': false, 'tl': false, 'tr': false });
canvas.add(imgInstance);

This code work for Firefox, what can I do ?

Thanks!

Upvotes: 0

Views: 345

Answers (1)

Durga
Durga

Reputation: 15604

You need to use

var objectDropped = ui.draggable[0];

var imgInstance = new fabric.Image(objectDropped, {

Dropped image element as source for fabric image.

Here is updated fiddle

Upvotes: 1

Related Questions