How to sync my animateMotion with my CSS animation? - css
I did not expect that, the goal would be to have the square make the path disappear. Both of my animation have a duration of 5s but they do not tie in.
I am new to svg animation so I did not find the solution to make it yet.
Any idea how I can make it ?
// Example class component
class Svg extends React.Component {
render() {
return (
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500">
<path className="path" id="motionPath" d="M404.88 470.22V79.69c-.2-19-14.21-33-17.52-36.19s-16.77-15.19-34.7-15.45h-1.11c-28.65.35-59.55-.12-319.52 0H28" stroke="#000" strokeWidth="4" stroke-miterlimit="10" fill="none"></path>
<rect id="circle" x="-25" y="-25" rx="15" ry="15" width="50" height="50"></rect>
<animateMotion id="forward"
xlinkHref="#circle"
dur="5s"
fill="freeze"
keyPoints="1;0"
keyTimes="0;1"
calcMode="linear">
<mpath xlinkHref="#motionPath"></mpath>
</animateMotion>
</svg>
</div>
);
}
}
// Render it
ReactDOM.render(
<Svg />,
document.getElementById("react")
);
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear reverse;
}
#keyframes dash {
to {
stroke-dashoffset: 0;
}
}
<div id="react"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
instead of using one SMIL and one CSS animations do both SMIL.
Also you are animating for a path length of 1000 when the path length is 795.3
Yet another idea: you need to reverse the css animation because your initial stroke-dashoffset: 1000; Use an initial value of 0 and animate it to maxim length (795.3 - in my demo), Now you don't need to reverse it anymore,
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500">
<path class="path" id="motionPath" d="M404.88,470.22v-390.53c-0.2,-19,-14.21,-33,-17.52,-36.19s-16.77,-15.19,-34.7,-15.45h-1.11c-28.65,0.35,-59.55,-0.12,-319.52,0h-4.03" stroke="#000" stroke-width="4" stroke-miterlimit="10" fill="none" stroke-dasharray="795.30" stroke-dashoffset="0">
<animate
attributeName="stroke-dashoffset"
from="0" to="795.30"
dur="5s"
fill="freeze"
begin="0"/>
</path>
<rect id="circle" x="-25" y="-25" rx="15" ry="15" width="50" height="50">
<animateMotion id="forward"
dur="5s"
fill="freeze"
keyPoints="1;0"
keyTimes="0;1"
calcMode="linear"
begin="0">
<mpath xlink:href="#motionPath"></mpath>
</animateMotion>
</rect>
</svg>
// Example class component
class Svg extends React.Component {
render() {
return (
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500">
<path className="path" id="motionPath" d="M404.88 470.22V79.69c-.2-19-14.21-33-17.52-36.19s-16.77-15.19-34.7-15.45h-1.11c-28.65.35-59.55-.12-319.52 0H28" stroke="#000" strokeWidth="4" stroke-miterlimit="10" fill="none"></path>
<rect id="circle" x="-25" y="-25" rx="15" ry="15" width="50" height="50"></rect>
<animateMotion id="forward"
xlinkHref="#circle"
dur="5s"
fill="freeze"
keyPoints="1;0"
keyTimes="0;1"
calcMode="linear">
<mpath xlinkHref="#motionPath"></mpath>
</animateMotion>
</svg>
</div>
);
}
}
// Render it
ReactDOM.render(
<Svg />,
document.getElementById("react")
);
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear reverse;
}
#keyframes dash {
to {
stroke-dashoffset: 200;
}
}
<div id="react"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
I can't problem but you can use 200ms on your dash animation stroke-dashoffset. That will help you to fix the problem. And I will try to find where is the issue.
Related
Animating feComposite SVG filter elements
I have two svg shapes, one on top of the other, and I've applied the feComposite filter on both so that the top shape knocks out part of the bottom shape. The code is as follows and works fine. <svg width="100" height="100"> <defs> <filter id="myfilter"> <feImage xlink:href="#layer1" result="lay1"/> <feImage xlink:href="#layer2" result="lay2"/> <feComposite operator="out" in="lay1" in2="lay2"/> </filter> </defs> <g filter="url(#myfilter)"> <circle id="layer1" cx="50" cy="50" r="40" stroke- width="0" fill="green" /> <circle id="layer2" class="small" cx="20" cy="60" r="20" stroke- width="0" fill="red" /> </g> </svg> Now I want to animate the top shape, but when I tried to apply the animation, both shapes animates and I can't figure out why because I've only targeted the second shape with class="small". Here is the css code for the animation. #keyframes rock { 0% { transform: rotate(45deg); } 50% { transform: rotate(0deg); } 100% { transform: rotate(-45deg); } } .small { animation-name: rock; animation-duration: 5s; animation-iteration-count: infinite; animation-timing-function: linear; } I am puzzled by this behavior and hope someone can shed some light to this problem. Is it not possible to animate the svg elements individually when filters are applied to them as a group? But that doesn't seem to make sense because the svg elements can be targeted individually. Here is a link to codepen: https://codepen.io/lanlanonearth/pen/bGbRyVo
Please try this: You put both circles in the <defs> and you <use xlink:href="#layer1". Next you apply the filter to the <use> element. <svg width="100" height="100"> <defs> <circle id="layer1" cx="50" cy="50" r="40" stroke-width="0" fill="green" /> <circle id="layer2" class="small" cx="20" cy="60" r="20" stroke-width="0" fill="red" /> <filter id="myfilter"> <feImage xlink:href="#layer1" result="lay1"/> <feImage xlink:href="#layer2" result="lay2"/> <feComposite operator="out" in="lay1" in2="lay2"/> </filter> </defs> <use xlink:href="#layer1" filter="url(#myfilter)"></use> </svg> Check it on codepen
svg fill animation does not work in firefox
Does anybody know why this code doesnt work in FF ? In chrome everything is ok but not in FF. The dots dont fill with the white color, just stay unfilled. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129.57 26.18"> <defs> <style>.cls-1{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:2px;}</style> </defs> <title>kropeczki</title> <g id="Warstwa_2" data-name="Warstwa 2"> <g id="Layer_1" data-name="Layer 1"> <circle class="cls-1" cx="13.09" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="0.7" dur=".1s" fill="freeze" repeatCount="1"/> </circle> <circle class="cls-1" cx="64.79" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="1" dur=".1s" fill="freeze" repeatCount="1"/> </circle> <circle class="cls-1" cx="116.49" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="1.3" dur=".1s" fill="freeze" repeatCount="1"/> </circle> </g> </g> </svg>
Considering that SMIL doesn't work cross browser, may I suggest you use CSS animation instead Animate the color none won't work, use transparent body { background: gray; } .cls-1 { fill: transparent; stroke: #fff; stroke-miterlimit: 10; stroke-width: 2px; -webkit-animation-name: setcolor; -webkit-animation-duration: 2s; -webkit-animation-fill-mode: forwards; animation-name: setcolor; animation-duration: 2s; animation-fill-mode: forwards; } .cls-1:nth-child(2) { -webkit-animation-delay: .5s; animation-delay: .5s; } .cls-1:nth-child(3) { -webkit-animation-delay: 1s; animation-delay: 1s; } #keyframes setcolor { 100% { fill: white; } } #-webkit-keyframes setcolor { 100% { fill: white; } } <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129.57 26.18"> <title>kropeczki</title> <g id="Warstwa_2" data-name="Warstwa 2"> <g id="Layer_1" data-name="Layer 1"> <circle class="cls-1" cx="13.09" cy="13.09" r="12.09"> </circle> <circle class="cls-1" cx="64.79" cy="13.09" r="12.09"> </circle> <circle class="cls-1" cx="116.49" cy="13.09" r="12.09"> </circle> </g> </g> </svg> Note, since Chrome favor CSS/Web animations over SMIL, the future of SMIL might be somewhat unpredictable, so I would recommend to wait using it until its future is more secured.
According to the SVG and SMIL specifications durations are not allowed to start with a full stop. Adding a leading 0 as the specification demands so that .7 becomes 0.7 fixes things in Firefox. I've also added a background rect as white on white does not show up too well in a snippet. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 129.57 26.18"> <defs> <style>.cls-1{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:2px;}</style> </defs> <title>kropeczki</title> <g id="Warstwa_2" data-name="Warstwa 2"> <rect width="100%" height="100%" fill="black"/> <g id="Layer_1" data-name="Layer 1"> <circle class="cls-1" cx="13.09" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="0.7" dur="0.1s" fill="freeze" repeatCount="1"/> </circle> <circle class="cls-1" cx="64.79" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="1" dur="0.1s" fill="freeze" repeatCount="1"/> </circle> <circle class="cls-1" cx="116.49" cy="13.09" r="12.09"> <animate attributeName="fill" from="none" to="#fff" begin="1.3" dur="0.1s" fill="freeze" repeatCount="1"/> </circle> </g> </g> </svg>
SMIL to CSS Animation: multiple animations on single element
Now that SMIL is dying I want to convert my simple animated SVGs to using CSS Animations, but I am not super sure how to do the mapping. In this specific svg there are two animation elements. #embedded { color: red; } <svg id="embedded" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> <circle cx="50" cy="50" r="45" stroke="rgba(43,43,43,0.3)" fill="none" stroke-width="10" stroke-linecap="round"/> <circle cx="50" cy="50" r="45" stroke="currentColor" fill="none" stroke-width="6" stroke-linecap="round"> <animate attributeName="stroke-dashoffset" dur="2s" repeatCount="indefinite" from="0" to="502"/> <animate attributeName="stroke-dasharray" dur="2s" repeatCount="indefinite" values="150.6 100.4;1 250;150.6 100.4"/> </circle> </svg> While I seemingly started out fine with these css rules I quickly got stuck stroke-dasharray: 150.6 100.4 1 250 150.6 100.4; animation-duration: 2s; animation-iteration-count: infinite; stroke-dashoffset: ?; What would a complete mapping be like? Is it possible at all? Sara Soueidan says not all animations are possible using CSS that are possible using SMIL.
The below is how you'd convert that SMIL animation into its equivalent CSS animation: Both your animate tags have the dur="2s" and so the CSS animation's duration (animation-duration) would also be 2s. You can either specify this value using the long-hand property or using the short-hand property like in the below snippet. There is no calcMode attribute specified for your animate element and so the interpolation mode is linear. Since the interpolation mode is linear, the animation-timing-function will also be linear. The repeatCount is indefinite and so the animation-iteration-count will be infinite. For the stroke-dashoffset, the animation has only a from (0%) and a to (100%) value. So, in the CSS animation's keyframes, we specify the stroke-dashoffset as 0 (from value) at 0% and as 502 (to value) at 100%. For the stroke-dasharray, the animation makes use of values instead of just from and to. In this case, there are three semi-colon separated values and so the first value from the list is given within the 0% keyframe , the second value from the list is given at 50% keyframe and the last is given within the 100% keyframe selector. #embedded, #embedded2 { color: red; width: 200px; height: 200px; } #embedded circle#animated { animation: demo 2s infinite linear; } #keyframes demo { 0% { stroke-dashoffset: 0; stroke-dasharray: 150.6 100.4; } 50% { stroke-dasharray: 1 250; } 100% { stroke-dashoffset: 502; stroke-dasharray: 150.6 100.4; } } <svg id="embedded" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> <circle cx="50" cy="50" r="45" stroke="rgba(43,43,43,0.3)" fill="none" stroke-width="10" stroke-linecap="round" /> <circle cx="50" cy="50" r="45" stroke="currentColor" fill="none" stroke-width="6" stroke-linecap="round" id="animated"> </circle> </svg> <svg id="embedded2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> <circle cx="50" cy="50" r="45" stroke="rgba(43,43,43,0.3)" fill="none" stroke-width="10" stroke-linecap="round" /> <circle cx="50" cy="50" r="45" stroke="currentColor" fill="none" stroke-width="6" stroke-linecap="round"> <animate attributeName="stroke-dashoffset" dur="2s" repeatCount="indefinite" from="0" to="502" /> <animate attributeName="stroke-dasharray" dur="2s" repeatCount="indefinite" values="150.6 100.4;1 250;150.6 100.4" /> </circle> </svg>
Animating an SVG Group
I currently have the following SVG: <svg class="tower owner" height="60" width="60" viewBox="0 0 300 300"> <g transform="translate(75 75)" opacity="1"> <ellipse class="border" cx="0" cy="0" fill="#222" rx="65" ry="65" stroke-width="5"></ellipse> <g class="rotatable" style="transform: rotate(5.497787143782138rad); transition: transform 2s;"> <rect fill="#aaa" height="50" stroke-width="7" stroke="#181818" width="40" x="-20" y="-80"></rect> <rect fill="#555" height="58" rx="12" ry="10" width="78" x="-39" y="-25"></rect> <rect fill="#ffe56d" height="46.4" y="-13.399999999999999" rx="12" ry="12" width="78" x="-39"></rect> </g> </g> </svg> I am currently animating a rotation on g.rotatable however I would like to use <animateTransform> if possible, and I haven't figured out how. I have tried placing it at the start of the group, at the bottom of it, and even after it, however none have any affect. <animateTransform attributeName="transform" attributeType="XML" dur="5s" keyTimes="0;0.4;0.75;1" repeatCount="indefinite" type="rotate" values="315deg;90deg;200deg;315deg" calcMode="linear"></animateTransform> Since I've never really worked with SVGs or animating them, I'm not sure where I'm going wrong. svg.tower .rotatable { animation: tower 5s linear infinite; } #keyframes tower { 0% { transform: rotate(315deg); } 40% { transform: rotate(90deg); } 75% { transform: rotate(200deg); } 100% { transform: rotate(315deg); } } Above is my current CSS animation. Can anyone tell me where I'm going wrong, so I can fix my mistakes, or if it's even possible, so I can potentially give up this line of action.
Note: You may want to reconsider using SMIL animations instead of CSS animations because Chrome has deprecated support for SMIL animations from v45. There were two problems in your code and they are as follows: The rotate transform in SVG just takes the degree number as value and doesn't need the deg suffix to be added to it. In addition a transform origin can also be specified (2nd and 3rd param) but it is not mandatory. There was a style='transform: rotate(...)' on the .rotatable element. The CSS overrides the animateTransform and so you don't get to see any rotation. Avoid this stylesetting. If there is a need for an initial rotation you could probably use SVG's transform attribute. Below is a working demo: <svg class="tower owner" height="60" width="60" viewBox="0 0 300 300"> <g transform="translate(75 75)" opacity="1"> <ellipse class="border" cx="0" cy="0" fill="#222" rx="65" ry="65" stroke-width="5"></ellipse> <g class="rotatable" transform="rotate(315)"> <rect fill="#aaa" height="50" stroke-width="7" stroke="#181818" width="40" x="-20" y="-80"></rect> <rect fill="#555" height="58" rx="12" ry="10" width="78" x="-39" y="-25"></rect> <rect fill="#ffe56d" height="46.4" y="-13.399999999999999" rx="12" ry="12" width="78" x="-39"></rect> <animateTransform attributeName="transform" attributeType="XML" dur="5s" keyTimes="0;0.4;0.75;1" repeatCount="indefinite" type="rotate" values="315;90;200;315" calcMode="linear"></animateTransform> </g> </g> </svg>
SVG animatetransform rotation, not working perfectly on ie and firefox
I'm trying to animate a simple svg image using I've got 4 petals (polygonal shapes), a Circle , and a rectangle. I want to rotate the petals around the circle, My code is as follows <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 700 700" style="enable-background:new 0 0 700 700;" xml:space="preserve"> <style type="text/css"> .st0 { fill: #A9A9AD; } .st1 { fill: #FEF058; } #Circleelement { transform-origin: center; -webkit-animation-name: rotate; -webkit-animation-duration: 5s; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-name: rotate; -moz-animation-duration: 5s; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; animation-name: rotate; animation-duration: 5s; animation-iteration-count: infinite; animation-timing-function: linear; } #-webkit-keyframes rotate { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } #-moz-keyframes rotate { from { -moz-transform: rotate(0deg); } to { -moz-transform: rotate(360deg); } } #keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } </style> <g id="Circleelement" transform="translate(150 170) rotate(45) translate(-150 -170)"> <g id="petals"> <g id="petal4" onclick="notify(this,"select");"> <path class="st0" d="M241.9,177.4l-69.4,68c-3.1,3-8.1,3-11.1-0.1l-20.8-21.2c-3-3.1-3-8.1,0.1-11.1l69.4-68c3.1-3,8.1-3,11.1,0.1 l20.8,21.2C245,169.4,245,174.4,241.9,177.4z" /> <polygon class="st0" points="138.8,221.4 132.8,195.3 191.3,136.6 218.4,143.4 " /> </g> <g id="petal3" onclick="notify(this,"select");"> <path class="st0" d="M174.3,259.4l68,69.4c3,3.1,3,8.1-0.1,11.1L221,360.6c-3.1,3-8.1,3-11.1-0.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1 l21.3-20.8C166.3,256.1,171.3,256.3,174.3,259.4z" /> <polygon class="st0" points="218.1,362.4 192.1,368.4 133.5,309.9 140.1,282.9 " /> </g> <g id="petal2" onclick="notify(this,"select");"> <path class="st0" d="M256.1,326.9l69.4-68c3.1-3,8.1-3,11.1,0.1l20.8,21.3c3,3.1,3,8.1-0.1,11.1l-69.4,68c-3.1,3-8.1,3-11.1-0.1 L256,338C253,334.9,253.1,329.9,256.1,326.9z" /> <polygon class="st0" points="359.3,282.9 365.3,309.1 306.8,367.8 279.6,361.1 " /> </g> <g id="petal1" onclick="notify(this,"select");"> <path class="st0" d="M323.8,245.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1l21.3-20.8c3.1-3,8.1-3,11.1,0.1l68,69.4c3,3.1,3,8.1-0.1,11.1 l-21.3,20.8C331.8,248.3,326.8,248.1,323.8,245.1z" /> <polygon class="st0" points="279.8,141.9 306,135.9 364.6,194.4 357.9,221.6 " /> </g> </g> <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0" to="360" begin="0" dur="5s" repeatCount="indefinite" /> </g> <circle class="st1" cx="250.4" cy="250.6" r="47.9" /> <rect id="stem" x="244" y="339" class="st0" width="12" height="385" /> </svg> Result on various browsers are:- The animation works perfectly on google chrome. Elements are dislocated and Animation is partial on Firefox and safari. Image is dislocated in IE. I've to use this svg animation in a website. Please Help me resolve this issue. Thanks in advance
Currently what Chrome does is wong per the w3c specifications. The version below works on Firefox and might work on Chrome if they changed to match the spec. Alternatively the spec might change to match Chrome in which case Firefox would likely change to match Chrome and the specification. Life is tough as the bleeding edge of specification and UA development. <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 700 700" style="enable-background:new 0 0 700 700;" xml:space="preserve"> <style type="text/css"> .st0 { fill: #A9A9AD; } .st1 { fill: #FEF058; } #Circleelement { transform-origin: center; -webkit-animation-name: rotate; -webkit-animation-duration: 5s; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-name: rotate; -moz-animation-duration: 5s; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; animation-name: rotate; animation-duration: 5s; animation-iteration-count: infinite; animation-timing-function: linear; } #-webkit-keyframes rotate { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } #-moz-keyframes rotate { from { -moz-transform: rotate(0deg); } to { -moz-transform: rotate(360deg); } } #keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } </style> <g transform="translate(-100, -100)"> <svg id="Circleelement" x="100" y="100" width="400" height="400"> <g id="petals"> <g id="petal4" onclick="notify(this,"select");"> <path class="st0" d="M241.9,177.4l-69.4,68c-3.1,3-8.1,3-11.1-0.1l-20.8-21.2c-3-3.1-3-8.1,0.1-11.1l69.4-68c3.1-3,8.1-3,11.1,0.1 l20.8,21.2C245,169.4,245,174.4,241.9,177.4z" /> <polygon class="st0" points="138.8,221.4 132.8,195.3 191.3,136.6 218.4,143.4 " /> </g> <g id="petal3" onclick="notify(this,"select");"> <path class="st0" d="M174.3,259.4l68,69.4c3,3.1,3,8.1-0.1,11.1L221,360.6c-3.1,3-8.1,3-11.1-0.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1 l21.3-20.8C166.3,256.1,171.3,256.3,174.3,259.4z" /> <polygon class="st0" points="218.1,362.4 192.1,368.4 133.5,309.9 140.1,282.9 " /> </g> <g id="petal2" onclick="notify(this,"select");"> <path class="st0" d="M256.1,326.9l69.4-68c3.1-3,8.1-3,11.1,0.1l20.8,21.3c3,3.1,3,8.1-0.1,11.1l-69.4,68c-3.1,3-8.1,3-11.1-0.1 L256,338C253,334.9,253.1,329.9,256.1,326.9z" /> <polygon class="st0" points="359.3,282.9 365.3,309.1 306.8,367.8 279.6,361.1 " /> </g> <g id="petal1" onclick="notify(this,"select");"> <path class="st0" d="M323.8,245.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1l21.3-20.8c3.1-3,8.1-3,11.1,0.1l68,69.4c3,3.1,3,8.1-0.1,11.1 l-21.3,20.8C331.8,248.3,326.8,248.1,323.8,245.1z" /> <polygon class="st0" points="279.8,141.9 306,135.9 364.6,194.4 357.9,221.6 " /> </g> </g> <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0" to="360" begin="0" dur="5s" repeatCount="indefinite" /> </svg> </g> <circle class="st1" cx="250.4" cy="250.6" r="47.9" /> <rect id="stem" x="244" y="339" class="st0" width="12" height="385" /> </svg>
I fixed the cross platform issue by using GreenSock TweenMax, var $flower=$('#flower'); TweenMax.to($flower,5,{rotation:360,transformOrigin:"116 116", repeat: -1,ease:Linear.easeNone} ); <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 700 500" style="enable-background:new 0 0 0 0;" xml:space="preserve"> <style type="text/css"> .st0 { fill: #A9A9AD; } .st1 { fill: #FEF058; } </style> <g id="flower"> <g id="petals"> <g id="petal4" onclick="notify(this,"select");"> <path class="st0" d="M241.9,177.4l-69.4,68c-3.1,3-8.1,3-11.1-0.1l-20.8-21.2c-3-3.1-3-8.1,0.1-11.1l69.4-68c3.1-3,8.1-3,11.1,0.1 l20.8,21.2C245,169.4,245,174.4,241.9,177.4z" /> <polygon class="st0" points="138.8,221.4 132.8,195.3 191.3,136.6 218.4,143.4 " /> </g> <g id="petal3" onclick="notify(this,"select");"> <path class="st0" d="M174.3,259.4l68,69.4c3,3.1,3,8.1-0.1,11.1L221,360.6c-3.1,3-8.1,3-11.1-0.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1 l21.3-20.8C166.3,256.1,171.3,256.3,174.3,259.4z" /> <polygon class="st0" points="218.1,362.4 192.1,368.4 133.5,309.9 140.1,282.9 " /> </g> <g id="petal2" onclick="notify(this,"select");"> <path class="st0" d="M256.1,326.9l69.4-68c3.1-3,8.1-3,11.1,0.1l20.8,21.3c3,3.1,3,8.1-0.1,11.1l-69.4,68c-3.1,3-8.1,3-11.1-0.1 L256,338C253,334.9,253.1,329.9,256.1,326.9z" /> <polygon class="st0" points="359.3,282.9 365.3,309.1 306.8,367.8 279.6,361.1 " /> </g> <g id="petal1" onclick="notify(this,"select");"> <path class="st0" d="M323.8,245.1l-68-69.4c-3-3.1-3-8.1,0.1-11.1l21.3-20.8c3.1-3,8.1-3,11.1,0.1l68,69.4c3,3.1,3,8.1-0.1,11.1 l-21.3,20.8C331.8,248.3,326.8,248.1,323.8,245.1z" /> <polygon class="st0" points="279.8,141.9 306,135.9 364.6,194.4 357.9,221.6 " /> </g> </g> </g> <circle class="st1" cx="250.4" cy="250.6" r="47.9" /> <rect id="stem" x="244" y="339" class="st0" width="12" height="385" /> </svg>