nk-o / jarallax

Parallax scrolling for modern browsers
https://jarallax.nkdev.info
MIT License
1.39k stars 214 forks source link

Jarallax Element : Different speed on responsive #150

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello,

Is it possible to define different speed for different breakpoints in responsive design.

for example, in full HD data-jarallax-element="100" is quite slow, but with a tablet or a phone, this is huge.

The best would be able to use something like that : data-jarallax-element="100" data-jarallax-element_w960="50" (which means the speed is reduced for screen with width smaller than 960px), or even data-jarallax-element_h600="50" which means the speed is reduced to 50 for screen with height smaller than 600px)

What do you think about it ? Or maybe it's already handled and I miss something in the doc ?

Best regards,

Alex

nk-o commented 5 years ago

Hi Alex.

I don't think I will try to improve this code to be responsive. But the solution could be like this:

  1. Subscribe to window resize event
  2. Find elements with responsive options, that meet the current screen size
  3. Destroy these elements
  4. Init these elements with new options

p.s. Maybe better to use another library for elements animations. This script is really strong https://github.com/alexfoxy/laxxx

ghost commented 5 years ago

Thank you for your answer, I will give a try to the repo you mention. I liked the fact that jarallax handle all kind of parallax (image, background, element) and I'm little disappointed to have 2 module to handle this, but I understand that what I ask probably represent a big amount of work.

I will still use jarallax for background cause it just perfectly do the job, in a very simple way, congratulation ! :)