Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Parallox scrolling

Hey i am looking for tutorial based on parallox scrolling is there is any good tutorial available on web for parallox scrolling ..

Thanks

1 Answer

I don't know how much JavaScript you know seeing as you only have 36 points here, but here is a very basic run down of how parallax works.

  1. Add an event listener to window object to listen for scroll
  2. On scroll call a function and grab the window objects pageYOffset
  3. Run conditional statements against the pageYOffset
window.addEventListener('scroll', function() {
var yOffset = window.pageYOffset;
if (yOffset >= 300) {
//your code here
}
}