Search code examples
openlayers

How do I know when an olext animation has ended?


I made an animation using Openlayers and olext.

var f = new ol.Feature (new ol.geom.Point(coord));
  f.setStyle (new ol.style.Style({
    image: new ol.style.Circle({
      radius: 18, 
      points: 10,
      stroke: new ol.style.Stroke ({ color: "rgba(0,0,0,1)", width:3 })
    })
  }));
  map.animateFeature(f, new ol.featureAnimation.Zoom({
    fade: ol.easing.easeOut, 
    duration: 1300, 
    easing: ol.easing["easeOut"] 
  }));

However, I don't know when the animation ends.

Is there an animation ending event?

I want to avoid duplicate animations before one animation is finished.


Solution

  • The documentation says there is an animationend event https://viglino.github.io/ol-ext/doc/doc-pages/ol.featureAnimation.html

      var animation = new ol.featureAnimation.Zoom({
        fade: ol.easing.easeOut, 
        duration: 1300, 
        easing: ol.easing["easeOut"] 
      });
    
      animation.on('animationend', function(){
        console.log('animationend');
      });
    
      map.animateFeature(f, animation);