CZML did reach track end callback

1. A concise explanation of the problem you're experiencing.

I need to know when an entity reaches the end of its positions, to trigger some events.
I tried to use range: 'LOOP_STOP', but the animation starts again from the beginning.
I also tried to check if currentTime is greater than endDate, but as CZML is loaded asynchronously, I sometimes have a noticeable difference.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

                var czml = [{
      id : 'document',
      name : 'CZML Path',
      version : '1.0',
      clock: {
        interval: startDate.toISOString() + '/' + endDate.toISOString(),
        currentTime: startDate.toISOString(),
        multiplier: 1,
        range: 'LOOP_STOP',
    }, {
      id : 'path',
      name : 'path data',
      description : 'hike trace',
      availability : startDate.toISOString() + '/' + endDate.toISOString(),
      billboard : {
        image : './data/images/Status/Orange-26x26.png'
      position : {
        epoch : startDate.toISOString(),
        cartographicDegrees :

    var coords = ;
    for (var i=0; i<pathGeojson.geometry.coordinates.length; i++) {
      var currentCoordinates = pathGeojson.geometry.coordinates[i];
      coords = coords.concat(Cesium.Cartographic.fromDegrees(currentCoordinates[0], currentCoordinates[1]));

    var promise = Cesium.sampleTerrainMostDetailed(Cesium.createWorldTerrain(), coords);
    promise.then(function(updatedPositions) {

      for (var i=0; i < pathGeojson.geometry.coordinates.length; i++) {
        var coordinates = [i/timeDivider].concat(pathGeojson.geometry.coordinates[i].slice(0,2).concat(updatedPositions[i].height + 1));
        czml[1].position.cartographicDegrees = czml[1].position.cartographicDegrees.concat(coordinates);

      .then(function() {
          function(currentCZML) {
            viewer.trackedEntity = currentCZML.entities.getById('path');


3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I have a button which will zoom on the first point of a polyline, then load it as a CZML to track it to the end. While the tracking is on, the start button is replaced with a stop button. If the tracking reaches the end before someone clicks the stop button, I want to stop the tracking manually, unload the CZML, and replace the stop button with a start button.

4. The Cesium version you're using, your operating system and browser.

Cesium 1.46, Safari 11.1.1, macOS 10.13.5

You can get the DataSourceClock associated with that DataSource once loaded, and get the stop time from that:

var stop = currentCZML.clock.stopTime;