-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Track popup to cursor [ready] #7786
Conversation
I'm trying to imagine a use case for this on mobile. It seems like it would be a very awkward UX as compared to simply touching on each new point to see a new popup. On the other hand, having a desktop only API method seems odd. Do we have other methods that don't work on mobile? If we do enable this on
This is a fun consequence. Maybe there needs to be a separate action to close the popup in this case. Would clicking the map to toggle the popup be too weird? |
Mobile handlingIn lieu of hover, I thought about adding cursor-tracked popups to a tap on the map. The interaction pattern for mobile is unfortunately quite complex: Other changes
|
Peter If you remove the touchscreen support how can we show the user information about the |
@KravMaguy that is correct, you will lose that functionality if you use a cursor-tracked popup on mobile. In these contexts, most apps display the information in a panel separate from the map: it's a much better practice given the limited screen space, and preserves visibility/interactivity of the map itself. some examples ⬇️ |
@KravMaguy you can still |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think overall it looks fine but I think the behavior is a little odd.
-
If you move the mouse quickly enough, you can end up inside the popup. I'm not entirely sure what the answer here could be, if anything.
-
The cursor partially obscures the "spout" of the popup when it's top-aligned. Perhaps we should add a bit of padding to the cursor to move it down a bit and/or make the cursor into a pointer instead of the grabber hand.
-
If you pan the map, the popup stays in one spot. Maybe on pan, the popup should close? I could see that being unexpected though.
👍the popup should definitely follow the cursor
Unfortunately this looks like a limitation of the browser, in that it emits mousemove events too slowly to keep up with the mouse's actual movement. Not sure if we can do anything here
Agree that this is weird, but the specific solution seems like it would vary by user/use case/preference. I'm inclined to let people modify CSS as appropriate. |
👍 I do think it makes sense to change the cursor from a grabber to a pointer when in |
|
Also removed interactivity with pointer-tracked popups, to avoid getting trapped in it 👍 |
a2f2290
to
a48f50f
Compare
a48f50f
to
6c7c5cf
Compare
Is this likely to make it into a release in the near future? We'd like to use this feature rather than the workarounds in #7777 |
@Plantain this branch is ready to the extent that I can tell -- looping in some reviewers to see if we can get this across the line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple minor things but this looks good to me
This is too late to be in the next release of GL JS which comes out this week, but it should be in May's release |
91a250f
to
2cd4525
Compare
clarified a bit of the code per #7786 (comment) and squashed as much as I can (not sure if I can squash past a previous pull from master?) |
You don't have to squash ahead of time @peterqliu. Once all the checks have passed, just pressing the |
ticket: #7777
Adds a method
.trackPointer()
to the Popup API that repositions the popup to the mouse cursor on every mousemove event, and hides/shows the popup when cursor leaves/enters the map. Mutually overwritable with.setLngLat
.Design
Opted not to extend setLngLat, as it doesn't quite fit those words. Also opted not to extend the popup
options
object, for cases when users need to change behavior after adding to map.Launch Checklist
@mapbox/studio
and/or@mapbox/maps-design
if this PR includes style spec changes