[英]Canvg - canvas changes on mousemove
我正在使用canvg以便将一些SVG渲染到图像中。 目前,SVG画布部分工作正常。 但是,我无法确定为什么当指针进入生成的画布时会发生变化。 我是否真的必须复制生成的画布,还是我丢失了什么?
svgElement.each(function () {
var canvas = document.createElement("canvas");
//convert SVG into a XML string
var xml = (new XMLSerializer()).serializeToString(this);
// Removing the name space as IE throws an error
xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');
// Rounded svg dimensions
var width = Math.floor(svgElement.width());
var height = Math.floor(svgElement.height());
// Draw the SVG onto a canvas
canvas.width = width;
canvas.height = height;
$(canvas).css('border', '2px solid red');
canvg(canvas, xml, {
ignoreDimensions: true,
scaleWidth: width,
scaleHeight: height
});
$('body').append(canvas); // When pointer enters the canvas it changes
// I can copy the canvas and that copy won't change on pointer enter.
$(this).hide();
}
在MacOS X El Capitan下的Firefox DE 47和Chrome 49上进行了验证(我的朋友也验证了在Windows下同时在Firefox和Chrome上发生这种情况)。
您必须使用ignoreMouse
选项:
更新的小提琴: http : //jsfiddle.net/35t6fkvj/7/
canvg(canvas, xml, {
ignoreDimensions: true,
scaleWidth: width,
scaleHeight: height,
ignoreMouse: true
});
不知道为什么它认为应该添加一些鼠标事件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.