SVG drawing - shape vanishing after animation [duplicate] - css

This question already has answers here:
Maintaining the final state at end of a CSS animation
(5 answers)
Closed 5 years ago.
I have a shape being animated/drawn which is fine, when the animation is done the shape remains on the page for a couple seconds then vanishes.
First time trying out CSS animations so don't fully understand why it vanishes off the page, I know it's probably something really obvious but any help pointers would be much appreciated.
body {
background-color: #fff;
}
svg {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 600px;
height: 600px;
}
.path {
stroke-dashoffset: 1600;
stroke-dasharray: 1600;
-webkit-animation: draw 5s linear;
-moz-animation: draw 5s linear;
animation: draw 5s linear;
fill-opacity: 0;
-webkit-animation-delay: 1.2s; /* Safari and Chrome */
animation-delay: 1.2s;
}
.path-first-o {
stroke-dashoffset: 1600;
stroke-dasharray: 1600;
-webkit-animation: draw 5s linear forwards;
-moz-animation: draw 5s linear forwards;
animation: draw 5s linear forwards;
fill-opacity: 0;
}
#-webkit-keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
#-moz-keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
#keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="210mm" height="297mm" viewBox="0 0 744.09448819 1052.3622047" preserveAspectRatio="xMidYMid meet" enable-background="new 0 0 1136 640" xml:space="preserve">
<g id="layer_1">
<g>
<path class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="M 247.28799,295.10581 29.551064,512.84273 247.28799,730.57965 l 0,-72.57898 L 102.13004,512.84273 247.28799,367.68478 Z"/>
<path class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="m 475.56912,295.10581 217.73694,217.73692 -217.73694,217.73692 0,-72.57898 L 620.72709,512.84273 475.56912,367.68478 Z" />
<path
class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="m 247.28799,599.93749 72.57897,0 159.67374,-174.18954 -72.57897,0 z" />
</g>
</g>
</svg>
See CodePen here

You are just missing the forwards keyword for the animation property. It is the a value for the animation-fill-mode property (see mdn).
This value keeps the last frame of the animation.
You can also use it in the animation shorthand like this :
body {
background-color: #fff;
}
svg {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 600px;
height: 600px;
}
.path {
stroke-dashoffset: 1600;
stroke-dasharray: 1600;
-webkit-animation: draw 5s linear;
-moz-animation: draw 5s linear;
animation: draw 5s linear;
fill-opacity: 0;
-webkit-animation-delay: 1.2s;
/* Safari and Chrome */
animation-delay: 1.2s;
}
.path-first-o {
stroke-dashoffset: 1600;
stroke-dasharray: 1600;
-webkit-animation: draw 5s linear forwards;
-moz-animation: draw 5s linear forwards;
animation: draw 5s linear forwards;
fill-opacity: 0;
}
#-webkit-keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
#-moz-keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
#keyframes draw {
30% {
stroke-dashoffset: 0;
fill-opacity: 0;
}
50% {
fill-opacity: 1;
}
100% {
stroke-dashoffset: 1;
fill-opacity: 1;
}
}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="210mm" height="297mm" viewBox="0 0 744.09448819 1052.3622047" preserveAspectRatio="xMidYMid meet" enable-background="new 0 0 1136 640" xml:space="preserve">
<g id="layer_1">
<g>
<path class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="M 247.28799,295.10581 29.551064,512.84273 247.28799,730.57965 l 0,-72.57898 L 102.13004,512.84273 247.28799,367.68478 Z"/>
<path class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="m 475.56912,295.10581 217.73694,217.73692 -217.73694,217.73692 0,-72.57898 L 620.72709,512.84273 475.56912,367.68478 Z" />
<path
class="path-first-o"
fill="#027eb4" stroke="#027eb4"
d="m 247.28799,599.93749 72.57897,0 159.67374,-174.18954 -72.57897,0 z" />
</g>
</g>
</svg>

Related

Invert the left svg animation?

Here is my code https://codepen.io/victoreugen2002/pen/PoJJPzP
I am trying to animate the left and right svg, to acheive this:
both starting at the same time from the top and they continue drawing.
until they both met at the bottom in the middle.
In order to acheive this I am thinking of inversing the animation for left svg, but it's not working:
.left {
width: 50%;
stroke-dasharray: 1855.968505859375;
animation: dash 2s ease-in;
#keyframes dash {
from {
stroke-dashoffset: 1855.968505859375;
}
to {
stroke-dashoffset: 3710;
}
}
svg {
left: 0;
}
}
You had to go from -1855.968505859375 to 0.
.left {
width: 50%;
stroke-dasharray: 1855.968505859375;
animation: dash-left 2s ease-in;
}
.left svg {
left: 0;
}
.right {
width: 50%;
stroke-dasharray: 1855.968505859375;
animation: dash-right 2s ease-in;
}
.right svg {
right: 0;
}
svg {
position: absolute;
top: 20px;
width: 50%;
stroke-width: 5px;
}
#keyframes dash-left {
from { stroke-dashoffset: -1855.968505859375 }
to { stroke-dashoffset: 0 }
}
#keyframes dash-right {
from { stroke-dashoffset: 1855.968505859375 }
to { stroke-dashoffset: 0 }
}
<div class="left">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 733 425">
<path d="M733,424.5H39A38.5,38.5,0,0,1,.5,386V39A38.5,38.5,0,0,1,39,.5H733" style="fill: none;stroke: #78be21"/>
</svg>
</div>
<div class="right">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 733 425">
<path d="M0,.5H694A38.5,38.5,0,0,1,732.5,39V386A38.5,38.5,0,0,1,694,424.5H0" style="fill: none;stroke: #78be21"/>
</svg>
</div>

Why is my #keyframes animation not working with the SVG `stroke-dashoffset` property?

My CSS animation is not working when I try to apply it to my <svg> element.
I have tried to use a prefix but it still did not fix the problem.
#keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
#-webkit-keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
.circle {
position: absolute;
top: 0;
left: 0;
animation-duration: 1.4s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-fill-mode: both;
animation-name: mymove;
-webkit-animation-name: mymove;
}
<nav class="footage-nav">
<a class="link" href="my_work/index.html"><svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>Work<div class="underLine"></div></a>
<svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>About<div class="underLine"></div>
</nav>
As commented by user4642212
The animation is definitely active (as you can see in dev tools), but
it has no effect. What are you expecting it to do? stroke-dashoffset
modifies where a stroke-dasharray starts. You’ve never set one.
In other words, for the animation to work, you need to add the stroke-dasharray to the animated object.: stroke-dasharray:56.52;
#keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
#-webkit-keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
.circle {
stroke-dasharray:56.52;
position: absolute;
top: 0;
left: 0;
animation-duration: 1.4s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-fill-mode: both;
animation-name: mymove;
-webkit-animation-name: mymove;
}
<nav class="footage-nav">
<a class="link" href="my_work/index.html"><svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>Work<div class="underLine"></div></a>
<svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>About<div class="underLine"></div>
</nav>
Animation option when hovering over a link
#keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
#-webkit-keyframes mymove {
0% {
stroke-dashoffset: 0;
}
50% {
stroke-dashoffset: 56.52;
}
}
.circle {
stroke-dasharray:56.52;
position: absolute;
top: 0;
left: 0;
}
.link:hover {
animation-duration: 1.4s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-fill-mode: both;
animation-name: mymove;
-webkit-animation-name: mymove;
}
<nav class="footage-nav">
<a class="link" href="my_work/index.html"><svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>Work<div class="underLine"></div></a>
<a class="link" href=""><svg height="20" width="20"><circle class="circle" cx="50%" cy="50%" r="9" stroke="#231f20" stroke-width="1" fill-opacity="0" /></svg>About<div class="underLine"></div></a>
</nav>

how to stop an svg css animation?

I have an SVG animation and I'm trying to figure out how to stop and leave the SVG in view right after the animation sequence is completed once. This way the logo stays on the page until the next page refresh etc.
here's the demo:
https://jsfiddle.net/u410bjyk/
html:
<svg class="pin" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 60 60" version="1.1">
<g class="pin__group">
<g class="pin__grayGroup">
<path class="pin__square" fill="none" stroke-width="1" d="M0,0 0,60 60,60 60,0z"/>
<path class="pin__line pin__line-1" fill="none" stroke-width="1" d="M15,0 15,60"/>
<path class="pin__line pin__line-2" fill="none" stroke-width="1" d="M30,0 30,60"/>
<path class="pin__line pin__line-3" fill="none" stroke-width="1" d="M45,0 45,60"/>
<path class="pin__line pin__line-1" fill="none" stroke-width="1" d="M0,45 60,45"/>
<path class="pin__line pin__line-2" fill="none" stroke-width="1" d="M0,30 60,30"/>
<path class="pin__line pin__line-3" fill="none" stroke-width="1" d="M0,15 60,15"/>
<path class="pin__circleBig" fill="none" stroke-width="1" d="M60,30 a30,30 0 0,1 -60,0 a30,30 0 0,1 60,0"/>
<path class="pin__circleSmall" fill="none" stroke-width="1" d="M45,30 a15,15 0 0,1 -30,0 a15,15 0 0,1 30,0"/>
</g>
<g class="pin__greenGroup">
<path class="pin__outer" stroke-width="2" d="M30,0 a30,30 0 0,1 30,30 L60,60 30,60 a30,30 0 0,1 0,-60"/>
<path class="pin__inner" stroke-width="2" d="M45,30 a15,15 0 0,1 -30,0 a15,15 0 0,1 30,0"/>
</g>
</g>
</svg>
CSS:
*, *:before, *:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.pin {
position: absolute;
left: 50%;
top: 50%;
margin-left: -60px;
margin-top: -60px;
width: 120px;
height: 120px;
overflow: visible;
}
.pin__group {
-webkit-transform-origin: 30px 30px;
transform-origin: 30px 30px;
-webkit-animation: group-anim 8s 1s infinite;
animation: group-anim 8s 1s infinite;
}
.pin__grayGroup {
-webkit-animation: gray-anim 8s 1s infinite;
animation: gray-anim 8s 1s infinite;
}
.pin__square {
stroke: #B8B8B8;
stroke-dasharray: 240, 240;
stroke-dashoffset: 240;
-webkit-animation: square-anim 8s 1s infinite;
animation: square-anim 8s 1s infinite;
}
.pin__line {
stroke: #B8B8B8;
stroke-dasharray: 60, 60;
stroke-dashoffset: 60;
}
.pin__line-1 {
-webkit-animation: line-anim 8s 0.6s infinite;
animation: line-anim 8s 0.6s infinite;
}
.pin__line-2 {
-webkit-animation: line-anim 8s 0.8s infinite;
animation: line-anim 8s 0.8s infinite;
}
.pin__line-3 {
-webkit-animation: line-anim 8s 1s infinite;
animation: line-anim 8s 1s infinite;
}
.pin__circleBig {
stroke: #B8B8B8;
stroke-dasharray: 188.522, 188.522;
stroke-dashoffset: 188.522;
-webkit-animation: bigCircle-anim 8s 1s infinite;
animation: bigCircle-anim 8s 1s infinite;
}
.pin__circleSmall {
stroke: #B8B8B8;
stroke-dasharray: 94.261, 94.261;
stroke-dashoffset: 94.261;
-webkit-animation: smallCircle-anim 8s 1s infinite;
animation: smallCircle-anim 8s 1s infinite;
}
.pin__outer {
stroke: #00CD73;
fill: transparent;
stroke-dasharray: 201.391, 201.391;
stroke-dashoffset: 201.391;
-webkit-animation: outer-anim 8s 1s infinite;
animation: outer-anim 8s 1s infinite;
}
.pin__inner {
stroke: #00CD73;
fill: transparent;
stroke-dasharray: 94.261, 94.261;
stroke-dashoffset: 94.261;
-webkit-animation: inner-anim 8s 1s infinite;
animation: inner-anim 8s 1s infinite;
}
#-webkit-keyframes square-anim {
15% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes square-anim {
15% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes line-anim {
23% {
stroke-dashoffset: 60;
}
30% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes line-anim {
23% {
stroke-dashoffset: 60;
}
30% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes bigCircle-anim {
30% {
stroke-dashoffset: 188.522;
}
43% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes bigCircle-anim {
30% {
stroke-dashoffset: 188.522;
}
43% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes smallCircle-anim {
43% {
stroke-dashoffset: 94.261;
}
53% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes smallCircle-anim {
43% {
stroke-dashoffset: 94.261;
}
53% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes group-anim {
53% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
61% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
94% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 1;
}
100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 0;
}
}
#keyframes group-anim {
53% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
61% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
94% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 1;
}
100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 0;
}
}
#-webkit-keyframes outer-anim {
61% {
stroke-dashoffset: 201.391;
}
71% {
stroke-dashoffset: 0;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: #00CD73;
}
100% {
stroke-dashoffset: 0;
fill: #00CD73;
}
}
#keyframes outer-anim {
61% {
stroke-dashoffset: 201.391;
}
71% {
stroke-dashoffset: 0;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: #00CD73;
}
100% {
stroke-dashoffset: 0;
fill: #00CD73;
}
}
#-webkit-keyframes inner-anim {
71% {
stroke-dashoffset: 94.261;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: white;
}
100% {
stroke-dashoffset: 0;
fill: white;
}
}
#keyframes inner-anim {
71% {
stroke-dashoffset: 94.261;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: white;
}
100% {
stroke-dashoffset: 0;
fill: white;
}
}
#-webkit-keyframes gray-anim {
53% {
opacity: 1;
}
79% {
opacity: 0.2;
}
94% {
opacity: 0;
}
100% {
opacity: 0;
}
}
#keyframes gray-anim {
53% {
opacity: 1;
}
79% {
opacity: 0.2;
}
94% {
opacity: 0;
}
100% {
opacity: 0;
}
}
I know I can remove the "infinite" property to run it once, but the question is, how do you stop it right after instead?
You can pause a CSS animation by using:
animation-play-state: paused;
I've added a button to your example that lets you stop the animation at any point.
function stop() {
$(".pin__group, .pin__grayGroup, .pin__square, .pin__line-1, .pin__line-2, .pin__line-3, .pin__circleBig, .pin__circleSmall, .pin__outer, .pin__inner").addClass("stop");
}
*, *:before, *:after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.pin {
position: absolute;
left: 50%;
top: 50%;
margin-left: -60px;
margin-top: -60px;
width: 120px;
height: 120px;
overflow: visible;
}
.pin__group {
-webkit-transform-origin: 30px 30px;
transform-origin: 30px 30px;
-webkit-animation: group-anim 8s 1s forwards;
animation: group-anim 8s 1s forwards;
}
.pin__grayGroup {
-webkit-animation: gray-anim 8s 1s infinite;
animation: gray-anim 8s 1s infinite;
}
.pin__square {
stroke: #B8B8B8;
stroke-dasharray: 240, 240;
stroke-dashoffset: 240;
-webkit-animation: square-anim 8s 1s infinite;
animation: square-anim 8s 1s infinite;
}
.pin__line {
stroke: #B8B8B8;
stroke-dasharray: 60, 60;
stroke-dashoffset: 60;
}
.pin__line-1 {
-webkit-animation: line-anim 8s 0.6s infinite;
animation: line-anim 8s 0.6s infinite;
}
.pin__line-2 {
-webkit-animation: line-anim 8s 0.8s infinite;
animation: line-anim 8s 0.8s infinite;
}
.pin__line-3 {
-webkit-animation: line-anim 8s 1s infinite;
animation: line-anim 8s 1s infinite;
}
.pin__circleBig {
stroke: #B8B8B8;
stroke-dasharray: 188.522, 188.522;
stroke-dashoffset: 188.522;
-webkit-animation: bigCircle-anim 8s 1s infinite;
animation: bigCircle-anim 8s 1s infinite;
}
.pin__circleSmall {
stroke: #B8B8B8;
stroke-dasharray: 94.261, 94.261;
stroke-dashoffset: 94.261;
-webkit-animation: smallCircle-anim 8s 1s infinite;
animation: smallCircle-anim 8s 1s infinite;
}
.pin__outer {
stroke: #00CD73;
fill: transparent;
stroke-dasharray: 201.391, 201.391;
stroke-dashoffset: 201.391;
-webkit-animation: outer-anim 8s 1s infinite;
animation: outer-anim 8s 1s infinite;
}
.pin__inner {
stroke: #00CD73;
fill: transparent;
stroke-dasharray: 94.261, 94.261;
stroke-dashoffset: 94.261;
-webkit-animation: inner-anim 8s 1s infinite;
animation: inner-anim 8s 1s infinite;
}
#-webkit-keyframes square-anim {
15% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes square-anim {
15% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes line-anim {
23% {
stroke-dashoffset: 60;
}
30% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes line-anim {
23% {
stroke-dashoffset: 60;
}
30% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes bigCircle-anim {
30% {
stroke-dashoffset: 188.522;
}
43% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes bigCircle-anim {
30% {
stroke-dashoffset: 188.522;
}
43% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes smallCircle-anim {
43% {
stroke-dashoffset: 94.261;
}
53% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes smallCircle-anim {
43% {
stroke-dashoffset: 94.261;
}
53% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#-webkit-keyframes group-anim {
53% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
61% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
94% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
}
#keyframes group-anim {
53% {
-webkit-transform: rotate(0);
transform: rotate(0);
}
61% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
94% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
100% {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
}
#-webkit-keyframes outer-anim {
61% {
stroke-dashoffset: 201.391;
}
71% {
stroke-dashoffset: 0;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: #00CD73;
}
100% {
stroke-dashoffset: 0;
fill: #00CD73;
}
}
#keyframes outer-anim {
61% {
stroke-dashoffset: 201.391;
}
71% {
stroke-dashoffset: 0;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: #00CD73;
}
100% {
stroke-dashoffset: 0;
fill: #00CD73;
}
}
#-webkit-keyframes inner-anim {
71% {
stroke-dashoffset: 94.261;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: white;
}
100% {
stroke-dashoffset: 0;
fill: white;
}
}
#keyframes inner-anim {
71% {
stroke-dashoffset: 94.261;
}
79% {
stroke-dashoffset: 0;
fill: transparent;
}
94% {
stroke-dashoffset: 0;
fill: white;
}
100% {
stroke-dashoffset: 0;
fill: white;
}
}
#-webkit-keyframes gray-anim {
53% {
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
79% {
opacity: 0.2;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
}
94% {
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
100% {
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
}
#keyframes gray-anim {
53% {
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
}
79% {
opacity: 0.2;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
}
94% {
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
100% {
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
}
.stop {
-webkit-animation-play-state: paused;
-moz-animation-play-state: paused;
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<svg class="pin" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 60 60" version="1.1">
<g class="pin__group">
<g class="pin__grayGroup">
<path class="pin__square" fill="none" stroke-width="1" d="M0,0 0,60 60,60 60,0z"/>
<path class="pin__line pin__line-1" fill="none" stroke-width="1" d="M15,0 15,60"/>
<path class="pin__line pin__line-2" fill="none" stroke-width="1" d="M30,0 30,60"/>
<path class="pin__line pin__line-3" fill="none" stroke-width="1" d="M45,0 45,60"/>
<path class="pin__line pin__line-1" fill="none" stroke-width="1" d="M0,45 60,45"/>
<path class="pin__line pin__line-2" fill="none" stroke-width="1" d="M0,30 60,30"/>
<path class="pin__line pin__line-3" fill="none" stroke-width="1" d="M0,15 60,15"/>
<path class="pin__circleBig" fill="none" stroke-width="1" d="M60,30 a30,30 0 0,1 -60,0 a30,30 0 0,1 60,0"/>
<path class="pin__circleSmall" fill="none" stroke-width="1" d="M45,30 a15,15 0 0,1 -30,0 a15,15 0 0,1 30,0"/>
</g>
<g class="pin__greenGroup">
<path class="pin__outer" stroke-width="2" d="M30,0 a30,30 0 0,1 30,30 L60,60 30,60 a30,30 0 0,1 0,-60"/>
<path class="pin__inner" stroke-width="2" d="M45,30 a15,15 0 0,1 -30,0 a15,15 0 0,1 30,0"/>
</g>
</g>
</svg>
<button onclick="stop()">Stop</button>

SVG Fill and Filter urls from css not working on safari

I created an animation for my personal website, its working in Chrome and Firefox with no problems and I don't care about IE, but its not working on Safari, I think because Safari won't recognise the fill:url(..) and filter:url(..) from seperate css file. Here's the actual animation link from codepen: http://codepen.io/GetTurnt/pen/kXREWw I would really like to know what is happening.
Here is the actual code:
.container {
width:50%;
height:50%;
padding: 0 25%;
}
.st0 {
fill:none;
stroke:#E27A4D;
stroke-width:31;
stroke-miterlimit:10;
stroke-dasharray:228.0897;
opacity:0.9;
stroke-dashoffset: -228.0897;
animation-name: line1;
animation-duration: .25s;
animation-delay: 3s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes line1 {
0% {
stroke-dashoffset: -228.0897;
}
70% {
stroke-dashoffset: -50;
}
80% {
stroke-dashoffset: -30;
}
90%{
stroke-dashoffset: -15;
}
100%{
stroke-dashoffset: 0;
}
}
.st1 {
fill:none;
stroke:#E27A4D;
stroke-width:31;
stroke-miterlimit:10;
stroke-dasharray:191.6966;
opacity:0.9;
stroke-dashoffset: 191.6966;
animation-name: line2;
animation-duration: .25s;
animation-delay: 3s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes line2 {
0% {
stroke-dashoffset: 191.6966;
}
70% {
stroke-dashoffset: 50;
}
80% {
stroke-dashoffset: 30;
}
90%{
stroke-dashoffset: 15;
}
100%{
stroke-dashoffset: 0;
}
}
.st2 {
fill:none;
stroke:#E27A4D;
stroke-width:31;
stroke-miterlimit:10;
stroke-dasharray:228.2286;
opacity:0.9;
stroke-dashoffset: 228.2286;
animation-name: line3;
animation-duration: .25s;
animation-delay: 3s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes line3 {
0% {
stroke-dashoffset: 228.2286;
}
70% {
stroke-dashoffset: 50;
}
80% {
stroke-dashoffset: 30;
}
90%{
stroke-dashoffset: 15;
}
100%{
stroke-dashoffset: 0;
}
}
.st3 {
fill:none;
stroke:#E27A4D;
stroke-width:31;
stroke-miterlimit:10;
stroke-dasharray:228.2286;
opacity:0.9;
stroke-dashoffset: 228.2286;
animation-name: line4;
animation-duration: .25s;
animation-delay: 3s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes line4 {
0% {
stroke-dashoffset: 228.2286;
}
70% {
stroke-dashoffset: 50;
}
80% {
stroke-dashoffset: 30;
}
90%{
stroke-dashoffset: 15;
}
100%{
stroke-dashoffset: 0;
}
}
.st4 {
fill:none;
stroke:#E27A4D;
stroke-miterlimit:10;
stroke-dasharray:411;
stroke-dashoffset:411;
filter:url(#dropshadow);
animation-name: m;
animation-duration: .75s;
animation-delay: 2.5s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes m {
0% {
stroke-dashoffset: 411;
stroke-width: 1;
}
70% {
stroke-dashoffset: 0;
stroke-width: 1;
}
90%{
stroke-dashoffset: 0;
stroke-width: 0;
}
100%{
fill:url(#SVGID_1_);
stroke-dashoffset: 0;
stroke-width: 0;
}
}
.st5 {
fill:none;
stroke:#E27A4D;
stroke-miterlimit:10;
stroke-dasharray:162;
stroke-dashoffset:162;
filter:url(#dropshadow);
animation-name: p1;
animation-duration: .5s;
animation-delay: 2.5s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes p1 {
0% {
stroke-dashoffset: 162;
stroke-width: 1;
}
70% {
stroke-dashoffset: 0;
stroke-width: 1;
}
90%{
stroke-dashoffset: 0;
stroke-width: 0;
}
100%{
fill:url(#SVGID_2_);
stroke-dashoffset: 0;
stroke-width: 0;
}
}
.st6 {
fill:none;
stroke:#E27A4D;
stroke-miterlimit:10;
stroke-dasharray:161;
stroke-dashoffset:161;
filter:url(#dropshadow);
animation-name: p2;
animation-duration: .5s;
animation-delay: 2s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes p2 {
0% {
stroke-dashoffset: 161;
stroke-width: 1;
}
70% {
stroke-dashoffset: 0;
stroke-width: 1;
}
90%{
stroke-dashoffset: 0;
stroke-width: 0;
}
100%{
fill:url(#SVGID_3_);
stroke-dashoffset: 0;
stroke-width: 0;
}
}
.st7 {
fill:none;
stroke:#E27A4D;
stroke-miterlimit:10;
stroke-dasharray:381;
stroke-dashoffset:381;
filter:url(#dropshadow);
animation-name: c;
animation-duration: .75s;
animation-delay: 2s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
#keyframes c {
0% {
stroke-dashoffset: 381;
stroke-width: 1;
}
70% {
stroke-dashoffset: 0;
stroke-width: 1;
}
90%{
stroke-dashoffset: 0;
stroke-width: 0;
}
100%{
fill:url(#SVGID_4_);
stroke-dashoffset: 0;
stroke-width: 0;
}
}
<div class="container">
<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 305.7 217.6" style="enable-background:new 0 0 305.7 217.6;" xml:space="preserve">
<radialGradient id="SVGID_1_" cx="62.4629" cy="34.0002" r="39.9731" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#383D48"/>
<stop offset="1" style="stop-color:#23262D"/>
</radialGradient>
<radialGradient id="SVGID_2_" cx="147.3418" cy="93.7559" r="20.996" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#383D48"/>
<stop offset="1" style="stop-color:#23262D"/>
</radialGradient>
<radialGradient id="SVGID_3_" cx="152.9411" cy="99.3551" r="20.885" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#383D48"/>
<stop offset="1" style="stop-color:#23262D"/>
</radialGradient>
<radialGradient id="SVGID_4_" cx="243.2371" cy="159" r="39.9731" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#383D48"/>
<stop offset="1" style="stop-color:#23262D"/>
</radialGradient>
<defs>
<filter id="dropshadow" height="130%">
<feGaussianBlur in="SourceAlpha" stdDeviation="3"/>
<feOffset dx="0" dy="7" result="offsetblur"/>
<feComponentTransfer>
<feFuncA type="linear" slope="0.35"/>
</feComponentTransfer>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<line class="st0" x1="96.5" y1="34" x2="288.4" y2="34"/>
<line class="st1" x1="17.3" y1="96.5" x2="152.8" y2="96.5"/>
<line class="st2" x1="288.4" y1="96.5" x2="152.8" y2="96.5"/>
<line class="st3" x1="17.3" y1="159" x2="209.4" y2="159"/>
<path class="st4" d="M17.3,0l45.2,31l45.2-31v68H87.1V36.8L62.5,54.9L37.8,36.8V68H17.3V0z"/>
<g>
<polygon class="st5" points="131.3,114.8 136.4,109.7 134.4,107.7 161.3,80.8 163.3,82.8 168.3,77.7 163.4,72.8 150.1,86.1
136.8,72.8 126.3,83.3 139.6,96.5 126.3,109.8 "/>
<polygon class="st6" points="160.5,96.5 173.8,83.2 169.1,78.5 164,83.5 165.8,85.3 138.9,112.2 137.1,110.4 132.1,115.5
136.8,120.2 150.1,107 163.3,120.2 173.8,109.8 "/>
</g>
<path class="st7" d="M288.4,185.3c-9.4,4.8-21.7,7.7-35.7,7.7c-32.5,0-54.6-14.6-54.6-34s22.1-34,54.6-34c14,0,26.3,2.8,35.7,7.7
l-9.9,15c-6.9-3.1-16.3-5.2-25.8-5.2c-16.3,0-30,6.2-30,16.6c0,10.4,13.7,16.6,30,16.6c9.5,0,18.9-2.1,25.8-5.2L288.4,185.3z"/>
</svg>
</div>
Note that I have tried using fill:url('#hash') , fill:url('/#hash') and moved the radialGradient into the <defs> tag to no avail, it isn't working. I hope that it's a simple mistake I've made.
The problem was not urls to fills and filters it was the fill:none, I had to use fill: ('#..') and fill-opacity:0.01 and alter fill-opacity to 1 during keyframes, its a little bit buggy but it gets the job done for the time being, if anybody has another solution, please do share.
I face the same problem and yes the problem is the fill:none, but I solved using fill: transparent

How to do that animation begins after page is fully loaded?

I have animation (#svg_tag, .st0). After animation complete, then fades-in the image (.logo_svg). I want that animation begins after page is fully loaded (both animation and image).
.logo_svg {
max-width: 80%;
width: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
opacity: 0;
animation-name: show;
animation-delay: 11s;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
animation-timing-function: linear;
}
body{
background-color: grey;
}
#svg_tag {
max-width: 80%;
width: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.st0 {
fill-opacity: 0;
stroke: #fff;
stroke-width: 1;
stroke-dasharray: 1350;
stroke-dashoffset: 1350;
animation: draw 15s linear;
animation-delay: 5s;
}
#keyframes draw {
to {
stroke-dashoffset: 0;
}
}
#keyframes show {
to {
opacity: 1;
}
}
<body>
<svg version="1.1" id="svg_tag" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 708.7 437.3" style="enable-background:new 0 0 708.7 437.3;" xml:space="preserve">
<path id="XMLID_13_" class="st0" d="M708.7,285c-18.6,18.6-47.7,21.9-70,7.9v102.3l70,42V285z"/>
<path id="XMLID_12_" class="st0" d="M595.6,113.1l-113.1,67.9v7.5H509V245c0,16.6,13.4,30,30,30s30-13.4,30-30v-56.5h26.5v113.1
h-26.5v-8.6c-9,5.6-19.4,8.6-30,8.6c-31.2,0-56.5-25.3-56.5-56.5v56.5l129.6,77.8V188.5h26.5v8.6c22.3-14,51.4-10.7,70,7.9v-24.1
L595.6,113.1z"/>
<circle id="XMLID_11_" class="st0" cx="669" cy="245" r="30"/>
<path id="XMLID_10_" class="st0" d="M242.7,188.5h-9.9V245c0,25.7-20.9,46.6-46.6,46.6s-46.6-20.9-46.6-46.6v-56.5h-9.9V245
c0,31.2,25.3,56.5,56.5,56.5c18.6,0,36.1-9.2,46.6-24.5v24.5h9.9V188.5z"/>
<polyline id="XMLID_9_" class="st0" points="279.2,188.5 259.3,188.5 259.3,198.4 269.2,198.4 269.2,301.6 279.2,301.6 279.2,188.5
"/>
<path id="XMLID_8_" class="st0" d="M259.3,123c0-5.5,4.4-9.9,9.9-9.9s9.9,4.4,9.9,9.9s-4.4,9.9-9.9,9.9S259.3,128.5,259.3,123
L259.3,123z"/>
<rect id="XMLID_7_" x="295.7" y="113.1" class="st0" width="9.9" height="188.5"/>
<path id="XMLID_16_" class="st0" d="M425.4,0v213c-17.7-25.7-52.9-32.3-78.6-14.6c-25.7,17.7-32.3,52.9-14.6,78.6
c17.7,25.7,52.9,32.3,78.6,14.6c5.7-3.9,10.7-8.9,14.6-14.6v24.5h9.9V0H425.4z M378.8,291.6c-25.7,0-46.6-20.9-46.6-46.6
s20.9-46.6,46.6-46.6s46.6,20.9,46.6,46.6S404.5,291.6,378.8,291.6z"/>
<path id="XMLID_15_" class="st0" d="M103.1,213c-17.7-25.7-52.9-32.3-78.6-14.6c-5.7,3.9-10.7,8.9-14.6,14.6V0H0v301.6h9.9V277
c17.7,25.7,52.9,32.3,78.6,14.6C114.3,273.9,120.8,238.7,103.1,213z M56.5,291.6c-25.7,0-46.6-20.9-46.6-46.6s20.9-46.6,46.6-46.6
s46.6,20.9,46.6,46.6S82.3,291.6,56.5,291.6z"/>
</svg>
<img src="logo.png" class="logo_svg" alt="" />
</body>
Thanks for uploading the HTML.
Correct me if I'm wrong, but I think you want to animate the logo, to draw itself, when the page loads. And then you want to animate another logo, that fades in.
If the logotypes are the same - then you can animate the first SVG logo itself, with one animation. No need for two :)
Here's a little codepen that does exactly that.
Here's the essential animation:
svg{
max-width: 80%;
width: 100%;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.st0 {
fill-opacity: 0;
stroke: #fff;
stroke-width: 1;
stroke-dasharray: 1350;
stroke-dashoffset: 1350;
animation: draw 5s linear forwards;
}
#keyframes draw {
95% {
stroke-dashoffset: 0;
fill-opacity:0;
stroke-width:1;
}
100%{
fill-opacity:1;
stroke-width:0;
}
}
Does this solve your problem?

Resources