Animating an arc in Raphael JS wobbles in Chrome

血红的双手。 提交于 2019-12-01 08:02:15

问题


I am seeing an annoying wobble in my animation, I have stripped out the code which contains the actual animation:

var side = 400;
var paper = new Raphael($(this), 100, side);

paper.customAttributes.arc = function (xloc, yloc, value, total, R) {


                var alpha = 360 / total * value,
                    a = (90 - alpha) * Math.PI / 180,
                    x = xloc + R * Math.cos(a),
                    y = yloc - R * Math.sin(a),
                    path;
                if (total == value) {
                    path = [
                        ["M", xloc, yloc - R],
                        ["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
                    ];
                } else {
                    path = [
                        ["M", xloc, yloc - R],
                        ["A", R, R, 0, +(alpha > 180), 1, x, y]
                    ];
                }
                return {
                    path: path
                };
            };

            var arcWidth = 180 - 120;
            var strokeRadius = (120 + arcWidth/2);

            var indicatorArc = paper.path().attr({
                "stroke": "#4B6384",
                "stroke-width": 100,
                arc: [side/2, side/2, 0, 100, strokeRadius]
            });

            indicatorArc.animate({
                arc: [side/2, side/2, 75, 100, strokeRadius]
            }, 1500, "<>", function(){
                // anim complete here
            });

I have put it in a jsfiddle for you to see for yourself, please check in firefox and chrome, you will notice in chrome the edges wobble substantially, is there anything I can do to eliminate this?

fiddle here: run many times


回答1:


So I know this is over two years old now, but if anyone comes across this issue, it's a known bug within Chrome's 2D drawing engine.

https://code.google.com/p/skia/issues/detail?id=2769



来源:https://stackoverflow.com/questions/9361476/animating-an-arc-in-raphael-js-wobbles-in-chrome

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!