Skip to content

Collapsible header question #6668

Answered by MatiPl01
Veeksi asked this question in Q&A
Nov 6, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hey!

Your code looks correct. One thing, I wonder if you need this if ... else if logic. It seems that the only difference is the way in which you calculate and apply the scrollDifference.

In the first case, you calculate scrollDifference as currentY - previousScrollY.value and then, subtract it from the headerOffset.value, which gives you headerOffset.value - (currentY - previousScrollY.value), which is the same as headerOffset.value + previousScrollY.value - currentY

The result is the same in the second case, when you calculate scrollDifference as previousScrollY.value - currentY and then, add the result to headerOffset.value. You get headerOffset.value + previousScrollY.value - currentY,…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Veeksi
Comment options

Answer selected by Veeksi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants