Openlayers 4 添加动画 Pause/Continue 功能?

Openlayers 4 Adding Animation Pause/Continue Functionality?

我正在使用开放层 4。我正在移动和停止标记动画作为 this 示例,没有任何问题。但我也想为标记添加暂停和继续功能。我编辑了一些变量并努力解决这些函数的问题。当我首先调用 continueAnimation 函数时,elapsedTime 参数变为负数并在 moveFeature 函数上给出异常。当我第二次调用 continueAnimation 函数时。它按预期工作。它看起来像是某种 javascript 实施问题。

 function pauseAnimation() {
            animating = false;
            //I hold elapsed time globally
            var index = Math.round($("[id='rightfrm:tbv1:txt1']").val() * elapsedTime / 1000);
            (geoMarker.getGeometry()).setCoordinates(line_coordinates[index].lc);
            map.un('postcompose', moveFeature);
        }

 function continueAnimation() {
    animating = true;
    now = new Date().getTime();
    now = now - 10000 + elapsedTime; // --10000-- for negativeness
    geoMarker.setStyle(null);
    map.on('postcompose', moveFeature);
    map.render();
 }

我发现了我的问题。这是一个逻辑错误。暂停并立即继续工作。

now = new Date().getTime() - elapsedTime;

任何人都可以将这些函数用于 Pause/Continue 功能。