Svg path animation on hover - html

I want to use transform property scale on my svg on hover. But when on hover the svg path changes and the animation takes place somewhere else instead of the original path it followed.
html {
background-color: #28505D;
}
svg {
width: 50%;
float: left;
}
#plane:hover {
transform: scale(1.2, 1.2);
}
.planePath {
stroke: #D9DADA;
stroke-width: .1%;
stroke-width: .5%;
stroke-dasharray: 1% 2%;
stroke-linecap: round;
fill: none;
}
.fil1 {
fill: #D9DADA;
}
.fil2 {
fill: #C5C6C6;
}
.fil4 {
fill: #9D9E9E;
}
.fil3 {
fill: #AEAFB0;
}
<svg viewBox="0 0 3387 1270">
<path id="planePath" class="planePath" d="M-226 626c439,4 636,-213 934,-225 755,-31 602,769 1334,658 562,-86 668,-698 266,-908 -401,-210 -893,189 -632,630 260,441 747,121 1051,91 360,-36 889,179 889,179" />
<g id="plane" transform="translate(-248,-306)">
<path id="note" fill="F23B3B" transform="translate(0,0)" d="M248.8,306.8c0,0-24-7-28.5,11c0,0-3,16,21,16.5c0,0,19.5,2.3,18.5-28.8s0-61.2,0-61.2s42,9,19,31.5c0,0,17-1,13.5-23c0,0-7.5-20-43-22L248.8,306.8z" />
</g>
<animateMotion xlink:href="#plane" dur="25s" repeatCount="indefinite" rotate="auto">
<mpath xlink:href="#planePath" />
</animateMotion>
</svg>

It's the translate on your #plane element that is causing the problem. When you scale, the translate is taken into account in the calculations, since you need to scale from a certain point.
Instead of applying transform to your #plane element, you can apply it to the note. So when you add scale on hover you don't have to worry about then translate part. See snippet, I've put the scale to 2, cause it's hard to see 1.2 when it's not moving. But you can set whatever you want, it'll scale without moving.
html {
background-color: #28505D;
}
svg {
width: 50%;
float: left;
}
#plane:hover {
transform: scale(2, 2) ;
}
.planePath {
stroke: #D9DADA;
stroke-width: .1%;
stroke-width: .5%;
stroke-dasharray: 1% 2%;
stroke-linecap: round;
fill: none;
}
.fil1 {
fill: #D9DADA;
}
.fil2 {
fill: #C5C6C6;
}
.fil4 {
fill: #9D9E9E;
}
.fil3 {
fill: #AEAFB0;
}
<svg viewBox="0 0 3387 1270">
<path id="planePath" class="planePath" d="M-226 626c439,4 636,-213 934,-225 755,-31 602,769 1334,658 562,-86 668,-698 266,-908 -401,-210 -893,189 -632,630 260,441 747,121 1051,91 360,-36 889,179 889,179" />
<g id="plane" transform="translate(0,0)">
<path id="note" fill="F23B3B" transform="translate(-248,-306)" d="M248.8,306.8c0,0-24-7-28.5,11c0,0-3,16,21,16.5c0,0,19.5,2.3,18.5-28.8s0-61.2,0-61.2s42,9,19,31.5c0,0,17-1,13.5-23c0,0-7.5-20-43-22L248.8,306.8z" />
</g>
<animateMotion xlink:href="#plane" dur="25s" repeatCount="indefinite" rotate="auto">
<mpath xlink:href="#planePath" />
</animateMotion>
</svg>

Related

CSS Animated Radial Graph overflow after animation SVG

I've encountered a problem when using the css disarray function. The "front" circle clips over after animation has finished and doesnt "Start" at origin point of the animation. After the animation has completed, the filled stroke clips back past the origin point. Can someone Please help me out - I've tried reading up on SVG elements and have fiddled with the code for a few hours now and I still cant get it to animate properly.
Thank you so much for your support. Here is the code I am working with.
.radial-graph-container {
display: flex;
justify-content: center;
flex-direction: column;
padding-bottom: 2.4rem;
}
.radial-graph-container .chart-container .back {
stroke: #101114;
stroke-width: 10;
}
.radial-graph-container .chart-container .front {
stroke: #94d82d;
stroke-width: 15;
stroke-dasharray: 210;
/* Works fine with values above 300 */
transform: rotate(-90deg);
transform-origin: center;
}
.front {
animation: fill 1s reverse;
}
<div class="radial-graph-container">
<svg width="200" height="200" class="chart-container">
<circle cx="100" cy="100" r="90" class="back" fill="none" />
<circle cx="100" cy="100" r="90" class="front" fill="none" />
<g class="graph-center-txt">
<text
x="100"
y="100"
alignment-baseline="central"
text-anchor="middle"
id="percentage-social-media-usage"
>
42%
</text>
</g>
</svg>
<p class="graph-info-txt">
Description Text Here
</p>
</div>
Your animation part was missing: (the #keyframes section)
.radial-graph-container {
display: flex;
justify-content: center;
flex-direction: column;
padding-bottom: 2.4rem;
}
.radial-graph-container .chart-container .back {
stroke: #101114;
stroke-width: 10;
}
.radial-graph-container .chart-container .front {
stroke: #94d82d;
stroke-width: 15;
stroke-dasharray: 210;
/* Works fine with values above 300 */
transform: rotate(-90deg);
transform-origin: center;
}
.front {
animation: fill 1s reverse;
}
#keyframes fill {
0% {
r: 90;
}
100% {
r: 0;
}
}
<div class="radial-graph-container">
<svg width="200" height="200" class="chart-container">
<circle cx="100" cy="100" r="90" class="back" fill="none" />
<circle cx="100" cy="100" r="90" class="front" fill="none" />
<g class="graph-center-txt">
<text
x="100"
y="100"
alignment-baseline="central"
text-anchor="middle"
id="percentage-social-media-usage"
>
42%
</text>
</g>
</svg>
<p class="graph-info-txt">
Description Text Here
</p>
</div>

Trouble making an HTML SVG Splash screen

I'm trying to create an animated splash screen for my APP and I have to do it using SVG, HTML and CSS due to the architecture of the APP.
The first GIF is the designed product which I'm trying to achieve and the second GIF is what I've been able to do.
I need help trying to create that circle effect (I have tried using <circle> but I cant get it to do the effect correctly. I also need to do the zoom in/out of the text and have the background color cover the whole screen.
This is what I have:
#keyframes fill {
0% {
fill: white;
}
50% {
fill: black;
}
100% {
fill: white;
}
}
#jazztel {
fill: white;
animation-name: fill;
animation-duration: 5s;
}
#keyframes colorChange {
0% {
fill: #da1884;
}
50% {
fill: #ffffff;
}
100% {
fill: #ffcd00;
}
}
.box {
fill: #ffcd00;
width: 100%;
height: 100%;
animation: colorChange 5s;
}
#keyframes buttonTransition {
0% {
transform: scale(0);
}
50% {
transform: scale(1);
visibility: none;
opacity: 0;
display: none;
}
100% {
transform: scale(0);
}
}
.innerCircle {
animation-duration: 3s;
animation-name: buttonTransition;
transform-origin: center center;
}
<svg width="100%" height="100%" viewBox="0 0 1131 1247" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect class="box" />
<!--<circle class="innerCircle" cx="50%" cy="50%" r="50%" fill="#FFFFFF" />-->
<path id="jazztel" d="M596.912 674.306V665.289H578.926L598.296 631.994H565.437V641.011H581.693L562.669 674.306H596.912Z" />
<path id="jazztel" d="M670.931 653.497C670.931 646.561 668.856 641.012 664.705 636.503C660.554 632.341 655.02 629.913 648.448 629.913C641.877 629.913 636.688 631.994 632.538 636.503C628.387 640.665 626.312 646.214 626.312 652.803C626.312 659.393 628.387 664.595 632.884 668.757C637.034 672.919 642.568 675 649.14 675C657.442 675 664.013 671.879 668.164 665.636L659.171 661.474C656.404 664.249 652.945 665.636 648.794 665.636C645.681 665.636 642.914 664.942 640.839 663.208C638.764 661.474 637.38 659.046 636.688 655.925H670.931V653.497ZM637.034 646.908C638.072 644.133 639.455 642.399 640.839 641.358C642.914 639.624 645.681 638.931 648.794 638.931C651.561 638.931 653.637 639.624 655.712 641.012C657.787 642.399 659.171 644.48 659.863 646.908H637.034Z" />
<path id="jazztel" d="M687.534 615H676.811V673.96H687.534V615Z" />
<path id="jazztel" d="M528.081 631.994V641.011H544.683L525.314 674.306H559.902V665.289H541.57L560.94 631.994H528.081Z" />
<path id="jazztel" d="M519.433 648.295C519.087 646.908 518.741 645.52 518.05 644.133C516.666 641.359 515.283 638.931 513.207 636.85C511.132 634.769 508.711 633.035 505.944 631.994C504.56 631.301 503.177 630.954 501.793 630.607C500.409 630.26 499.026 630.26 497.296 630.26C494.183 630.26 491.416 630.954 488.995 631.994C487.612 632.688 486.574 633.382 485.536 634.075C484.499 634.769 483.461 635.81 482.423 636.85C481.386 637.89 480.694 638.931 480.002 640.318C478.619 641.705 477.927 642.746 477.581 644.133C476.889 645.52 476.543 646.908 476.197 648.295C475.852 649.682 475.852 651.416 475.852 652.804C475.852 655.925 476.543 658.7 477.581 661.127C478.273 662.515 478.965 663.555 479.656 664.596C480.348 665.636 481.386 666.677 482.077 667.717C483.115 668.758 484.153 669.451 485.19 670.492C486.228 671.185 487.612 671.879 488.649 672.573C491.071 673.613 493.838 674.307 496.605 674.307H519.779V652.804C519.779 651.416 519.433 650.029 519.433 648.295ZM509.748 664.249H497.296C495.913 664.249 494.529 663.902 493.146 663.208C492.454 662.862 491.762 662.515 491.416 662.168C490.725 661.821 490.379 661.127 489.687 660.781C489.341 660.087 488.649 659.74 488.303 659.047C487.958 658.353 487.612 657.659 487.266 656.966C486.574 655.578 486.228 654.191 486.228 652.457C486.228 651.763 486.228 650.723 486.574 650.029C486.574 649.336 486.92 648.642 487.266 647.948C487.612 647.255 487.958 646.561 488.303 645.867C488.649 645.174 488.995 644.827 489.687 644.133C490.379 643.44 490.725 643.093 491.416 642.746C492.108 642.399 492.8 642.052 493.146 641.705C494.529 641.012 496.259 640.665 497.642 640.665C498.334 640.665 499.372 640.665 500.064 641.012C500.755 641.012 501.447 641.359 502.139 641.705C503.522 642.399 504.906 643.093 505.944 644.48C506.981 645.521 508.019 646.908 508.711 648.295C509.057 648.989 509.402 649.682 509.402 650.376C509.402 651.07 509.748 652.11 509.748 652.804V664.249Z" />
<path id="jazztel" d="M469.972 615.693H458.903V655.924C458.903 655.924 458.903 659.739 458.557 660.78C458.212 662.861 457.174 663.901 455.444 663.901C453.023 663.901 450.256 662.167 447.489 658.699L439.534 666.676C444.03 672.225 449.564 675 455.79 675C458.903 675 461.67 674.306 463.746 672.919C466.513 671.185 468.242 668.41 469.28 664.595C469.626 662.514 469.972 659.046 469.972 654.19V615.693Z" />
<path id="jazztel" d="M616.281 631.647V615.693H605.559V638.93L605.213 640.664H605.559V674.306H616.281V640.664H622.507V631.647H616.281Z" />
</svg>
Ive managed to solve all my problems, below you can find the snippet of the working version.
I removed my <rect> tag and instead created a <div> to wrap the SVG and added a background to that to solve the problem where the background was not filling up the whole screen.
To solve the zoom issue on the text what I did was implemented a transform: scale(x) to the same div mentioned above instead of the text which are several paths (if applied to the path it wouldnt do the effect correctly). So instead of zooming in and out on the text the effect is like if I had a painting in my hand and I brought it closer to your face.
And last is the <circle> effect. I removed the background color in the HTML tag and added it to the #keyframes in CSS.
#keyframes textColorChange {
0% {
fill: white;
}
50% {
fill: black;
}
100% {
fill: white;
}
}
#jazztel {
fill: white;
animation-name: textColorChange;
animation-duration: 5s;
}
#keyframes bgColorChange {
0% {
background-color: #da1884;
transform: scale(1);
}
50% {
background-color: #ffffff;
transform: scale(1.5);
}
100% {
background-color: #ffcd00;
transform: scale(1);
}
}
.splashBackground {
background-color: #ffcd00;
width: 100%;
height: 100%;
animation: bgColorChange 5s;
}
#keyframes circleTransition {
0% {
transform: scale(0);
fill: #FFFFFF;
}
50% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
.innerCircle {
animation-duration: 3s;
animation-name: circleTransition;
transform-origin: center center;
}
<div class="splashBackground">
<svg width="100%" height="100%" viewBox="0 0 1131 1247" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle class="innerCircle" cx="50%" cy="50%" r="50%" />
<path id="jazztel" d="M596.912 674.306V665.289H578.926L598.296 631.994H565.437V641.011H581.693L562.669 674.306H596.912Z" />
<path id="jazztel" d="M670.931 653.497C670.931 646.561 668.856 641.012 664.705 636.503C660.554 632.341 655.02 629.913 648.448 629.913C641.877 629.913 636.688 631.994 632.538 636.503C628.387 640.665 626.312 646.214 626.312 652.803C626.312 659.393 628.387 664.595 632.884 668.757C637.034 672.919 642.568 675 649.14 675C657.442 675 664.013 671.879 668.164 665.636L659.171 661.474C656.404 664.249 652.945 665.636 648.794 665.636C645.681 665.636 642.914 664.942 640.839 663.208C638.764 661.474 637.38 659.046 636.688 655.925H670.931V653.497ZM637.034 646.908C638.072 644.133 639.455 642.399 640.839 641.358C642.914 639.624 645.681 638.931 648.794 638.931C651.561 638.931 653.637 639.624 655.712 641.012C657.787 642.399 659.171 644.48 659.863 646.908H637.034Z" />
<path id="jazztel" d="M687.534 615H676.811V673.96H687.534V615Z" />
<path id="jazztel" d="M528.081 631.994V641.011H544.683L525.314 674.306H559.902V665.289H541.57L560.94 631.994H528.081Z" />
<path id="jazztel" d="M519.433 648.295C519.087 646.908 518.741 645.52 518.05 644.133C516.666 641.359 515.283 638.931 513.207 636.85C511.132 634.769 508.711 633.035 505.944 631.994C504.56 631.301 503.177 630.954 501.793 630.607C500.409 630.26 499.026 630.26 497.296 630.26C494.183 630.26 491.416 630.954 488.995 631.994C487.612 632.688 486.574 633.382 485.536 634.075C484.499 634.769 483.461 635.81 482.423 636.85C481.386 637.89 480.694 638.931 480.002 640.318C478.619 641.705 477.927 642.746 477.581 644.133C476.889 645.52 476.543 646.908 476.197 648.295C475.852 649.682 475.852 651.416 475.852 652.804C475.852 655.925 476.543 658.7 477.581 661.127C478.273 662.515 478.965 663.555 479.656 664.596C480.348 665.636 481.386 666.677 482.077 667.717C483.115 668.758 484.153 669.451 485.19 670.492C486.228 671.185 487.612 671.879 488.649 672.573C491.071 673.613 493.838 674.307 496.605 674.307H519.779V652.804C519.779 651.416 519.433 650.029 519.433 648.295ZM509.748 664.249H497.296C495.913 664.249 494.529 663.902 493.146 663.208C492.454 662.862 491.762 662.515 491.416 662.168C490.725 661.821 490.379 661.127 489.687 660.781C489.341 660.087 488.649 659.74 488.303 659.047C487.958 658.353 487.612 657.659 487.266 656.966C486.574 655.578 486.228 654.191 486.228 652.457C486.228 651.763 486.228 650.723 486.574 650.029C486.574 649.336 486.92 648.642 487.266 647.948C487.612 647.255 487.958 646.561 488.303 645.867C488.649 645.174 488.995 644.827 489.687 644.133C490.379 643.44 490.725 643.093 491.416 642.746C492.108 642.399 492.8 642.052 493.146 641.705C494.529 641.012 496.259 640.665 497.642 640.665C498.334 640.665 499.372 640.665 500.064 641.012C500.755 641.012 501.447 641.359 502.139 641.705C503.522 642.399 504.906 643.093 505.944 644.48C506.981 645.521 508.019 646.908 508.711 648.295C509.057 648.989 509.402 649.682 509.402 650.376C509.402 651.07 509.748 652.11 509.748 652.804V664.249Z" />
<path id="jazztel" d="M469.972 615.693H458.903V655.924C458.903 655.924 458.903 659.739 458.557 660.78C458.212 662.861 457.174 663.901 455.444 663.901C453.023 663.901 450.256 662.167 447.489 658.699L439.534 666.676C444.03 672.225 449.564 675 455.79 675C458.903 675 461.67 674.306 463.746 672.919C466.513 671.185 468.242 668.41 469.28 664.595C469.626 662.514 469.972 659.046 469.972 654.19V615.693Z" />
<path id="jazztel" d="M616.281 631.647V615.693H605.559V638.93L605.213 640.664H605.559V674.306H616.281V640.664H622.507V631.647H616.281Z" />
</svg>
</div>
https://jsfiddle.net/ty6qwcnm/

Using linear-gradient in an animation on CSS

I'm working on a mobile first project, it's a project on with HTML and CSS only, allowing us to learn how to do animation with CSS only. I have a problem with my project that I hope you can help me with.
I am trying to fill the hearts with a linear-gradient color instead of the ##9356DC I am using in my code. Problem is, each time I am using the linear-gradient, the heart doesn't fill with any color anymore.
Thanks in advance for all the help you can provide to me!
.icon {
fill: transparent;
stroke: black;
stroke-width: 50;
cursor: pointer;
position: absolute;
right: 1.5rem;
bottom: 2rem;
}
.icon svg {
overflow: visible;
width: 1.6rem;
}
.icon .heart-main:active path {
animation: fill-animation 1.5s ease-in-out forwards;
stroke: #9356DC;
}
#keyframes fill-animation {
10% {
fill: #9356DC;
}
80% {
fill: #9356DC;
}
100% {
fill: #9356DC;
}
}
<div class="icon">
<svg class="heart-main" viewBox="0 0 512 512" width="100" title="heart">
<path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z" />
</svg>
</div>
To fill linear-gradient, you will have to add linearGradient node inside the definitions section of your SVG file like below: (Read More about Linear Gradient)
<defs>
<linearGradient id="FillGradient" gradientTransform="rotate(90)">
<stop offset="2%" stop-color="#FFF" />
<stop offset="95%" stop-color="#9356DC" />
</linearGradient>
</defs>
Make sure you are adding id attribute which is going to be used in CSS to fill the gradient like below:
#keyframes fill-animation {
0%{
fill-opacity: 0.1;
}
10% {
fill: url(#FillGradient);
fill-opacity: 0.1;
}
80% {
fill: url(#FillGradient);
fill-opacity: 1;
}
100% {
fill: url(#FillGradient);
fill-opacity: 1;
}
}
You can remove the fill-opacity and of course change the color of gradient in linearGradient node as per your need.
See the working Snippet below: (I have commented few styles just to make it big and clear)
.icon {
fill: transparent;
stroke: black;
stroke-width: 50;
cursor: pointer;
/* position: absolute;
right: 1.5rem;
bottom: 2rem;*/
}
.icon svg {
overflow: visible;
width: 5.6rem; /* changed from 1.6 to 5.6 */
}
.icon .heart-main:active path {
animation: fill-animation 1.5s ease-in-out forwards;
stroke: #9356DC;
}
#keyframes fill-animation {
0%{
fill-opacity: 0.1;
}
10% {
fill: url(#FillGradient);
fill-opacity: 0.1;
}
80% {
fill: url(#FillGradient);
fill-opacity: 1;
}
100% {
fill: url(#FillGradient);
fill-opacity: 1;
}
}
<div class="icon">
<svg class="heart-main" viewBox="0 0 512 512" width="300" title="heart">
<path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z" />
<defs>
<linearGradient id="FillGradient" gradientTransform="rotate(90)">
<stop offset="2%" stop-color="#FFF" />
<stop offset="98%" stop-color="#9356DC" />
</linearGradient>
</defs>
</svg>
</div>
you could use my code
#keyframes value {
0%{background-image: linear-gradient(90deg, red, purple, green);}
25%{background-image: linear-gradient(90deg, orange, yellow,blue);}
50%{background-image: linear-gradient(90deg, black, grey, white);}
100%{background-image: linear-gradient(90deg,lime,violet,magenta);}
}
then use
.icon{
animation-name: value;
animation-duration: 50s;
animation-iteration-count: infinite;
}
you could use background-image instead of fill and if that doesn't work you could use color instead.
i hope i helped but i am pretty new to css myself.

SVG arrow wrong sync animation

why doesn't the arrow start along with the line?
Is it not synchronized?
I would like the arrow to leave together with the line.
.box{
width:100%;
padding:0px;
background-color: black;
}
.squiggle {
stroke-dasharray: 498.181;
stroke-dashoffset: 498.181;
animation: draw 10s linear infinite;
}
#keyframes draw {
from {
stroke-dashoffset: 498.181;
}
to {
stroke-dashoffset: 0;
}
}
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=5">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<body>
<div class="box">
<svg xmlns="http://www.w3.org/2000/svg" id="svg1" viewBox="0 0 215 66" preserveAspectRatio="xMidYMid meet">
<g id="layer1" transform="translate(-68.19229,10.180375)">
<g id="g38" transform="matrix(0.26458333,0,0,0.26458333,54.727655,-107.07271)">
<g>
<path id="path22" class="squiggle"
style="fill:none;
stroke:orange;
stroke-width:3px;
stroke-linecap:butt;
stroke-linejoin:miter;
stroke-opacity:1"
d="M 653.40952,459.58095 C 539.70759,242.15840999999995 379.43686,703.6978899999999 252.34286,526.62857"/>
<use href="#path22"/>
<path fill="red" d="M -9.5357143,-9.9107143 10,0 -10,10 -3.3928571,-0.17857143 Z">
<animateMotion dur="10s" repeatCount="indefinite" rotate="auto">
<mpath href="#path22"/>
</animateMotion>
</path>
</g>
</g>
</g>
</svg>
</div>
</body>
</html>
look at this, This may be helpful:
#desc {
max-width: 700px;
margin-top: 100px;
color: #b3b3b3;
font-size: 11px;
font-family: sans-serif;
}
#desc li {
margin-bottom: 1em;
}
#desc p {
padding: 20px 0 0 40px;
}
#doubled-separate {
width: 110px;
}
#doubled-separate #over-path {
fill: none;
stroke-dasharray: 150;
stroke-dashoffset: 0;
animation: 10s reveal linear infinite forwards;
}
#keyframes reveal {
50%, 100% {
stroke-dashoffset: 150;
}
}
#separate-marker {
width: 88px;
position: relative;
top:-4px;
}
#separate-marker .just-line {
fill: none;
stroke-dashoffset: 0;
animation: 10s reveal2 linear infinite forwards;
}
#keyframes reveal2 {
100% {
stroke-dashoffset: 150;
}
}
#doubled-separate-marker {
width: 110px;
}
#doubled-separate-marker .over-path {
fill: none;
stroke-dasharray: 150;
stroke-dashoffset: 0;
animation: 3s reveal3 linear infinite forwards;
}
#keyframes reveal3 {
50%, 100% {
stroke-dashoffset: 150;
}
}
#doubled-separate-marker-2 {
width: 110px;
}
#doubled-separate-marker-2 #arrow3 path {
opacity: 0;
animation: 10s revealarrow linear infinite forwards;
}
#keyframes revealarrow {
0%, 50% {
opacity: 0;
}
60%, 100% {
opacity: 1;
}
}
#doubled-separate-marker-2 .over-path {
fill: none;
stroke-dasharray: 150;
stroke-dashoffset: 0;
animation: 10s reveal4 linear infinite forwards;
}
#keyframes reveal4 {
50%, 100% {
stroke-dashoffset: 150;
}
}
#separate-marker-2 {
width: 88px;
position: relative;
top:-4px;
}
<svg viewBox="0 0 44 97" preserveAspectRatio="xMinYMin meet" id="separate-marker-2">
<defs>
<marker id="arrow4" viewBox="0 0 13 13" refX="11" refY="8" markerWidth="13" markerHeight="13" markerUnits="userSpaceOnUse" orient="auto-start-reverse" preserveAspectRatio="xMinYMin meet">
<path d="M3.66332316,0.125850427 L3.75090984,0.194245468 L12.2529105,7.89856961 C12.6592041,8.26674392 12.5414228,8.91869993 12.063138,9.1358919 L11.9627228,9.17332054 L0.963626457,12.4383634 C0.566538833,12.5562375 0.149079906,12.3298902 0.0312058479,11.9328025 C-0.0768453724,11.5688056 0.10434498,11.187691 0.441152309,11.0359066 L0.536766731,11.0003819 L10.2568836,8.11360225 L2.74367477,1.30576583 C2.46464034,1.05291103 2.41998014,0.63794112 2.62313708,0.333974789 L2.69153212,0.246388115 C2.94438692,-0.0326463148 3.35935683,-0.0773065179 3.66332316,0.125850427 L3.66332316,0.125850427 Z" fill="#B3B3B3" fill-rule="nonzero"></path>
</marker>
</defs>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g transform="translate(1.000000, 1.000000)">
<path d="M31.6194299,0 C-0.925516514,8.99255645 -7.90071768,47.4229255 8.63466801,71.535115 C9.41568622,72.6740094 10.2491558,73.7809605 11.1348599,74.8513572" class="just-line" stroke="#B3B3B3" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4" marker-end="url(#arrow4)">
<animate attributeName="d" from="M31.6194299,0 C-0.925516514,8.99255645 -7.90071768,47.4229255 8.63466801,71.535115 C9.41568622,72.6740094 10.2491558,73.7809605 11.1348599,74.8513572" to="M31.6194299,0 C-0.925516514,8.99255645 -7.90071768,47.4229255 8.63466801,71.535115 C15.4626235,81.4917594 26.2993953,89.006995 41,91" dur="1.5s" repeatCount="indefinite"/>
</path>
</g>
</g>
</svg>
<div id="desc">
<ol>
<li>Line and arrowhead are two paths grouped together, with an identical (but wide and white) line path on top that animates to reveal.</li>
<li>Line path with arrowhead path attached as a marker. dash-offset animates on line path to add movement.</li>
<li>Fusion of 1 and 2. Line path with arrowhead as marker, white line path animating on top. Shows that path+marker connection is much smoother than path+path, and that butt linecaps create a smoother animation finish than square or round (although it required moving the white path start-point a step or two to cover the marker).</li>
<!-- figuring out CSS animation on an SVG marker was a JOURNEY -->
<li>Adaptation of 3. The arrowhead SVG marker has CSS animation applied. Since it doesn't appear until after the line path is fully visible, the white line path on top has a narrower stroke since it doesn't need to cover the marker. The animation timings are synced up via keyframe percentages.</li>
<li>native SVG animate!</li>
</ol>
<p>DISCLAIMER: honestly no idea about browser support for any of this</p>
</div>

marker-end not getting displayed

I have a following html:
<div id="divVis2" class="divVis">
<svg width="1540" height="345">
<defs>
<marker id="normal" viewBox="0 -5 10 10" refX="15" refY="-1.5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M0,-5L10,0L0,5"></path>
</marker>
<marker id="anomaly" viewBox="0 -5 10 10" refX="15" refY="-1.5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M0,-5L10,0L0,5"></path>
</marker>
</defs>
<g>
<path class="anomaly" marker-end="url(#anomaly)" d="M908.3739002256449,176.0182689704716L661.9527686239043,249.64760217208658"></path>
<path class="normal" marker-end="url(#normal)" d="M660.4045373167714,246.37428873149702L879.5700343222044,98.59473202412175"></path>
<path class="normal" marker-end="url(#normal)" d="M878.0019325543491,95.25420149730667L631.216835426003,167.4248240636326"></path>
</g>
<g>
<g transform="translate(889.5195255254339,91.88595979689137)">
<circle class="normal" r="12"></circle>
<text x="0" y="4" class="normal">133</text>
</g>
<g transform="translate(619.6992424549181,170.7930657640479)">
<circle class="normal" r="12"></circle>
<text x="0" y="4" class="normal">134</text>
</g>
<g transform="translate(650.4550461135419,253.0830609587274)">
<circle class="anomaly" r="12"></circle>
<text x="0" y="4" class="normal">137</text>
</g>
<g transform="translate(919.8716227360072,172.5828101838308)">
<circle class="normal" r="12"></circle>
<text x="0" y="4" class="normal">136_1</text>
</g>
</g>
</svg>
</div>
Its corresponding css is:
#divVis2 path {
fill: none;
/* stroke: #666; */
stroke-width: 0.5px;
}
#divVis2 path.normal {
stroke: #808080;
}
#divVis2 path.anomaly {
stroke: red;
stroke-width: 1.5px;
}
/* for the marker */
#divVis2 #normal {
fill: black;
stroke-width: 0.5px;
}
#divVis2 #anomaly {
fill: red;
stroke-width: 1.5px;
}
#divVis2 circle.normal {
fill: #ccc;
stroke: #ffffff;
stroke-width: 0.5px;
}
#divVis2 circle.anomaly {
fill: #ff0000;
stroke: #ffffff;
stroke-width: 0.5px;
}
#divVis2 text.normal {
font: 7px sans-serif;
pointer-events: none;
fill: black;
text-anchor:middle;
}
#divVis2 text.label {
font: 9px sans-serif;
pointer-events: none;
fill: blue;
text-anchor:middle;
}
The corresponding output in browser is:
Why are the arrows not getting displayed at the end of each path? I am unable to find out the problem in css selectors.
Here is a jsfiddle: http://jsfiddle.net/onh7t53o/
#divVis2 path {
fill: none;
/* stroke: #666; */
stroke-width: 0.5px;
}
has a higher specificity for the markers than
#divVis2 #normal {
fill: black;
stroke-width: 0.5px;
}
so the marker paths are fill="none" and the stroke-width is so thin because the markers are small that you can't see it.
I had this problem in an angular app that was using a <base> tag. In the context of a rich web app like one built on Angular, where you need to set the <base> tag to make HTML5-style navigation work, it can get messy to try to fix that in a permanent way.
In my case, the app I was working on was showing a SVG-based interactive diagram builder that would change the app url as I selected elements therein.
What I did was to add a global event handler that would fix all url(#...) inline styles in any <path> element found in the page:
$rootScope.$on 'fixSVGReference', ->
$('path').each ->
$path = $ this
if (style = $path.attr 'style')?
$path.attr 'style', style.replace /url\([^)#]*#/g, "url(#{location.href}\#"
Then trigger this handler in key places, like when the app state changes (I'm using ui-router)
$rootScope.$on '$stateChangeSuccess', ->
$timeout (-> $rootScope.$emit 'fixSVGReference'), 5
As well as anywhere where I know there'd be new/updated paths like these. Here, the $timeout thing is to account for the fact that the DOM nodes really are changed asynchronously sometime after the $stateChangeSuccess event is triggered.