dixonandmoe / rellax

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

Feature request: Allow setting of breakpoint-specific speed values in JavaScript #227

Open dnywh opened 3 years ago

dnywh commented 3 years ago

Hi,

Rellax is great. Thanks for making it. I've just got a feature request that would reduce the amount of markup I need to write:

As well as setting breakpoint-specific speed values in HTML, could default breakpoint-specific speeds be set in JavaScript?

For example, instead of writing the below for multiple HTML elements that share the same speed value across breakpoints:

<div
 class="rellax"
 data-rellax-xs-speed="1.25" 
 data-rellax-mobile-speed="3"
 data-rellax-tablet-speed="5"
 data-rellax-desktop-speed="10">
    Stuff here
</div>

<!-- Repeat the above for each element that shares the same speed values -->

...could there be defaults set in the accompanying JavaScript like so:

const rellax = new Rellax(".rellax", {
    // This already works to set a default speed value to anything with the class ".relax"
    speed: 3,
    // This below doesn't work but would be nice to have
    xsSpeed: 1.25,
    mobileSpeed: 3,
    tabletSpeed: 5,
    desktopSpeed: 10
});

Thanks!