pixelcog / parallax.js

Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin
MIT License
3.53k stars 838 forks source link

Parallax image does not move when elements are removed that changes its position #227

Closed onebigcelt closed 6 years ago

onebigcelt commented 6 years ago

We have been creating an ad bar that shows above the website. When the user clicks the X to remove the ad the bar disappears and the header moves back up to the normal starting position.

If you notice in the images below the parallax image does not realign when the page changes now that div has been hidden. If I refresh the page manually it resets and displays the way it should.

It's almost like the parallax window remembers where it should be based on where it was on the page even though the containing div has moved. here is my code

`

Connect with new customers

` (before removing banner) ![image](https://user-images.githubusercontent.com/20730890/33092249-95be014e-cec7-11e7-9ff3-8cb78feff16d.png) (after removing banner) ![image](https://user-images.githubusercontent.com/20730890/33092160-5213a1c4-cec7-11e7-8bd2-cb1556a9651c.png)
wstoettinger commented 6 years ago

due to performance reasons, the library calculates some variables only on window resize. Try adding the following code after the banner has been hidden jQuery(window).trigger('resize').trigger('scroll');

should work!

onebigcelt commented 6 years ago

Dude! That fixed it! Works flawless no delay or jump!

wstoettinger commented 6 years ago

good to hear! :)