For each of these options, you can set the Lottie playback to play on the initial interaction and then play the reverse on the second interaction.
To apply triggers that will be dependent on the displayed viewport or page state, you can check out the ‘Page trigger’ options. The same steps apply to those as well. To learn more, you can check out
Webflow’s course on After Effects and Lottie.
Thank you for reading and happy animating!