@@ -25,7 +25,8 @@ describe('$swipe', function() {
2525 var usedEvents ;
2626 var MOUSE_EVENTS = [ 'mousedown' , 'mousemove' , 'mouseup' ] . sort ( ) ;
2727 var TOUCH_EVENTS = [ 'touchcancel' , 'touchend' , 'touchmove' , 'touchstart' ] . sort ( ) ;
28- var ALL_EVENTS = MOUSE_EVENTS . concat ( TOUCH_EVENTS ) . sort ( ) ;
28+ var POINTER_EVENTS = [ 'pointerdown' , 'pointermove' , 'pointerup' , 'pointercancel' ] . sort ( ) ;
29+ var ALL_EVENTS = MOUSE_EVENTS . concat ( TOUCH_EVENTS , POINTER_EVENTS ) . sort ( ) ;
2930
3031 beforeEach ( function ( ) {
3132 usedEvents = [ ] ;
@@ -36,7 +37,7 @@ describe('$swipe', function() {
3637 } ) ;
3738 } ) ;
3839
39- it ( 'should use mouse and touch by default' , inject ( function ( $swipe ) {
40+ it ( 'should use mouse, touch and pointer by default' , inject ( function ( $swipe ) {
4041 $swipe . bind ( element , events ) ;
4142 expect ( usedEvents . sort ( ) ) . toEqual ( ALL_EVENTS ) ;
4243 } ) ) ;
@@ -51,14 +52,35 @@ describe('$swipe', function() {
5152 expect ( usedEvents . sort ( ) ) . toEqual ( TOUCH_EVENTS ) ;
5253 } ) ) ;
5354
55+ it ( 'should only use pointer events for pointerType "pointer"' , inject ( function ( $swipe ) {
56+ $swipe . bind ( element , events , [ 'pointer' ] ) ;
57+ expect ( usedEvents . sort ( ) ) . toEqual ( POINTER_EVENTS ) ;
58+ } ) ) ;
59+
5460 it ( 'should use mouse and touch if both are specified' , inject ( function ( $swipe ) {
5561 $swipe . bind ( element , events , [ 'touch' , 'mouse' ] ) ;
62+ expect ( usedEvents . sort ( ) ) . toEqual ( MOUSE_EVENTS . concat ( TOUCH_EVENTS ) . sort ( ) ) ;
63+ } ) ) ;
64+
65+ it ( 'should use mouse and pointer if both are specified' , inject ( function ( $swipe ) {
66+ $swipe . bind ( element , events , [ 'mouse' , 'pointer' ] ) ;
67+ expect ( usedEvents . sort ( ) ) . toEqual ( MOUSE_EVENTS . concat ( POINTER_EVENTS ) . sort ( ) ) ;
68+ } ) ) ;
69+
70+ it ( 'should use touch and pointer if both are specified' , inject ( function ( $swipe ) {
71+ $swipe . bind ( element , events , [ 'touch' , 'pointer' ] ) ;
72+ expect ( usedEvents . sort ( ) ) . toEqual ( TOUCH_EVENTS . concat ( POINTER_EVENTS ) . sort ( ) ) ;
73+ } ) ) ;
74+
75+ it ( 'should use mouse, touch and pointer if they are specified' , inject ( function ( $swipe ) {
76+ $swipe . bind ( element , events , [ 'mouse' , 'touch' , 'pointer' ] ) ;
5677 expect ( usedEvents . sort ( ) ) . toEqual ( ALL_EVENTS ) ;
5778 } ) ) ;
5879
5980 } ) ;
6081
6182 swipeTests ( 'touch' , /* restrictBrowers */ true , 'touchstart' , 'touchmove' , 'touchend' ) ;
83+ swipeTests ( 'pointer' , /* restrictBrowers */ true , 'pointerdown' , 'pointermove' , 'pointerup' ) ;
6284 swipeTests ( 'mouse' , /* restrictBrowers */ false , 'mousedown' , 'mousemove' , 'mouseup' ) ;
6385
6486 // Wrapper to abstract over using touch events or mouse events.
0 commit comments