javascript - 沿路径动画脚印

标签 javascript css animation svg

我从这个 pen 得到灵感有动画脚印的地方。我的问题是如何将它与给定的轨迹结合起来,以便脚印沿着路径移动?我的路径是这样的:

<svg id="svg" width="800" height="800">
    <path id="path" d="M130 20 L230 80 L200 100 L170 200"/>
    <image id="footprint" xlink:href="http://icons.veryicon.com/png/System/Icons8%20Metro%20Style/Tracks%20Footprints%20Left%20shoe.png" x="0" y="0" height="50px" width="50px"/>
</svg>

非常感谢您的帮助!

最佳答案

为此,我建议您使用 GREENSOCK ,重量轻,易于使用,充满动画,无论您在场景中需要什么

也许这对你有帮助

<img src="https://res.cloudinary.com/dwr6mqx2g/image/upload/v1489592258/leftfoot_hjajqj.svg" id="leftfoot">
      <img src="https://res.cloudinary.com/dwr6mqx2g/image/upload/v1489592258/rightfoot_fthak3.svg" id="rightfoot">

一些JS

var $rightfoot = $("#rightfoot"),
    $leftfoot = $("#leftfoot");

var tl = new TimelineMax({repeat:-1})



  var ease = SteppedEase.config(5);

tl

  .to($rightfoot, 0.25, {autoAlpha:1,},1)
  .to($leftfoot, 0.25, {autoAlpha:1,},1)
  .to($leftfoot, 3, 

  {bezier:{ curviness: 1, values:[{x:0, y:0},{x:52, y:-25}, {x:97, y:-39}, {x:136, y:-54}, {x:172, y:-83}, {x:197, y:-117},{x:200, y:-163,}],
  autoRotate:90}, ease:ease},1)

  .to($rightfoot, 3, 
  {bezier:{ curviness: 1, values:[{x:0, y:0}, {x:44, y:-13}, {x:97, y:-28,}, {x:134, y:-49,}, {x:166, y:-83,}, {x:182, y:-126,}, {x:176, y:-163,}],
  autoRotate:100}, ease:ease},1.25)

引用

Codepen

致谢珍娜

关于javascript - 沿路径动画脚印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59422176/

相关文章:

javascript - 如何在 Javascript 中将文本复制到剪贴板?

Css 动画关键帧不适用于 Safari 11

html - 水平格式化 DIV

android - 动画和 CPU - 最佳实践?

javascript - js中如何删除div中的元素?

javascript - 开始拖动后删除/隐藏原始拖动

ios - 动画播放与否取决于链接动画的 animationRepeatCount

ios - ScrollView 内的 imageView 上的多个动画

javascript - 如何使用 Google 应用程序脚本通过 Google Business 应用程序获取组织内候选人的日历信息

javascript - 如何将 css 和 javascript 放在公共(public)库/元素中