dixonandmoe / rellax

Lightweight, vanilla javascript parallax library
https://dixonandmoe.com/rellax/
MIT License
7.06k stars 878 forks source link

Change direction? #166

Open aolko opened 5 years ago

aolko commented 5 years ago

Is it possible to change the direction of movement without changing the speed?

p-realinho commented 5 years ago

Hey. Thanks for using the plugin.

I believe changing the speed is the only way to control the direction of movement (if we're not talking about changing axis, just direction).

Wouldn't inverting the speed number achieve what you want? For example, if you're element has a speed of -3, changing it to 3 would change the direction while keeping the same speed.

Let me know if that works for you.

aolko commented 5 years ago

right, but can it be implemented for 4 cardinal directions independently of speed?

p-realinho commented 5 years ago

I'm not sure I understand your question correctly and I'll be honest here, I'm not entirely up-to-date with some of the features, but, I believe wherever there's a speed, you can invert it to make it go the other way. This goes for vertical and horizontal parallax.

I understand you do not wanna change the speed, just the direction, but, if you invert the speed's value, the element will keep the same exact speed but will travel in the opposite direction.

Now, in case you wanna make it travel horizontally instead of (the default) vertically, for example, you'd have to follow the readme (sorry, I can't help much with that part, I never used it myself). But then, the same principle would apply. To make it go, for example, left to right instead of right to left, you'd just need to invert the speed's value.

(Someone correct me if I'm spreading fake news here, please, thanks lol)

Play around with those settings a bit and let me know how it goes.