I have svg picture and I would like to animate stroke color:
I have tried this but nothing happen:
$(".svg-path").animate('stroke','blue')
It works when I set property directly without animating it:
$(".svg-path").attr('stroke','blue')
Is it possible to do that?
Solved.
I forgot to add hook to support other css properties:
jQuery.Color.hook( "stroke" );
Then
$(".svg-path").animate({
'stroke': 'blue'
}, 200);
works pretty well!
An alternative, quite convenient, is to specify the animation within the CSS, as so:
$(".svg-path").css({'stroke': 'blue', transition: "0.2s"});
I noticed you cannot use .animate()
to change fill color, but .css()
with transition
works fine for fill color as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.