appleple / backpax

Simple JavaScript Library to add parallax image to background-image
https://appleple.github.io/backpax/
MIT License
16 stars 1 forks source link

Initialize transform position on load #36

Open stefaaan opened 2 years ago

stefaaan commented 2 years ago

I have a problem when I use the parallax on the top of the page. When the page loads the transform attribute isn't added to the parallax window, this makes for shaky movement. When you to scroll it adds (in my case) 160px to the scrolling position. How can i fix this or can you update the app so it initializes when the backbax function is called

https://user-images.githubusercontent.com/10194127/164673524-1609d394-01f2-4953-8052-3a9a92cd3af1.mp4

.

magic-77 commented 2 years ago

Hi @stefaaan same problem here too. as a workaround i found this solution

.parallax-element {
    div[style*="position: absolute"] {
        transform: translateY(-50%);
    }
}

but it may be that you still notice a very small offset

BenjaminBeck commented 2 months ago

Or like this:

let instance = new Backpax('.imageparallax');
window.onload = function() {
    instance.run();
}
magic-77 commented 2 months ago

@BenjaminBeck works as expected with "instance.run()"; Thank you! Maybe it would be good to update the doc for other user.