X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Finteraction.js;fp=gallery%2Finteraction.js;h=a90373754e7bf29d485b42ecc7c083a1dc406bc1;hb=ce31caf22475e3e1fd6d9fea192d61ff4fcd7fac;hp=5936189f363d78dea5ef2c69623a3f70288d98ba;hpb=a4c3ece0a11e4e5c4f1f51a8bc8b7878d34ee052;p=dygraphs.git diff --git a/gallery/interaction.js b/gallery/interaction.js index 5936189..a903737 100644 --- a/gallery/interaction.js +++ b/gallery/interaction.js @@ -50,9 +50,8 @@ Gallery.register( }, run: function() { var lastClickedGraph; - // TODO(konigsberg): Add cleanup to remove callbacks. - Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; }); - Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; }); + document.addEventListener("mousewheel", function() { lastClickedGraph = null; }); + document.addEventListener("click", function() { lastClickedGraph = null; }); new Dygraph(document.getElementById("div_g"), NoisyData, { errorBars : true }); new Dygraph(document.getElementById("div_g2"), @@ -85,5 +84,9 @@ Gallery.register( }, underlayCallback : captureCanvas }); + }, + clean: function() { + document.removeEventListener('mousewheel'); + document.removeEventListener('click'); } });