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

draggable markers on mobile also drag map with first drag #497

Open
Valid opened this issue Jan 17, 2018 · 6 comments
Open

draggable markers on mobile also drag map with first drag #497

Valid opened this issue Jan 17, 2018 · 6 comments

Comments

@Valid
Copy link

Valid commented Jan 17, 2018

I thought this was an issue with my own implementation, but I noticed that this happens on the 'switch style' demo as well.

When you first press/drag, it drags the point as well as the map, but every subsequent drag only drags the marker as desired. This happens on my Android Pixel XL as well as my iPhone 7.

@Valid Valid changed the title draggable markers on mobile also map with first drag draggable markers on mobile also drag map with first drag Jan 17, 2018
@alex3165
Copy link
Owner

Hey @Valid Could you confirm this is still happening with react-mapbox-gl version 3.8.0, we did massive changes on the event logic around drag events for Feature component. In the meantime I opened an issue to improve the demo website to be mobile friendly so that it is easier to test things on mobile: #535

@MadalenaGoncalves
Copy link

I can confirm that this is still an issue in version 3.8.0, as I am trying to go around it somehow.
My idea is to create an overlay div with the pin pointing to the center of the map, and just move the map instead of the pin. I wont even be using a Layer or a Marker, since these move with the map. Just plain position:absolute on an image. But in this case, I also need a way to deal with a shifted map center (mapbox/mapbox-gl-js#1740)
Any suggestions to overcome these issues or to a better solution for my case?

@aratcliffe
Copy link

I'm also experiencing this issue with 3.8.0.

@aratcliffe
Copy link

I found that the source of the problem for me was the safari window bouncing behaviour on iOS. Using iNoBounce fixed this for me.

@cristian-calugar
Copy link

We also experience this issue with version 4.8.6. It seems that map.dragPan.disable() / map.dragPan.enable() is not called in case of touchstart/touchend events on layers with draggable features.

@olso
Copy link

olso commented Jan 31, 2021

Still an issue

but fix is "easy"

<MapFeatureRenderer
                  draggable
                  onDragEnd={handleDragEnd}
                  onDragStart={handleDragStart}
const handleDragStart = React.useCallback<
    NonNullable<MapFeatureRendererProps["onDragStart"]>
  >(() => {
    if (mapRef.current) {
      mapRef.current.dragPan.disable();
    }
  }, []);
const handleDragEnd = React.useCallback<
    NonNullable<MapFeatureRendererProps["onDragEnd"]>
  >(() => {
    if (mapRef.current) {
      mapRef.current.dragPan.enable();
    }
  }, []);

thx @cristian-calugar

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

No branches or pull requests

6 participants