dixonandmoe / rellax

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

How to make rellax positions "predictable"? #241

Open gremo opened 2 years ago

gremo commented 2 years ago

When relax items are on the very top of the page their position is predictable (https://codepen.io/iosystems/pen/VwrVeOV): the three boxes start in the middle of the container.

Example 1

On the contrary, when there is content above the container, rellax items positions is unpredictable (https://codepen.io/iosystems/pen/rNYQeQZ): box 1 and 3 are already outside their container.

Question is: is there any way to say "start in the original position, despite the fact that there is content above it"?

pen2

p-realinho commented 2 years ago

Hi! Have you tried the centering option? You can make all the elements meet their original position when they're crossing the middle of the viewport, or, define a percentage relative to the viewport's height that is where they should meet the original position. Let me know if that helps.