Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallax effect only for elements in viewport? #67

Closed
envieme opened this issue Jul 24, 2017 · 8 comments
Closed

Parallax effect only for elements in viewport? #67

envieme opened this issue Jul 24, 2017 · 8 comments

Comments

@envieme
Copy link

envieme commented Jul 24, 2017

I am having a newsfeed with images+titles below them like Flipboard. I am applying the parallax effect to the images just like Flipboard app. And after trying many plugins, rellax is doing the best job for all its simplicity and lightweight.

But am wondering how to make the parallax effect run only when elements come into viewport. This will be helpful to make the effect more pronounced as right now at the default of -2 speed and 0.5 rellax percentage, the images in the bottom of the feed, when they come into the viewport, are way off from their respective titles.

@envieme
Copy link
Author

envieme commented Jul 25, 2017

I am sorry for posting this. I did figure out I had to change my HTML a bit to prevent lazyloading of images and it works beautifully now! Thank you for the plugin.

But is there a way to make it work with lazy loading images that have rellax applied to them? What happens is the first time a page loads and the images in the bottom of the feed are displaced by quite a bit when they come into viewport. But the second refresh of the same page renders them properly. So I am guessing it has to do with size information regarding the images?

@envieme envieme closed this as completed Jul 25, 2017
@envieme envieme reopened this Jul 25, 2017
@p-realinho
Copy link
Contributor

Hey. Thanks for using the plugin :)

If you're loading all the image at once I think the solution for #52 could work for you.
If you're using lazy-loading, infinite scrolling, etc, you'll probably have to wait for #62 to get implemented. 😕

@johanneslamers
Copy link

Would be awesome if the parallax items stop transforming if they are out of the viewport. That would make this script much lighter and faster. No more unnecessary calculations and paints.

@moeamaya
Copy link
Member

This is conceptually a great idea, but ultimately doesn't work in practice.

Because parallax by definition depends on your vertical scroll position, it doesn't make sense to not do the calculation on scroll. Even with 1,000 rellax elements, an iphone 5s doesn't stutter at all, so if your website is having performance issues I'd suggest optimizing elsewhere.

@johanneslamers Since we're using requestAnimationFrame and the elements are out of the viewport, painting is negligible.

@functionandform
Copy link

I may have gotten confused with this... but surely parallax relative to the viewport is essential? If I have a large page, then anything at the bottom of the page is going to end up being complete out of place by the time you scroll to its position. is there another way of achieving this?

@moeamaya
Copy link
Member

@toddpadwick Yup, we have the centering: true feature which centers your element in the viewport when you scroll to that point.

@functionandform
Copy link

haha I knew I'd got something wrong somehow as it seemed odd not having it. Thanks @moeamaya . Great plugin... so many over bloated or abandoned parallax plugins out there and also very few seem to have a good destroy function which was the main reason I chose yours. 👍

@moeamaya
Copy link
Member

Hey no worries glad you picked us! Feel free to email or tweet us when you launch your parallax project, we'll promote it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants