danday74
danday74

Reputation: 57166

Popmotion end a tween immediately and jump to the end of the tween

I've got a simple tween:

const grass = styler(/* some element */)
const from = +grass.get('opacity')
const tweener = tween({from, to: 0, duration: 5000, ease: easing.linear}).start(v => grass.set('opacity', v))

How do I make it jump to the end of the tween and then stop tweening immediately? For example, in this case, jump to 0 opacity and stop tweening? I know I can do:

grass.set('opacity', 0)
tweener.stop()

but I believe there is a more natural solution. Something like:

tweener.jumpToEndAndStop()

Upvotes: 0

Views: 86

Answers (1)

danday74
danday74

Reputation: 57166

Based on https://code.tutsplus.com/tutorials/introduction-to-popmotion-part-1-tween--cms-30431 I think this is what I want:

tweener.seek(1)
tweener.stop()

Upvotes: 0

Related Questions