dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
283 stars 34 forks source link

Make eventsIfTopMost also work for manageHoverState, and introduce #71

Closed dabreegster closed 9 months ago

dabreegster commented 9 months ago

openIfTopMost for Popups.

This PR does two separate things: 1) Make the existing eventsIfTopMost option also apply to setting hover state 2) Introduce a new openIfTopMost for Popups that works the same way

The existing demo page is extended to show all of this:

https://github.com/dimfeld/svelte-maplibre/assets/1664407/2c2046cc-1034-45eb-bde9-42fedab0a67e

changeset-bot[bot] commented 9 months ago

🦋 Changeset detected

Latest commit: a29734df528aff6417635c456640e7133ead759d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------- | ----- | | svelte-maplibre | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 9 months ago

Someone is attempting to deploy a commit to a Personal Account owned by @dimfeld on Vercel.

@dimfeld first needs to authorize it.

dabreegster commented 9 months ago

A bug I'm not sure how to fix: if one layer has hoverCursor and another doesn't, as you transition between overlapping features for the two, the cursor isn't un-set when it should be

vercel[bot] commented 9 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-maplibre ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2023 1:27am
dabreegster commented 9 months ago

I rebased, adding in the sourceLayer fix to one spot.

This is imperfect with the hoverCursor problem, but I think it's a good enough start

dimfeld commented 9 months ago

I would need to try it but I think adding

      if (hoverCursor) {
        $map.getCanvas().style.cursor = hoverCursor;
      }

into the mousemove handler in Layer.svelte would fix the hoverCursor thing.

dimfeld commented 9 months ago

I left a comment above about the default value for openIfTopMost. Curious to get your thoughts on that but after that I think this is good to go.

dabreegster commented 9 months ago

I fixed the cursor behavior, and updated the example. The green layer has no cursor set, to demonstrate why it's necessary to reset to the empty string sometimes too. Now the cursor should always match the layer being hovered on.

Thanks for the help with the CSS alignment and tip about the cursor fix!

dimfeld commented 9 months ago

Looks good. Thank you again!