I’ve been looking at many many many paralax tutorials, there’s been way too much complication for what I actually need to achieve, and I’m sure there’s some tricky yet easier way without plugins to do it.
Basically, All i want to do is have for example..
A rocket ship. On a space background. And when the user scrolls down, the rocket ship would scroll at say double or half the speed of the scroll. in x or y? Does anyone have any ideas?
Sure. I’ve got lots of ideas. This doesn’t sound overly complicated.
Create a variable outside of the scope of the function. give it a name like
last_position, give it a value of0.Now capture the scroll event.
Now, capture the distance we travel from the top on scroll. Save this variable into the last_position variable, and create an if statement.
No, within those if statements, use
.animate()to set thetop & leftdistances respectively. Calculate with whatever math you’d like to achieve your desired effect. It’s important to note you’ll want to.stop()each animation before you call it again. If you don’t…well, you’ll see why..Try it out yourself.