Skip to content

Commit

Permalink
feat: conditional positioning based on event pixel
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Aug 31, 2023
1 parent bc406b9 commit ff2ab75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion elements/map/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
id: "selectInteraction",
overlay: {
element: "eox-map-tooltip",
offset: [0, 30],
},
condition: "pointermove",
layer: {
Expand Down
5 changes: 5 additions & 0 deletions elements/map/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export async function addSelect(
selectStyleLayer.changed();

if (overlay) {
const xPosition =
event.pixel[0] > EOxMap.offsetWidth / 2 ? "right" : "left";
const yPosition =
event.pixel[1] > EOxMap.offsetHeight / 2 ? "bottom" : "top";
overlay.setPositioning(`${yPosition}-${xPosition}`);
overlay.setPosition(feature ? event.coordinate : null);
if (feature && (<EOxMapTooltip>tooltip).renderContent) {
(<EOxMapTooltip>tooltip).renderContent(feature.getProperties());
Expand Down
4 changes: 2 additions & 2 deletions elements/map/src/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export class EOxMapTooltip extends TemplateElement {
: html` <style>
ul {
margin: 0;
padding: 15px 5px 15px 30px;
padding: 15px 15px 15px 30px;
background: #0008;
border-radius: 15px;
color: white;
max-width: 50%;
max-width: 250px;
font-size: small;
}
span {
Expand Down

0 comments on commit ff2ab75

Please sign in to comment.