@@ -25,7 +25,8 @@ describe('$swipe', function() {
25
25
var usedEvents ;
26
26
var MOUSE_EVENTS = [ 'mousedown' , 'mousemove' , 'mouseup' ] . sort ( ) ;
27
27
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 ( ) ;
29
30
30
31
beforeEach ( function ( ) {
31
32
usedEvents = [ ] ;
@@ -36,7 +37,7 @@ describe('$swipe', function() {
36
37
} ) ;
37
38
} ) ;
38
39
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 ) {
40
41
$swipe . bind ( element , events ) ;
41
42
expect ( usedEvents . sort ( ) ) . toEqual ( ALL_EVENTS ) ;
42
43
} ) ) ;
@@ -51,14 +52,35 @@ describe('$swipe', function() {
51
52
expect ( usedEvents . sort ( ) ) . toEqual ( TOUCH_EVENTS ) ;
52
53
} ) ) ;
53
54
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
+
54
60
it ( 'should use mouse and touch if both are specified' , inject ( function ( $swipe ) {
55
61
$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' ] ) ;
56
77
expect ( usedEvents . sort ( ) ) . toEqual ( ALL_EVENTS ) ;
57
78
} ) ) ;
58
79
59
80
} ) ;
60
81
61
82
swipeTests ( 'touch' , /* restrictBrowers */ true , 'touchstart' , 'touchmove' , 'touchend' ) ;
83
+ swipeTests ( 'pointer' , /* restrictBrowers */ true , 'pointerdown' , 'pointermove' , 'pointerup' ) ;
62
84
swipeTests ( 'mouse' , /* restrictBrowers */ false , 'mousedown' , 'mousemove' , 'mouseup' ) ;
63
85
64
86
// Wrapper to abstract over using touch events or mouse events.
0 commit comments