Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Only generate hexagons after a mouse movement has been detected
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed May 18, 2014
1 parent eb9ba5a commit 59a5b70
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/resources/javascript/main.js
Expand Up @@ -73,6 +73,19 @@
profiledRenderer();
}

function onMouseDetector(callback) {
var hoverDetected = false,
hoverDetectorFunction = function() {
if (!hoverDetected) {
hoverDetected = true;
document.removeEventListener("mouseover", hoverDetectorFunction);
callback.call();
}
};

document.addEventListener("mouseover", hoverDetectorFunction);
}

var run = oneAtATimePlease(generateAndRender);

window.addEventListener("resize", function() {
Expand All @@ -85,5 +98,5 @@
}
});

run();
onMouseDetector(run);
}());

0 comments on commit 59a5b70

Please sign in to comment.