d3 on click on circle pause and resume transition of marker along line

前端 未结 1 1304
独厮守ぢ
独厮守ぢ 2021-01-23 05:59

I would like help to correct my code to click the marker circle element to pause or resume transition of this element along the line. My code moves marker along a line and I can

1条回答
  •  猫巷女王i
    2021-01-23 06:36

    To check if the circle is moving in the click function use d3.active(), which...

    ... returns null if there is no such active transition on the specified node.

    Like this:

    .on('click', function(d, i) {
        if (d3.active(this)) {
            marker.transition();
            setTimeout(function() {
                pauseValues.lastTime = pauseValues.currentTime;
            }, 100);
        } else {
            transition();
        }
    });
    

    Here is your code with that change:

    
    
    
    
    
    
    
    
    
      
    
      
    

    0 讨论(0)
提交回复
热议问题