简体   繁体   English

Firefox中svg.js“ animate()。move()”的奇怪行为

[英]Odd behaviour of svg.js “animate().move()” in Firefox

I am using svg.js ( Website ) to animate a polygon inside a mask. 我正在使用svg.js( 网站 )为蒙版内的多边形设置动画。 This works perfectly in Chrome and IE However if I try it in Firefox the animation is broken. 这在Chrome和IE中完美运行,但是,如果我在Firefox中尝试,动画将被破坏。

Please have a look at this jsfiddle . 请看看这个jsfiddle

HTML: HTML:

<div id="drawing"></div>

JS: JS:

var draw = SVG('drawing');
var rect = draw.rect(1000, 300).fill({ color: '#fff' });
var polygon = draw.polygon('100,260 50,300 150,300').fill('#000');
var mask = draw.mask().add(rect).add(polygon);

var bgrect = draw.rect(1000, 300).fill({ color: '#ff0000' });
bgrect.maskWith(mask);
polygon.animate().move(500,260);

In Chrome and IE the triangle moves 500px along the x-axis, which is what I want. 在Chrome和IE中,三角形沿x轴移动了500px,这正是我想要的。 In Firefox, however, it jumps to the upper left corner und animates downwards to its initial position. 但是,在Firefox中,它会跳到左上角,然后向下动画到其初始位置。

Is there a way to make the animation work in Firefox, too? 也有办法使动画在Firefox中工作吗? I'm testing in FF 32.0.1 btw. 我正在以FF 32.0.1 btw测试。

This bug is fixed in the latest commit ( https://github.com/wout/svg.js/commit/8617a6b5d5ff147718051a7fc582c54f603aa90f ). 此错误已在最新提交( https://github.com/wout/svg.js/commit/8617a6b5d5ff147718051a7fc582c54f603aa90f )中修复。

Firefox wont calculate a bounding box of elements which are hidden. Firefox不会计算隐藏元素的边界框。 Since everything in the defs is hidden by definition, Firefox fails when it comes to bbox calculation. 由于defs中的所有内容均按定义隐藏,因此Firefox在进行bbox计算时会失败。 However this has been worked around in the named commit. 但是,这已在命名提交中解决。

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

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