Permalink
Browse files
Add an s2e mouse move event
- Loading branch information...
Showing
with
19 additions
and
0 deletions.
-
+1
−0
src/display.js
-
+18
−0
test/displayTest.js
|
@@ -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;
|
|
|
|
@@ -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