Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG animation bug in safari 11

As you may know there is a new Safari released last night: Safari 11. And this last version create a bug on SVG animation that was working fine on safari 10 or still work on chrome :

And I just don't find how to fix this, I tried everything, -webkit- subfix, container, origin etc … 

Can someone have an idea ?

Here is the version that was working until the last version of 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);}
    }
like image 265
Alex Avatar asked Dec 24 '22 14:12

Alex


1 Answers

You are using percentage values for translate() transformations. That raises the question: percentage of what?

Google Chrome and Safari 10 answer the question with "the bounding box of the transformed element". That is from the 2013 "Working Draft" of the CSS Transforms definition

Firefox and Safari 11 answer with "the size of the local viewport". (in your case, the size of the <svg> element). That is from the latest "Editor's Draft" version of the CSS Transforms definition.

You could try to restore the previous behavior by setting transform-box:fill-box.

The better solution is not to use relative, but pixel values. Since your animated elements are all in the range of 25px width and height, dividing the current value by 4 and exchanging % for px should give you a decent start for fine-tuning these values.

like image 53
ccprog Avatar answered Dec 31 '22 15:12

ccprog