Permalink
Browse files

Add an s2e mouse move event

  • Loading branch information...
rhburrows committed Jul 12, 2011
1 parent 7d9d9fc commit ca297a581ee7d7bd2849ae076e93d25eaa1dc547
Showing with 19 additions and 0 deletions.
  1. +1 −0 src/display.js
  2. +18 −0 test/displayTest.js
View
@@ -15,6 +15,7 @@
$(this.canvas).click(mouseHandler('s2e:click', this));
$(this.canvas).mousedown(mouseHandler('s2e:mousedown', this));
$(this.canvas).mouseup(mouseHandler('s2e:mouseup', this));
+ $(this.canvas).mousemove(mouseHandler('s2e:mousemove', this));
this.context = this.canvas.getContext('2d');
this.padding = 20;
View
@@ -63,3 +63,21 @@ test('s2e:mouseup event', function(){
$(display.canvas).trigger(mouseup);
});
+
+test('s2e:mouseup event', function(){
+ var mousemove = $.Event('mousemove');
+ mousemove.pageX = $(display.canvas).position().left + display.padding + 10;
+ mousemove.pageY = $(display.canvas).position().top + 10;
+
+ expect(3);
+ $(display).bind('s2e:mousemove', function(ev){
+ equals(ev.position, 0,
+ "It converts the coordinates to a position in the buffer");
+ equals(ev.pageX, $(display.canvas).position().left + display.padding + 10,
+ "It provides access to the actual click position");
+ equals(ev.pageY, $(display.canvas).position().top + 10,
+ "It provides access to the actual click position");
+ });
+
+ $(display.canvas).trigger(mousemove);
+});

0 comments on commit ca297a5

Please sign in to comment.