Is there a way to update the `to` coordinates of an animation?
kurtextrem opened this issue · 2 comments
kurtextrem commented
E.g. I'm calling the tween function whenever the X/Y coordinates have been updated. This may mean though, that the previous animation doesn't finish fast enough. So the from
stays the same, but the to
changes. Is this supported here, or would you recommend a different lib?
jeremyckahn commented
Hi @kurtextrem! There's no API in Shifty to specifically achieve what you're describing, but I think you could get the results you're looking for by doing something like the following:
- Keep track of the
timeElapsed
value in your tween'sstepFunction
- Calling
.stop()
on your tween when theto
orfrom
data changes - Start a new tween with the updated
to
andfrom
data .seek
to the latesttimeElapsed
value of the previous tween.resume
the tween
I haven't tried this myself so it may need a bit of adjusting. Other libraries might have a better API for this, though I don't which one would be the best to recommend to you.
kurtextrem commented
Thank you. Will try that out.