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

Add a method to enable / disable cooperativeGestures #2057

Closed
raphaelMalie opened this issue Jan 11, 2023 · 7 comments · Fixed by #2152
Closed

Add a method to enable / disable cooperativeGestures #2057

raphaelMalie opened this issue Jan 11, 2023 · 7 comments · Fixed by #2152
Labels
enhancement New feature or request good first issue Good for newcomers PR is more than welcomed Extra attention is needed

Comments

@raphaelMalie
Copy link

Motivation

I have a button on my map to toggle a full screen mode (position:fixed; width+height:100%).

My use case is that I need to have cooperativeGestures enabled when my map is inlined somewhere in my page, but I want to disable it when the full screen mode is enabled.

There is currently no clean way to enable or disable cooperativeGestures programmatically.

This is the dirty way I have to do when I toggle cooperativeGestures :

if (fullscreen) {
	// This part is not optimal, but it's OK
	map._cooperativeGestures = false;

	// This part is really uggly...
	map.handlers._handlersById.touchPan._minTouches = 1;
} else {
	map._cooperativeGestures = true;
	map.handlers._handlersById.touchPan._minTouches = 2;
}

I can live with that, but I won't sleep well 🥲

Design Alternatives

We could have something like that :

map.enableCooperativeGestures();
map.disableCooperativeGestures();

Or (same way than interactions) :

map.cooperativeGestures.enable();
map.cooperativeGestures.disable();

If it's too complicated, please at least improve the part in TouchPanHandler. Instead of computing TouchePanHandler._minTouches in the constructor, compute it on the fly by checking if cooperativeGestures are still enabled or not.

@HarelM
Copy link
Collaborator

HarelM commented Jan 11, 2023

I generally understand the request and agree this is needed.
Can you find something similar that can be toggled on/off in the current API so that this API "feels" the same?
If so, please feel free to submit a PR.
There is also this PR which is waiting for review fixes.
Feel free to push it forward by creating a new PR with it as well if this interest you.
Thanks!

@HarelM HarelM added enhancement New feature or request good first issue Good for newcomers PR is more than welcomed Extra attention is needed labels Jan 11, 2023
@raphaelMalie
Copy link
Author

Thank you for your feedback, I will try to propose a clean PR soon to add this feature.

kevinschaul added a commit to kevinschaul/maplibre-gl-js that referenced this issue Feb 7, 2023
Fixes maplibre#2057

Also disable cooperative gestures in fullscreen, using these new methods
(Fixes maplibre#1488)
@magnolo
Copy link

magnolo commented Feb 10, 2023

i am also looking forward to this feature. But also would be awesome to change the text for the informational screen dynamically. For example if the user changes language.

something like:

map.setCooperativeGestures( boolean | GestureOptions )

a set-named function would feel like to fit to other option updates like setCenter or setMaxBounds

thank you for all your effort

@HarelM
Copy link
Collaborator

HarelM commented Feb 11, 2023

That's an excellent point.

@magnolo
Copy link

magnolo commented Mar 1, 2024

I was really thankfull, that this option was there, but now its gone? So i cant change cooperativeGestures dynamically?

@HarelM
Copy link
Collaborator

HarelM commented Mar 1, 2024

It's in a different place, see changelog.

@magnolo
Copy link

magnolo commented Mar 1, 2024

oh man... thank you thank you for your fast answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers PR is more than welcomed Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants