-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Dead space when using ParallaxLayer speed property #962
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
Comments
I'm seeing a related issue, though my perspective of it is a little bit different. I described what I was seeing in #1019 but I could also summarize it as a huge vertical gap between layers around If I set I will investigate further tomorrow. |
I think that the problem I'm seeing is related to this line, where the viewport height is factored in twice. Setting I'm trying to deduce exactly what this logic should be, but I'm unsure. I realized that it isn't exactly clear what the number Can anyone clarify how |
I have a proposed fix for this issue. That fix, along with making sure that the last layer has a speed of 0 and an appropriate offset (so that it will be positioned at the bottom of the page), resolved my issues. The last layer being positioned at the bottom of the page isn't necessarily required, but since it is a footer in my case, it should be all the way at the bottom. |
Just a note about what I learned about |
this was causing some elements to have an extra viewport height gap. see issue for more details. fixes pmndrs#962
I believe that I am running into this issue. Has anyone been able to find a fix for it yet? |
Same issue here. |
I am also encountering this issue. The problem can replicated on the codesandbox linked in the official docs: https://codesandbox.io/s/h1rrv EDIT: Thanks for the work, loving the library 👍 . |
I think your spending of a large time with a single problem helped me! Thanks a lot brother! @localjo |
After trying to figure out the different threads 1422, 962, 1023,... |
I have figured out the problem!It's not actually a problem.It's the way how to speed function works.When we use it, to give give the effect, it slows down the component (on scroll)...This is how it works! |
Oh, all right. |
Can you share me your code?Perhaps in Codepen?Or here? |
This is the code for a YouTube tutorial. |
Do meant by the empty space?So here's something you are looking for:- The offset is the page you are currently viewing (you can also think it as the page number or component number)... When you are slowing down a speed and the offesets are different,one page(or component) is bring slowed down, and to make the effect you are also making next offset fast, so one is slow another is fast therefor a empty space is being created,This is the way it works... I hope as far ny knowledge os concerned,it will help you...Inform me after you are done with it! I would love to see your result 🙌 |
Everything you tell me seems logical and works in resolution lower than 2k. |
I think giving it a background color might solve the problem... That can be a solution...😕 |
Thank you so much for your help ! |
Did it work?That's great! |
🐛 Bug Report
Using an ParallaxLayer with a non-zero
speed
creates a dead space in which it is impossible to position the layer (no matter itsoffset
value).It seems to me that it is a maths problem occuring here and here (more explanations in the repro).
To Reproduce
See the explained codesandbox demo below.
Expected behavior
Being able to vertically align a layer at any height, not matter its
speed
.Link to repro (highly encouraged)
https://codesandbox.io/s/withered-sun-zqbh3
Seeing the behaviour requires you to open the sandbox as a full page app (https://zqbh3.csb.app/)
The repro has one 2-pages Parallax element, with 3 ParallaxLayers inside - yellow, cyan and blue - each having a
speed
of 0.1.With this configuration, the layers original positions are at:
transform: translate3d(0px, 900px, 0px);
transform: translate3d(0px, 1000px, 0px);
(the browser rounds this value to an entire pixel, the actual result should be 999.999999)transform: translate3d(0px, 1100px, 0px);
The consequence of this is: I am able to create layers between yellow and cyan (i.e. between 900px and 1000px) with offsets from 0.9 to 0.9999...99999 BUT I am unable to create layers between cyan and blue (i.e. between 1000px and 1100px) because there is no actual value between 0.9999...99999 and 1.
The code responsible for translating
offset
andspeed
of a layer to an actual height in pixels is the following (see links above):Seems to me that⚠️ seems from what I tested, and I am definitely not very confident with maths).
Math.floor
is the problem. Removing it seems to remove the dead space (The codesandbox has a
parallax.js
which does not contain anyMath.floor
for you to try.Environment
react-spring
v8.0.27react
v16.13.1The text was updated successfully, but these errors were encountered: