Skip to content

Commit

Permalink
[src/library_glut.js]: Call motion callbacks only if motion position …
Browse files Browse the repository at this point in the history
…changed ;
  • Loading branch information
prenaux committed Apr 6, 2012
1 parent 7576b2a commit 096b56b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/library_glut.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ var LibraryGLUT = {
},

onMousemove: function(event) {
/* Pierre: Send motion event only if the motion changed, prevents
* spamming our app with uncessary callback call. It does happen in
* Chrome on Windows.
*/
var newX = event['clientX'] - Module['canvas'].offsetLeft;
var newY = event['clientY'] - Module['canvas'].offsetTop;
if (newX == GLUT['lastX'] && newY == GLUT['lastY'])
return;

GLUT.savePosition(event);
if (GLUT.buttons == 0 && event.target == Module["canvas"] && GLUT.passiveMotionFunc) {
event.preventDefault();
Expand Down

0 comments on commit 096b56b

Please sign in to comment.