javascript - stop d3js globe auto rotate -


i have d3js globe , found code auto rotate need code stop rotate. 1 can help? here code.

var rotate = [.001, 0], velocity = [.013, 0], time = date.now();   function rotateglobe() {    d3.timer(function() {     var dt = date.now() - time;     projection.rotate([rotate[0] + velocity[0] * dt, rotate[1] + velocity[1] * dt]);     redraw(); }); }    $(document).ready(function(){    $("#stop").click(function(){      stopglobe()    });     function stopglobe() {        //need stop code here    } });  

you can stop timer timer.stop();:

var rotate = [.001, 0], velocity = [.013, 0], time = date.now(); var timer;//make timer global.  function rotateglobe() {    timer = d3.timer(function() {     var dt = date.now() - time;     projection.rotate([rotate[0] + velocity[0] * dt, rotate[1] + velocity[1] * dt]);     redraw(); }); }    $(document).ready(function(){    $("#stop").click(function(){      stopglobe()    });     function stopglobe() {       timer.stop();    } });  

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -