Skip to content
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

bugfix:outer scroll #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chirpmonster
Copy link

Great project! Our company has used this repository for several years.

However, we have encountered a problem that inner scrolling will trigger outer scrolling. We read the source code of this project and located the problem.

In the project, e.stoppropagation() and e.preventdefault() are used to prevent outer scrolling. And when "hitsBound", the outer scroll is not prevented.

Here is the code

if (Math.abs(deltaY) > Math. abs(deltaX)) {
    hitsBound = isTop || isBottom;
} else {
    hitsBound = isLeft || isRight;
}

However, this leads to a problem. When I roll down on the top, because the first lower roll is "hitBound", the outer roll is not prevented, resulting in the inner and outer roll together.

Another problem is that when the touchpad scrolls, there is a slight offset occasionally, resulting in a momentary deltaY=deltaX. This will cause to judge "isLeft" and "isRight" at that moment. This is a very serious problem, which will lead to the inability to stop the external scrolling at that moment. In fact, our page scrolling up and down is much higher than scrolling left and right. I think that when deltaY=deltaX occurs, we should give priority to scrolling up and down rather than left and right

Here is my modified code

if (Math.abs(deltaY) >= Math. abs(deltaX)) {
    hitsBound = (isTop && deltaY > 0) || (isBottom && deltaY < 0);
} else {
    hitsBound = (isLeft && deltaX > 0) || (isRight && deltaX < 0);
}

Thanks for reading. This problem has brought us some troubles. I also raised a pull request. I hope it can be repaired as soon as possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant