dixonandmoe / rellax

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

Added "data-rellax-min" and "data-rellax-max". #145

Closed p-realinho closed 5 years ago

p-realinho commented 5 years ago

Added two new data attributes, data-rellax-min and data-rellax-max, that aim to solve #114. I did not implement global options for it (not sure it makes sense, I'll wait for feedback on it).

Also added an example page, with 3 examples.

This can be used by simply passing an integer, that'll serve as cap for the translate. So, for example, let's say we have an element with a speed of -5 and center: true. To stop the element from moving further after reaching the original position, use data-rellax-max="0".

Use both data-rellax-min and max to define a range where the element is "allowed" to move.

The results are probably better with the center option enabled, because the elements go over their original positions more often that way.

(Docs coming soon 😅)

Btw, although very similar to #129, it does not serve the same purpose.