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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [BUG]: Canvas captures scroll even when all scroll-related features are disabled #1360

Open
1 task done
Tracked by #1378
snoozbuster opened this issue Mar 26, 2024 · 13 comments
Open
1 task done
Tracked by #1378
Assignees
Labels
bug Something isn't working

Comments

@snoozbuster
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues and this is a new bug.

Current Behavior

When all scroll behaviors are disabled (pinchToZoom, scrollToZoom, scrollToPan), and a canvas is inserted in a scrolling document, scrolling the page such that the pointer enters the canvas boundaries will immediately halt the scroll

Expected Behavior

Scrolling should not be halted if the scroll event is not used by vue-flow to perform some action

Steps To Reproduce

  1. Disable all scroll-related functionality
  2. Scroll the mouse over the canvas

Relevant log output

No response

Anything else?

My thought is that this code should probably only run and "trap" the event if the handler detects that some action should be performed based on the event and current settings. As it stands this issue can be worked around somewhat by adding nowheel to the entire canvas, but this only works if it's desired that all events are disabled. if the settings are adjusted so that scroll-to-zoom only happens on cmd/ctrl press, then it's not possible to prevent this issue with nowheel.

@snoozbuster snoozbuster added bug Something isn't working triage Awaiting triage labels Mar 26, 2024
@bcakmakoglu
Copy link
Owner

Are you possibly just looking for the preventScrolling prop?

@snoozbuster
Copy link
Contributor Author

could be. I wasn't aware of that prop, is it recent? Let me try it out.

@bcakmakoglu
Copy link
Owner

Not really, has existed for more than a year now but isn't really that well documented 馃槄

@snoozbuster
Copy link
Contributor Author

@bcakmakoglu I don't believe that prop does what I'm looking for. in fact, it doesn't seem to have any effect whatsoever in my app. As a more concrete example, go to https://vueflow.dev/examples/ and add :zoom-on-scroll="false" then place the mouse outside the canvas (above or below it) and try to smoothly scroll the page. if you end a scroll with the mouse over the canvas, all further scrolls get eaten by the canvas even though they aren't used.

In my app, I have a rather thin + wide canvas which is inline on a longer page. so scrolling this page becomes pretty annoying because to a user it seems like their scroll wheel just stops working, since the canvas is stopping all scroll events regardless of whether or not it ends up using them to produce an effect.

@bcakmakoglu
Copy link
Owner

What you describe is exactly the use-case of preventScrolling. You need to set it to false in order for it to not stop scrolling the page when you hit the VueFlow container with a wheel.
It is what's preventing any zoom/pan on scroll when you open vueflow.dev (the top flow with the little buttons to go to different sections of the docs). Otherwise you'd be stuck scrolling in there ^^

@snoozbuster
Copy link
Contributor Author

Ah I see. I was setting it to true. But this still doesn't do exactly what I want - it does allow the page to scroll without interference, but it can't be combined with :zoom-on-scroll="false" and zoom-activation-key-code="Ctrl" in order to have no scroll action by default, but still allow scroll-to-zoom with a modifier. That is what I really want. Is there a way to do that?

@bcakmakoglu
Copy link
Owner

You could track if the Ctrl key is pressed and toggle preventScrolling.

@snoozbuster
Copy link
Contributor Author

snoozbuster commented Mar 28, 2024

I guess, but my point is why should I have to do that? why is the library calling preventDefault on events it doesn't use? preventDefault is intended for use cases where javascript is supplanting the original action with a new one, so surely that would be a better solution. I would have to duplicate quite a bit of the code inside the library relating to OS detection and key defaulting which is quite fragile.

@bcakmakoglu
Copy link
Owner

I see your point I'm just giving workarounds until it's fixed 馃槃

@snoozbuster
Copy link
Contributor Author

ah ok 馃槃 I am ok with waiting for a fix, appreciate it!

@bcakmakoglu
Copy link
Owner

Sorry that this hasn't been fixed yet, I am still talking to the ReactFlow team whether this should be considered a bug or not and we're not 100% clear on this yet 馃槄

@snoozbuster
Copy link
Contributor Author

Ah, I wondered what the hold up was. Is there some counter argument they have? Is the discussion public?

@bcakmakoglu
Copy link
Owner

Not a public discussion no, the hold up is that the devs haven't gotten back to me yet 馃槄
Pinged recently though I'll ask next week again ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants