0

I’m using Vue-Leaflet + Leaflet to display dynamic CircleMarkers whose styling depends on reactive Vue state.

When a marker enters the list, it should fade in via CSS.

When it leaves the list, it should get a fade-out class, animate, and only be removed afterwards.

This works except for one thing:

the fade-out animation never plays — the marker disappears instantly, even though the correct CSS class is applied.

Here’s how the markers are rendered:

<LCircleMarker
  v-for="item in displayItems"
  :key="item.url"
  :lat-lng="[item.lat, item.long]"
  :radius="6"
  :class-name="[
    'map__circle-marker',
    item._fadeOut ? 'map__circle-marker--fadeout' : 'map__circle-marker--fadein'
  ].join(' ')"
  :color="'#FE581B'"
  :fill-color="'#000'"
  :fill-opacity="1"
  :layerType="'overlay'"
  :pane="'markerPane'"
>
  <LPopup>...</LPopup>
</LCircleMarker>

EDIT: Here is the CSS

.map__circle-marker {
  animation-name: map-marker-in;
  animation-duration: 15s;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
  opacity: 0;
  pointer-events: all !important;
}

@keyframes map-marker-in {
  0% {
    stroke-width: 50;
  }

  20% {
    stroke-width: 3;
    opacity: 1;
  }

  100% {
    opacity: 1;
  }
}

.map__circle-marker--fadeout {
  animation: fadeout-marker 30s forwards;
  opacity: 1;
}

@keyframes fadeout-marker {
  0% {
    opacity: 1;
  }

  20% {
    opacity: 0.6;
  }

  90% {
    opacity: 0.2;
    stroke-width: 3;
  }
  
  100% {
    opacity: 0;
    stroke-width: 0;
  }
}
New contributor
Arne Witteler is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 1
    Can you add the css of your fade out animation? Commented 2 days ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.