amineyarman / vue-kinesis

Easily create complex interactive animations with Vue.js
https://www.aminerman.com/kinesis/
MIT License
1.48k stars 59 forks source link

Is it possible to initiate an animation programmatically? #47

Open akamaryna opened 3 years ago

akamaryna commented 3 years ago

Hello, thanks for this amazing library!

Is it possible to initiate an animation programmatically? I mean not on mouse move or scroll, but by JS (for example on window load)

Thanks, Maryna

amineyarman commented 3 years ago

Hello, thank you for your feedback :)

At the moment there is no such possibility but we can discuss the idea. The idea behind Kinesis is to move objects based on values that evolve through time (mouse movement, scroll, audio...). So it won't work for, let's say, a tweening between a start and end value. All the intermediate values have to be calculated "manually".

But I'd like to understand your need first. What kind of effect are you trying to achieve? A looping animation? Just a normal tweening animation? Or an animation based on values that you'd pass to what you want to animate (as explained above).

Thank you!

akamaryna commented 3 years ago

Hi Aminerman, Please see how my animation is working on the desktop in the attached gif - it's kinda an eye that is watching the mouse move. On the mobile, I'd like it acts the same but without user interaction. I thought to write few "states" (for example rotateX(10deg)&rotateY(-12deg) and rotateX(12deg)&rotateY(17deg)) and make the button toggle these states when it's in the viewport.

eye-anim

amineyarman commented 3 years ago

Oh I see, that's an interesting idea. That's cool to see what you managed to do :) I'll consider you suggestion. I'll need to think about it. The thing is that if you need to do a looping animation using those "states", you might want to use another animation library, like anime.js or GSAP. But I understand that you might not want to add another dependency just for that. This is why I'll think about it.

amineyarman commented 3 years ago

So after thinking about it here is what I came up with. The idea would be to add a :states prop, but it will work a bit differently than what you suggested. Instead of passing css-like transform properties, the idea would be to pass values ranging from 0 to 1, or 0% to 100%. There are many reasons for that:

It might not all make sense to you, but my goal with this is to keep consistency and the ease of use. I'll give a proper explanation of this, with examples, when it will be implemented.

akamaryna commented 3 years ago

Thanks, that sounds fully reasonable!

joeczar commented 2 years ago

Hi, has there been any progress on this issue? I have a similar use case for mobile that I'd like to fallback to if there is no gyroscope support.