X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Finteraction.js;h=a90373754e7bf29d485b42ecc7c083a1dc406bc1;hb=b55a71d768d2f8de62877c32b3aec9e9975ac389;hp=fd50def744f55ded96df06566f82ce8d8f2ec315;hpb=2a3953eb837cf50230d40fb518d0fa9b93ed7c56;p=dygraphs.git diff --git a/gallery/interaction.js b/gallery/interaction.js index fd50def..a903737 100644 --- a/gallery/interaction.js +++ b/gallery/interaction.js @@ -1,3 +1,6 @@ +/*global Gallery,Dygraph,data */ +/*global NoisyData,downV3,moveV3,upV3,clickV3,dblClickV3,scrollV3,restorePositioning,downV4,moveV4,upV4,dblClickV4,captureCanvas */ + Gallery.register( 'interaction', { @@ -41,18 +44,17 @@ Gallery.register( " to mark them.", "

", "
", - "", + "" ].join('\n'); }, run: function() { - // TODO(konigsberg): Add cleanup to remove callbacks. - Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; }); - Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; }); - var g = new Dygraph(document.getElementById("div_g"), + var lastClickedGraph; + document.addEventListener("mousewheel", function() { lastClickedGraph = null; }); + document.addEventListener("click", function() { lastClickedGraph = null; }); + new Dygraph(document.getElementById("div_g"), NoisyData, { errorBars : true }); - var s = document.getElementById("g2_console"); - var g2 = new Dygraph(document.getElementById("div_g2"), + new Dygraph(document.getElementById("div_g2"), NoisyData, { errorBars : true, @@ -69,15 +71,22 @@ Gallery.register( }}); document.getElementById("restore3").onclick = function() { restorePositioning(g3); - } - var g4 = new Dygraph(document.getElementById("div_g4"), - NoisyData, { errorBars : true, drawPoints : true, interactionModel : { - 'mousedown' : downV4, - 'mousemove' : moveV4, - 'mouseup' : upV4, - 'dblclick' : dblClickV4, - }, - underlayCallback : captureCanvas - }); + }; + new Dygraph(document.getElementById("div_g4"), + NoisyData, { + errorBars : true, + drawPoints : true, + interactionModel : { + 'mousedown' : downV4, + 'mousemove' : moveV4, + 'mouseup' : upV4, + 'dblclick' : dblClickV4 + }, + underlayCallback : captureCanvas + }); + }, + clean: function() { + document.removeEventListener('mousewheel'); + document.removeEventListener('click'); } });