Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery设置SVG填充的动画?_Javascript_Jquery_Animation_Svg - Fatal编程技术网

Javascript 使用jquery设置SVG填充的动画?

Javascript 使用jquery设置SVG填充的动画?,javascript,jquery,animation,svg,Javascript,Jquery,Animation,Svg,我正在尝试使用jQuery来设置SVG路径的动画,然后在第一个动画完成后,使用持续时间和缓和功能设置SVG填充的动画 这可能吗 $(function() { $('svg').hover(function() { $(this).find('.social-circle').stop() .animate({'stroke-dashoffset': 0}, 1000, 'easeOutBounce') .css('fill', '#f4321e');

我正在尝试使用jQuery来设置SVG路径的动画,然后在第一个动画完成后,使用持续时间和缓和功能设置SVG填充的动画

这可能吗

$(function() {
  $('svg').hover(function() {
    $(this).find('.social-circle').stop()
      .animate({'stroke-dashoffset': 0}, 1000, 'easeOutBounce')
      .css('fill', '#f4321e');
      console.log('on');
  }, function() {
    $(this).find('.social-circle').stop()
      .animate({'stroke-dashoffset': 900}, 1000, 'easeOutBounce')
      .css('fill', 'none');
  });
});

谢谢你的时间

一种方法是使用CSS转换(*),但您需要使
填充:透明
,而不是
填充:无
,如下(1):

$(函数(){
$('svg').hover(函数(){
$('svg').find('.social circle').stop()
.animate({'stroke-dashoffset':0},1000)
.css({'fill':'red','transition':'fill 1s});
console.log('on');
},函数(){
$('svg').find('.social circle').stop()
.animate({'stroke-dashoffset':900},1000)
.css({'fill':'transparent','transition':'fill 1s});
});
})


可以。jQuery不制作颜色动画,但jQuery UI和各种插件都可以。或者你可以使用或@Mi creative,是的,我已经尝试过了,但它没有制作动画。当你说“这可能吗?”我以为你没有尝试就问了,这个why@adeneo-仍然不知道如何使用它进行颜色填充,可能是使用
element.classList.add('newclass')
@Mi creative-我见过它们,但在查看Snapsvg时,我没有找到任何好的文档或示例。Il checkout GSAP。