野生动物园11中的SVG动画bug

时间:2017-09-20 17:01:24

标签: animation svg safari

你可能知道昨晚发布了一个新的Safari:Safari 11。 最后一个版本创建了一个关于SVG动画的bug,它在safari 10上工作正常,或者仍在chrome上工作:

我只是找不到如何解决这个问题,我尝试了一切,-webkit- subfix,容器,原产地等......

有人有想法吗?

这是直到最后一个版本的Safari工作的版本:https://jsfiddle.net/3f02je66/

.home_st0 {fill:#FFFFFF;}
.home_st1 {fill:#6CC3BD;}
.home_st2 {fill:none;stroke:#FFFFFF;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:200;stroke-dashoffset:200;}
.home_st3 {fill:none;stroke:#FFFFFF;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:20;stroke-dashoffset:20;}
.home_st4 {fill:none;stroke:#FFFFFF;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:50;stroke-dashoffset:50;}

#casserole {stroke-dasharray:200; stroke-dashoffset:200;}
#casserolePL {stroke-dasharray:20; stroke-dashoffset:20; }
#casserolePR {stroke-dasharray:20; stroke-dashoffset:20; }
#casseroleL {stroke-dasharray:50;  stroke-dashoffset:50;}
#casserole {animation: casserole .8s ease-in-out forwards .8s;}
    @keyframes casserole {
        from{stroke-dashoffset:200; }
        to {stroke-dashoffset:0;}
    }
#casserolePL {animation: casserolePL .5s ease-in-out forwards 1s;}
    @keyframes casserolePL {
        from{stroke-dashoffset:20; }
        to {stroke-dashoffset:40;}
    }
#casserolePR {animation: casserolePR .5s ease-in-out forwards 1.1s;}
    @keyframes casserolePR {
        from{stroke-dashoffset:20; }
        to {stroke-dashoffset:0;}
    }
#casseroleL {animation: casseroleL .5s ease-in-out forwards 1.2s;}
    @keyframes casseroleL {
        from{stroke-dashoffset:50; }
        to {stroke-dashoffset:100;}
    }

#aubergine {transform: translate(45%, 0%) rotate(0deg); transform-origin:center center;}
#aubergine {animation: aubergine 10s linear infinite 1.5s;}
    @keyframes aubergine {
        0%{transform: translate(45%, 0%) rotate(0deg);}
        20%,100% {transform: translate(45%, 400%) rotate(200deg);}
    }
#poisson {transform: translate(45%, 0%) rotate(0deg); transform-origin:center center;}
#poisson {animation: poisson 10s linear infinite 1.5s;}
    @keyframes poisson {
        9%{transform: translate(45%, 0%) rotate(0deg);}
        29%,100% {transform: translate(40%, 400%) rotate(-240deg);}
    }
#carotte {transform: translate(45%, 0%) rotate(0deg); transform-origin:center center;}
#carotte {animation: carotte 10s linear infinite 1.5s;}
    @keyframes carotte {
        18%{transform: translate(45%, 0%) rotate(0deg);}
        38%,100% {transform: translate(0%, 400%) rotate(-100deg);}
    }
#pois {transform: translate(-20%, 0%) rotate(0deg); transform-origin:center center;}
#pois {animation: pois 10s linear infinite 1.5s;}
    @keyframes pois {
        27%{transform: translate(45%, 0%) rotate(0deg);}
        47%,100% {transform: translate(0%, 420%) rotate(160deg);}
    }
#poulet {transform: translate(-20%, 0%) rotate(0deg); transform-origin:center center;}
#poulet {animation: poulet 10s linear infinite 1.5s;}
    @keyframes poulet {
        36%{transform: translate(-20%, 0%) rotate(0deg);}
        56%,100% {transform: translate(-20%, 400%) rotate(300deg);}
    }
#feuille {transform: translate(-50%, 0%) rotate(0deg); transform-origin:center center;}
#feuille {animation: feuille 10s linear infinite 1.5s;}
    @keyframes feuille {
        45%{transform: translate(-40%, 0%) rotate(0deg);}
        65%,100% {transform: translate(15%, 400%) rotate(60deg);}
    }
#navet {transform: translate(15%, 0%) rotate(0deg); transform-origin:center center;}
#navet {animation: navet 10s linear infinite 1.5s;}
    @keyframes navet {
        54%{transform: translate(20%, 0%) rotate(0deg);}
        74%,100% {transform: translate(-35%, 460%) rotate(360deg);}
    }
#crevette {transform: translate(-15%, 0%) rotate(0deg); transform-origin:center center;}
#crevette {animation: crevette 10s linear infinite 1.5s;}
    @keyframes crevette {
        63%{transform: translate(-15%, 0%) rotate(0deg);}
        83%,100% {transform: translate(15%, 400%) rotate(-160deg);}
    }
#oignon {transform: translate(45%, 0%) rotate(0deg); transform-origin:center center;}
#oignon {animation: oignon 10s linear infinite 1.5s;}
    @keyframes oignon {
        72%{transform: translate(45%, 0%) rotate(0deg);}
        92%,100%  {transform: translate(40%, 500%) rotate(-240deg);}
    }
#poivron {transform: translate(10%, 0%) rotate(0deg); transform-origin:center center;}
#poivron {animation: poivron 10s linear infinite 1.5s;}
    @keyframes poivron {
        81%{transform: translate(10%, 0%) rotate(0deg);}
        99%,100% {transform: translate(20%, 440%) rotate(140deg);}
    }

1 个答案:

答案 0 :(得分:10)

您正在使用translate()转化的百分比值。这提出了一个问题:什么的百分比?

Google Chrome和Safari 10使用"the bounding box of the transformed element"回答了问题。这是来自CSS Transforms定义的2013年“工作草案”

Firefox和Safari 11使用"the size of the local viewport"回答。 (在您的情况下,<svg>元素的大小)。这是来自CSS Transforms定义的最新“编辑草案”版本。

您可以尝试通过设置transform-box:fill-box来恢复以前的行为。

更好的解决方案不是使用相对值,而是使用像素值。由于您的动画元素都在25px宽度和高度的范围内,将当前值除以4并为%交换px应该为您提供一个良好的开始来微调这些值。