SVG路径动画

1 篇文章 0 订阅

直接贴图和代码吧!

圆点动画

<svg width="350" height="200">
      <path d="M10 80 Q 77.5 10, 145 80 T 280 80" stroke="yellow" stroke-width="2" fill="transparent"></path>
      <circle cx="0" cy="0" r="2" fill="red">
          <animateMotion
                  path="M10 80 Q 77.5 10, 145 80 T 280 80"
                  dur="5s"
                  begin="1s"
                  fill="remove"
                  rotate="auto"
                  repeatCount="indefinite"
          >
          </animateMotion>
      </circle>
</svg>

圆点动画

水珠流动

<svg width="250" height="250">
     <path d="M10 80 H 100 V 200 H 10" stroke="orange"  stroke-linecap="round"  stroke-width="10" fill="transparent"></path>
     <rect width="6" height="2" rx="2" ry="2" fill="red" stroke-width="1" stroke="red" v-for="i in 20">
         <animateMotion
                 path="M10 80 H 100 V 200 H 10"
                 dur="10s"
                 :begin="1+(i - 1)*0.5+'s'"
                 fill="remove"
                 rotate="auto"
                 repeatCount="indefinite"
         >
         </animateMotion>
     </rect>
</svg>

水珠流动

水流

<svg width="250" height="250">
      <path d="M10 80 H 100 V 200 H 10" stroke="orange"  stroke-linecap="round"  stroke-width="10" fill="transparent"></path>
      <path d="M10 80 H 100 V 200 H 10" stroke="red" stroke-dasharray="320" stroke-dashoffset="0" stroke-linecap="round" stroke-width="10" fill="transparent">
          <animate attributeType="CSS" attributeName="stroke-dashoffset" from="320" to="0" dur="5s" repeatCount="indefinite"/> 
      </path>
</svg>

水流

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue是一种流行的JavaScript框架,它可以方便地创建可交互的用户界面。在Vue中,使用SVG路径动画可以实现各种有趣的效果。 首先,要在Vue项目中使用SVG路径动画,需要安装vue-svg路径动画扩展。可以通过运行`npm install vue-svg-path-animation`命令来安装。 一旦安装完成,就可以在Vue组件中使用SVG路径动画了。首先,需要在Vue组件中引入`vue-svg-path-animation`模块。然后,可以在组件的`data`选项中创建一个属性来存储SVG路径。这个属性可以在`<svg>`元素的`d`属性中使用。 接下来,可以使用Vue的生命周期钩子函数来触发SVG路径动画。例如,在`mounted`钩子函数中可以使用`setPath`方法来更新SVG路径属性,从而触发动画。可以在该钩子函数中设置一定的延迟,以便动画效果更加明显。 除了在`mounted`钩子函数中触发动画,还可以根据需要在其他钩子函数中实现动画效果。例如,在`created`钩子函数中初始化SVG路径属性,然后在`beforeDestroy`钩子函数中清除SVG路径属性,以停止动画。 在Vue组件中使用SVG路径动画可以为用户提供一种更加丰富和吸引人的交互体验。通过使用Vue的生命周期钩子函数和`vue-svg-path-animation`扩展,可以轻松地实现各种有趣的SVG路径动画效果。这不仅可以使用户界面更加生动,还可以提高用户对网站或应用程序的参与度和满意度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值