When playing around with some SVG animation, i ran into a strange artifact. When rendering keystroke-dashoffset animations in Chrome (haven't tested any other browsers) stops before they are finished, see below. In this case it is the S and M.
The lines also seem to retract a bit in the beginning. How do i fix this so that the letters render fully?
I use OSX El Capitan and Chrome v.51.0.2704.84.
Here is the code (not written by me):
text {
font-family: sans-serif;
stroke-dasharray: 100%;
stroke-dashoffset: 100%;
-webkit-animation: draw 8s forwards;
-moz-animation: draw 8s forwards;
-o-animation: draw 8s forwards;
-ms-animation: draw 8s forwards;
animation: draw 8s forwards;
}
#-webkit-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-moz-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-o-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-ms-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
<svg width="500" height="150">
<text x="100" y="80" fill="none" stroke="black" stroke-width="1" font-size="50">Some text</text>
</svg>
The problem lies in the stroke-dasharray property in CSS. Setting this to a value larger than 100% (125% is enough for most fonts) will draw the letters correctly. This will cause the letters to already be drawn when the animation starts, so i set the stroke-dashoffset property to 125%, too.
body {
background:black;
}
text {
font-family: initial;
stroke-dasharray: 125%;
stroke-dashoffset: 125%;
-webkit-animation: draw 5s ease-in-out forwards;
-moz-animation: draw 5s ease-in-out forwards;
-o-animation: draw 5s ease-in-out forwards;
-ms-animation: draw 5s ease-in-out forwards;
animation: draw 5s ease-in-out forwards;
}
#-webkit-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-moz-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-o-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#-ms-keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<svg width="500" height="150">
<text x="100" y="80" fill="none" stroke="white" stroke-width="1" font-size="50">Some text</text>
</svg>
Related
I am using the material spinner from this codepen: https://codepen.io/mrrocks/pen/EiplA
It displays perfectly in all browsers except IE.
Here is the SVG icon:
<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>
</svg>
Then we have the LESS to make it rotate and all that:
$offset: 187;
$duration: 1.4s;
.spinner {
animation: rotator $duration linear infinite;
}
#keyframes rotator {
0% { transform: rotate(0deg); }
100% { transform: rotate(270deg); }
}
.path {
stroke-dasharray: $offset;
stroke-dashoffset: 0;
transform-origin: center;
animation:
dash $duration ease-in-out infinite,
colors ($duration*4) ease-in-out infinite;
}
#keyframes colors {
0% { stroke: #4285F4; }
25% { stroke: #DE3E35; }
50% { stroke: #F7C223; }
75% { stroke: #1B9A59; }
100% { stroke: #4285F4; }
}
#keyframes dash {
0% { stroke-dashoffset: $offset; }
50% {
stroke-dashoffset: $offset/4;
transform:rotate(135deg);
}
100% {
stroke-dashoffset: $offset;
transform:rotate(450deg);
}
}
As far as I can tell everything I am using seems to be supported in IE11 according to caniuse.com: http://caniuse.com/#search=svg and http://caniuse.com/#feat=css-animation.
I tried adding <meta http-equiv="X-UA-Compatible" content="IE=edge"> but it had no effect.
Any ideas?
I have the following HTML and CSS code:
.spinner-container {
-webkit-animation: rotate 2s linear infinite;
animation: rotate 2s linear infinite;
z-index: 2;
}
.spinner-container .path {
stroke-dasharray: 1,150;
stroke-dashoffset: 0;
stroke: rgba(27, 154, 89, 0.7);
stroke-linecap: round;
-webkit-animation: dash 1.5s ease-in-out infinite;
animation: dash 1.5s ease-in-out infinite;
}
#keyframes rotate {
100% {
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
}
}
#keyframes dash {
0% {
stroke-dasharray: 1,150;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 90,150;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 90,150;
stroke-dashoffset: -124;
}
}
#-webkit-keyframes dash {
0% {
stroke-dasharray: 1,150;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 90,150;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 90,150;
stroke-dashoffset: -124;
}
}
<svg class="spinner-container" viewBox="0 0 44 44" style="width: 50px; height: 50px;"><circle class="path" cx="22" cy="22" r="20" fill="none" stroke-width="4"></circle></svg>
If you run it in IE Edge, you will see that animation is interrupted. How can be fixed ?
I've made an animation using svg and now I wonder how to activate it when it shows on the screen. Tried with Scroll Reveal but it doesn't work.
Here is the animation: http://jsfiddle.net/z86026mv/148/light/
HTML
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" width="136.5px" height="100.15px" viewBox="0 0 136.5 100.15" enable-background="new 0 0 136.5 100.15" xml:space="preserve">
<rect class="key" x="111.284" y="80.95" fill="none" stroke="#000000" stroke-width="6" stroke-miterlimit="10" width="1.02" height="1.02"/>
<path class="phone" fill="none" stroke="#000000" stroke-width="6" stroke-miterlimit="10" d="M102.85 31.275L90.902 43.222v51.003h29.837l11.947-11.946V31.275H102.85z"/>
<polyline class="bottom_line" fill="none" stroke="#000000" stroke-width="6" stroke-miterlimit="10" points="52.476 94.225 65.188 94.225 78.059 94.225 "/>
<line class="vert_line" fill="none" stroke="#000000" stroke-width="6" stroke-miterlimit="10" x1="65.188" y1="94.225" x2="65.188" y2="81.969"/>
<polyline class="screen" fill="none" stroke="#000000" stroke-width="6" stroke-miterlimit="10" points="120.74 22.27 120.74 5.924 3.813 5.924 3.813 81.969 82.262 81.969 "/>
CSS
/*Animacje*/
svg * {
fill: none;
stroke: currentColor;
stroke-linecap: square;
stroke-linejoin: miter;
color: #100F0D;
stroke-width: 6;
stroke-miterlimit: 10;
}
.phone {
animation: draw 1.5s cubic-bezier(1, 0.1, 0, 0.87) alternate;
-webkit-animation: draw 1.5s cubic-bezier(1, 0.1, 0, 0.87) alternate;
}
#keyframes draw {
0% {
stroke-dashoffset: 192;
stroke-dasharray: 192;
}
100% {
stroke-dashoffset: 0;
stroke-dasharray: 192;
}
}
.screen {
animation: screen 1.5s cubic-bezier(1, 0.1, 0, 0.87) alternate;
-webkit-animation: screen 1.5s cubic-bezier(1, 0.1, 0, 0.87) alternate;
fill-opacity: 0;
stroke: #000;
stroke-width: 6;
}
#keyframes screen {
0% {
stroke-dashoffset: 290;
stroke-dasharray: 290;
}
100% {
stroke-dashoffset: 0;
stroke-dasharray: 290;
}
}
.bottom_line {
position: absolute;
opacity: 0;
-webkit-animation: bottom_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
-moz-animation: bottom_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
-o-animation: bottom_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
animation: bottom_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
}
#keyframes bottom_line {
0% {
opacity: 1;
stroke-dashoffset: 290;
stroke-dasharray: 290;
}
100% {
opacity: 1;
stroke-dashoffset: 0;
stroke-dasharray: 290;
}
}
.vert_line{
position: absolute;
opacity: 0;
-webkit-animation: vert_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
-moz-animation: vert_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
-o-animation: vert_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
animation: vert_line 1s cubic-bezier(1, 0.1, 0, 0.87) 1s forwards;
}
#keyframes vert_line {
0% {
opacity: 1;
stroke-dashoffset: 290;
stroke-dasharray: 290;
}
100% {
opacity: 1;
stroke-dashoffset: 0;
stroke-dasharray: 290;
}
}
.key {
position: absolute;
opacity: 0;
-webkit-animation: key 1s ease 1s forwards;
-moz-animation: key 1s ease 1s forwards;
-o-animation: key 1s ease 1s forwards;
animation: key 1s ease 1s forwards;
}
#keyframes key {
0% {
opacity: 0;
transform: translate(-35px,0px);
-ms-transform: translate(-35px,0px); /* IE 9 */
-webkit-transform: translate(-35px,0px); /* Safari and Chrome */
-o-transform: translate(-35px,0px); /* Opera */
-moz-transform: translate(-35px,0px); /* Firefox */
}
100% {
opacity: 1;
transform: translate(0,0px);
-ms-transform: translate(0,0px); /* IE 9 */
-webkit-transform: translate(0,0px); /* Safari and Chrome */
-o-transform: translate(0,0px); /* Opera */
-moz-transform: translate(0,0px); /* Firefox */
}
}
#-webkit-keyframes key {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
And here, in the "Service" section I have placed it. http://flowagency.nu/index_ico.php
Do you have any ideas?
Thx in advance.
you can set the display of the svg to none var svg = document.getElementsByTagName("svg")[0];
svg.style.display='none'; then when you click on the service tab you can set the display to block svg.style.display='block'; watch out the example below i did the second step using setTimeout you can do it with click or whatever you like
http://jsfiddle.net/z86026mv/149/
I have been trying to get an line svg animation to behave consistently cross-browser but, Internet Explorer 11 is not beginning the animation on page load.
To simplify my question I have forked an example from jczimmm
I have removed any vendor prefixes to distill the CSS into its barest form so they can be re-added if needed.
Here is the link to the fork on codepen.
Here is the svg
<div class="loader">
<svg class="circular">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
</svg>
</div>
and here is the css
body {
background-color: #eee;
}
.loader {
position: relative;
margin: 0px auto;
width: 100px;
height: 100px;
zoom: 1.7;
}
.circular {
-webkit-animation: rotate 2s linear infinite;
animation: rotate 2s linear infinite;
height: 100px;
position: relative;
width: 100px;
}
.path {
stroke-dasharray: 1,200;
stroke-dashoffset: 0;
-webkit-animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
stroke-linecap: round;
}
#-webkit-keyframes rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#-webkit-keyframes dash {
0% {
stroke-dasharray: 1,200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89,200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89,200;
stroke-dashoffset: -124;
}
}
#keyframes dash {
0% {
stroke-dasharray: 1,200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89,200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89,200;
stroke-dashoffset: -124;
}
}
#-webkit-keyframes color {
100%, 0% {
stroke: #d62d20;
}
40% {
stroke: #0057e7;
}
66% {
stroke: #008744;
}
80%, 90% {
stroke: #ffa700;
}
}
#keyframes color {
100%, 0% {
stroke: #d62d20;
}
40% {
stroke: #0057e7;
}
66% {
stroke: #008744;
}
80%, 90% {
stroke: #ffa700;
}
}
I want to create a CSS3 Animation that works on non-webkit browsers and webkit browsers. I included both CSS tags, but it refuses to work on Firefox. It works great on Chrome and Safari. Any ideas?
HTML:
<svg>
<g fill="none" stroke="black" stroke-width="6">
<path stroke-dasharray="10,10" stroke="#000000" stroke-width="4" d="M108.634,309.137c0.19-29.637,0.772-122.891,0.677-140.006c-0.112-20.395,6.424-61.949,66.966-61.949c40.273,0,65.163-0.552,77.294,0c24.892,1.132,34.114-11.41,37.47-19.581"/>
</g>
</svg>
CSS :
#keyframes antsAnimation {
from {
stroke-dashoffset: 100%;
}
}
#-webkit-keyframes antsAnimation {
from {
stroke-dashoffset: 100%;
}
}
svg {
animation: antsAnimation 15s linear infinite;
animation-fill-mode: forwards;
-webkit-animation: antsAnimation 15s linear infinite;
-webkit-animation-fill-mode: forwards;
}
JSFiddle: http://jsfiddle.net/MpLwk/
Thanks again!
I've updated the fiddle. Have a look HERE
It appears that on mozilla you need to have a start and an end for the stroke-dashoffset...
from {
stroke-dashoffset : 100%;
}
to {
stroke-dashoffset: 0%;
}
I think for firefox you will have to specify the following
#-moz-keyframes ANIMATION-NAME {
}
Try This.
#keyframes antsAnimation {
from {
stroke-dashoffset: 100%;
}
}
#-webkit-keyframes antsAnimation {
from {
stroke-dashoffset: 100%;
}
}
#-moz-keyframes antsAnimation {
from {
stroke-dashoffset: 100%;
}
}
svg {
animation: antsAnimation 15s linear infinite;
animation-fill-mode: forwards;
-webkit-animation: antsAnimation 15s linear infinite;
-webkit-animation-fill-mode: forwards;
-moz-animation: antsAnimation 15s linear infinite;
-moz-animation-fill-mode: forwards;
}
You need to call the vendor specific tags