0

i am new to using svg.js. I want to animate an element from it's original position to a second position and back to the original position and loop that process. What's the bets wa for achieving this?

Thanks in advance

RacoonOnMoon
  • 1,556
  • 14
  • 29

1 Answers1

1

//Edit: Just use the loop() method to loop animations

For longer animation chains you need the following solution:

For svg v2.x it is not really possible in a build-in way. You can write a function which sets the whole animation chain up and call it after the animation finished (with the afterAll() method)

In svg v3.x you can setup a timeline and move in time to replay animations. You can read more on this in this answer: How can i use timelines in version svg.js 3.x

Fuzzyma
  • 7,619
  • 6
  • 28
  • 60
  • I am not sure if i explained myself very well. I just need to move an object from A to B than back to A and that with loop() . Is there a simple way to do this – RacoonOnMoon Mar 31 '19 at 10:53
  • Yes, loop(true, true) – Fuzzyma Mar 31 '19 at 11:22
  • Scissors.animate(1000, '-').move(25, 260).move(25, 250).loop(true, true) ? Does not work. AM i doing sthing wrong? – RacoonOnMoon Mar 31 '19 at 11:47
  • Only one move command is needed. The object then moves force and back between initial position and position specfied in love. You can see example codes in the docs :) – Fuzzyma Mar 31 '19 at 11:49