首页 > 解决方案 > 我如何知道 olext 动画何时结束?

问题描述

我使用 Openlayers 和 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"] 
  }));

但是,我不知道动画什么时候结束。

有动画结束事件吗?

我想在一个动画完成之前避免重复的动画。

标签: openlayers

解决方案


文档说有一个animationend事件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);

推荐阅读