[SOLVED] Photo Swipe Behavior

Hello,
I would like to write a function to manage this effect:
https://photoswipe.com/#&gid=1&pid=3

My dream is to create a function with this capability:
crate a sprite with n animations (manually)
associate the new “PhotoSwipe” Behavior
Automatically the function generate two images: oe the right of the main and one on the left and hide them. Then when you swape the function manage the sprite movements like the site example.

My questions are:

  • how to know how many animations has a sprite ?
  • how to hide a portion of sprite ?

Do you know a better solution ?

Thanks,
J

I don’t know if your first question is possible. (I’m not saying it isn’t, I just literally don’t know).
For the second question, I’d recommend using the “Mask” extension from the extensions list.

If you don’t want to write manually how many animations has a sprite, maybe you can trick with a loop, like: change animation to x, check if animation is x, x+=1.
To hide portion of a sprite, you need to put another sprite on top, I guess. Or crop the sprite with javascript, I suppose it’s possible.

1 Like

If you set the sprites per animation manually, you might as well give the object a variable framecount

Thanks, it works:

1 Like

Perfect, I didn’t know the function.
Now I have all the ingredients to write the algorithm

Thanks,
J