简体   繁体   English

使用Fabric JS的画布中的新图像不适用于Chrome

[英]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! 我使用fabric.js来管理画布,但是当我制作新的fabric.Image在画布中放了图片后,它在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 ? 此代码适用于Firefox,该怎么办?

Thanks! 谢谢!

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 这是更新的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM