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

Bug and Solution:inner scrolling triggers outer scrolling #136

Open
chirpmonster opened this issue Jun 2, 2022 · 0 comments
Open

Bug and Solution:inner scrolling triggers outer scrolling #136

chirpmonster opened this issue Jun 2, 2022 · 0 comments

Comments

@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

No branches or pull requests

1 participant