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

Draw interferes dragPan.disable() #654

Closed
rvratner opened this issue Jun 8, 2017 · 15 comments
Closed

Draw interferes dragPan.disable() #654

rvratner opened this issue Jun 8, 2017 · 15 comments
Labels
bug ui Buttons & user interactions

Comments

@rvratner
Copy link

rvratner commented Jun 8, 2017

mapbox-gl-js version: 0.37
mapbox-gl-draw version: v0.17.4

Steps to Trigger Behavior

  1. Load map.
  2. Load Draw control
  3. map.drapPan.disable()

Expected Behavior

User can't drag pan the map

Actual Behavior

Map is able to be dragpanned

If you comment out the
var draw = new MapboxDraw({
displayControlsDefault: false,
controls: {
polygon: true,
trash: true
}
});
You are able to disable dragPan as expected

@Elefantz
Copy link

Hi,

Same problem here. Did you find a workaround ?

Thanks,

@rvratner
Copy link
Author

No, I never did - was hoping to hear from the folks who developed this to see if they had any insight?

@mcwhittemore
Copy link
Contributor

Ah! I keep hoping to have time to really dive into this. Sorry.

@mcwhittemore
Copy link
Contributor

OK. I took a quick look. This bug is happening in simple_select and direct_select but not that drawing modes. This makes me guess that we're enabling dragPan as some part of these two modes. I don't have much time right now to dive in deeper, but maybe that bit of info can help others push on this a bit.

@rvratner
Copy link
Author

rvratner commented Aug 1, 2017

Thanks, appreciate you looking into it. Let me know if there's anything I can do on my end?

@mcwhittemore
Copy link
Contributor

@rvratner - If you have time to debug this a bit and make a PR when you find a solution that would be great.

Here are the three places Draw calls dragPan.disable() in these two modes.

I'd work on this by starting the debug page and adding some logging to the modes.

holyblader2010 added a commit to holyblader2010/mapbox-gl-draw that referenced this issue Oct 4, 2017
holyblader2010 added a commit to holyblader2010/mapbox-gl-draw that referenced this issue Oct 4, 2017
holyblader2010 added a commit to holyblader2010/mapbox-gl-draw that referenced this issue Oct 4, 2017
@GadyTal
Copy link

GadyTal commented Sep 13, 2018

Any solution?

@GadyTal
Copy link

GadyTal commented Sep 20, 2018

In my case, this issue affected the draggable markers on my map, which prevents them from being dragged due to the fact that the dragPan option can't be disabled which is required for dragging markers. (see https://www.mapbox.com/mapbox-gl-js/example/drag-a-point/)

Workaround

On marker's 'mouseenter' event we should prepare the markers for drag by changing the draw mode to draw_polygon (which doesn't cause the error) -
placeDraw.changeMode('draw_polygon');

then, on 'mouseleave' fired we change it back to simple_select.
placeDraw.changeMode('simple_select');

@amirhossein1414
Copy link

amirhossein1414 commented Dec 17, 2019

MyWorkaround

I solved this problem by modifying mapbox-gl-draw.js file.
I searched for "dragPan.enable()" statement and delete it from mapbox-gl-draw.js file.
If you dont want to delete it entirely, you can wrap "dragPan.enable()" in an if clause so you can
check the mapboxgl interaction option and then call dragPan.enable().

@kkaefer kkaefer added bug ui Buttons & user interactions and removed bug-confirmed labels Jan 7, 2020
@john-melin
Copy link

john-melin commented Jul 6, 2020

This is still an issue. Is this looked being looked at?
@kkaefer

I belive it should work if when setting dragPan.enable(), you only do this if dragPan is not previously disabled.

MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Sep 20, 2020
MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Sep 20, 2020
MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Sep 20, 2020
@wandongming
Copy link

any update?

@whatoeat2night
Copy link

any update

MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Nov 7, 2021
MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Nov 7, 2021
MauPalantir pushed a commit to MauPalantir/mapbox-gl-draw that referenced this issue Nov 7, 2021
@IlariaCallegari
Copy link

Hi there, is there any update on this? Mapbox-draw is still interfering with dragPan. Any chance you'll merge PR #1191 ?

@tredpath
Copy link

This problem affects more than just dragPan. I tried the work around suggested here which does fix dragPan but doubleClickZoom is still a problem. If you double click on the map it won't zoom immediately but it will re-enable both dragPan and doubleClickZoom.

In order to disable interactions I had to remove the draw control from the map when I wanted to disable interactions and add it back in when I wanted to re-enable them.
map.removeControl(drawControl).

stepankuzmin added a commit that referenced this issue Jul 1, 2024
* #654 retaining dragPan state for simple_select, direct_select, and setup

* #654 further limiting direct_select to only re-enable dragPan when direct_select has disabled it

* #654 further limiting simple_select to only re-enable dragPan when direct_select has disabled it

* refactor: applied suggestions

---------

Co-authored-by: holyblader2010 <[email protected]>
Co-authored-by: Stepan Kuzmin <[email protected]>
@stepankuzmin
Copy link
Contributor

Hey all! Thanks for the discussion. This is done at #1216 and will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ui Buttons & user interactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.