giniedp / spritespin

jQuery plugin for spriteanimation.
http://giniedp.github.com/spritespin/
MIT License
377 stars 122 forks source link

'Spin To Frame' method? #46

Closed danhumaan closed 6 years ago

danhumaan commented 6 years ago

Gday,

Thanks for the plugin, it's doing a good job of creating the primary interaction i'm looking for, however i'm looking for a method to trigger the instance to spin all the way back to frame 1. Animate is set to false by default because I don't want it auto spinning.

If there is no 'spin to' method, is there a simple way I could start the auto animate process again?

The scenario I am trying to replicate is this:

  1. Instance has 'cover' image (with other actions overlayed).
  2. User clicks 'explore 360' to fade cover image (and other actions) and enable and focus on spritespin instance
  3. panel has 'close' button to return back to cover image, but I need it to spin back to frame 1 before the cover fades back in.
giniedp commented 6 years ago

yes, you can use the api object which has such a method.

// initialise
$(".container").spritespin({ ... })
// access the api object
$(".container").spritespin("api").playTo(FRAME_NUMBER)

some implemented api methods are here https://github.com/giniedp/spritespin/blob/master/src/api/common.ts#L78

giniedp commented 6 years ago

however, there is no callback (yet) telling you when the playback has reached that frame. You have to track the occuring frame numbers using the onFrame callback

danhumaan commented 6 years ago

Awesome, thanks mate - and totally fine to watch the onFrame to know when it's reached the end point.