@@ -40,14 +40,14 @@ describe('DragDropRegistry', () => {
40
40
const firstItem = testComponent . dragItems . first ;
41
41
42
42
expect ( registry . isDragging ( firstItem ) ) . toBe ( false ) ;
43
- registry . startDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
43
+ registry . initializeDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
44
44
expect ( registry . isDragging ( firstItem ) ) . toBe ( true ) ;
45
45
} ) ;
46
46
47
47
it ( 'should be able to stop dragging an item' , ( ) => {
48
48
const firstItem = testComponent . dragItems . first ;
49
49
50
- registry . startDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
50
+ registry . initializeDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
51
51
expect ( registry . isDragging ( firstItem ) ) . toBe ( true ) ;
52
52
53
53
registry . stopDragging ( firstItem ) ;
@@ -57,7 +57,7 @@ describe('DragDropRegistry', () => {
57
57
it ( 'should stop dragging an item if it is removed' , ( ) => {
58
58
const firstItem = testComponent . dragItems . first ;
59
59
60
- registry . startDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
60
+ registry . initializeDragging ( firstItem , createMouseEvent ( 'mousedown' ) ) ;
61
61
expect ( registry . isDragging ( firstItem ) ) . toBe ( true ) ;
62
62
63
63
registry . removeDragItem ( firstItem ) ;
@@ -68,7 +68,7 @@ describe('DragDropRegistry', () => {
68
68
const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
69
69
const subscription = registry . pointerMove . subscribe ( spy ) ;
70
70
71
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
71
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
72
72
dispatchMouseEvent ( document , 'mousemove' ) ;
73
73
74
74
expect ( spy ) . toHaveBeenCalled ( ) ;
@@ -80,7 +80,7 @@ describe('DragDropRegistry', () => {
80
80
const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
81
81
const subscription = registry . pointerMove . subscribe ( spy ) ;
82
82
83
- registry . startDragging ( testComponent . dragItems . first ,
83
+ registry . initializeDragging ( testComponent . dragItems . first ,
84
84
createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
85
85
dispatchTouchEvent ( document , 'touchmove' ) ;
86
86
@@ -94,7 +94,7 @@ describe('DragDropRegistry', () => {
94
94
const subscription = registry . pointerMove . subscribe ( spy ) ;
95
95
96
96
fixture . nativeElement . addEventListener ( 'mousemove' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
97
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
97
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
98
98
dispatchMouseEvent ( fixture . nativeElement . querySelector ( 'div' ) , 'mousemove' ) ;
99
99
100
100
expect ( spy ) . toHaveBeenCalled ( ) ;
@@ -106,7 +106,7 @@ describe('DragDropRegistry', () => {
106
106
const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
107
107
const subscription = registry . pointerUp . subscribe ( spy ) ;
108
108
109
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
109
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
110
110
dispatchMouseEvent ( document , 'mouseup' ) ;
111
111
112
112
expect ( spy ) . toHaveBeenCalled ( ) ;
@@ -118,7 +118,7 @@ describe('DragDropRegistry', () => {
118
118
const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
119
119
const subscription = registry . pointerUp . subscribe ( spy ) ;
120
120
121
- registry . startDragging ( testComponent . dragItems . first ,
121
+ registry . initializeDragging ( testComponent . dragItems . first ,
122
122
createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
123
123
dispatchTouchEvent ( document , 'touchend' ) ;
124
124
@@ -132,7 +132,7 @@ describe('DragDropRegistry', () => {
132
132
const subscription = registry . pointerUp . subscribe ( spy ) ;
133
133
134
134
fixture . nativeElement . addEventListener ( 'mouseup' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
135
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
135
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
136
136
dispatchMouseEvent ( fixture . nativeElement . querySelector ( 'div' ) , 'mouseup' ) ;
137
137
138
138
expect ( spy ) . toHaveBeenCalled ( ) ;
@@ -159,9 +159,9 @@ describe('DragDropRegistry', () => {
159
159
const firstItem = testComponent . dragItems . first ;
160
160
161
161
// First finger down
162
- registry . startDragging ( firstItem , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
162
+ registry . initializeDragging ( firstItem , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
163
163
// Second finger down
164
- registry . startDragging ( firstItem , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
164
+ registry . initializeDragging ( firstItem , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
165
165
// First finger up
166
166
registry . stopDragging ( firstItem ) ;
167
167
@@ -194,15 +194,23 @@ describe('DragDropRegistry', () => {
194
194
expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( false ) ;
195
195
} ) ;
196
196
197
+ it ( 'should not revent the default `touchmove` action when an item is only initialized' , ( ) => {
198
+ registry . initializeDragging ( testComponent . dragItems . first ,
199
+ createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
200
+ expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( false ) ;
201
+ } ) ;
202
+
197
203
it ( 'should prevent the default `touchmove` action when an item is being dragged' , ( ) => {
198
- registry . startDragging ( testComponent . dragItems . first ,
204
+ registry . initializeDragging ( testComponent . dragItems . first ,
199
205
createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
206
+ registry . startDragging ( testComponent . dragItems . first ) ;
200
207
expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( true ) ;
201
208
} ) ;
202
209
203
210
it ( 'should prevent the default `touchmove` if event propagation is stopped' , ( ) => {
204
- registry . startDragging ( testComponent . dragItems . first ,
211
+ registry . initializeDragging ( testComponent . dragItems . first ,
205
212
createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
213
+ registry . startDragging ( testComponent . dragItems . first ) ;
206
214
207
215
fixture . nativeElement . addEventListener ( 'touchmove' , ( e : TouchEvent ) => e . stopPropagation ( ) ) ;
208
216
@@ -215,16 +223,22 @@ describe('DragDropRegistry', () => {
215
223
expect ( dispatchFakeEvent ( document , 'selectstart' ) . defaultPrevented ) . toBe ( false ) ;
216
224
} ) ;
217
225
226
+ it ( 'should not prevent the default `selectstart` action when an item is initialized' , ( ) => {
227
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
228
+ expect ( dispatchFakeEvent ( document , 'selectstart' ) . defaultPrevented ) . toBe ( false ) ;
229
+ } ) ;
230
+
218
231
it ( 'should prevent the default `selectstart` action when an item is being dragged' , ( ) => {
219
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
232
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
233
+ registry . startDragging ( testComponent . dragItems . first ) ;
220
234
expect ( dispatchFakeEvent ( document , 'selectstart' ) . defaultPrevented ) . toBe ( true ) ;
221
235
} ) ;
222
236
223
237
it ( 'should dispatch `scroll` events if the viewport is scrolled while dragging' , ( ) => {
224
238
const spy = jasmine . createSpy ( 'scroll spy' ) ;
225
239
const subscription = registry . scroll . subscribe ( spy ) ;
226
240
227
- registry . startDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
241
+ registry . initializeDragging ( testComponent . dragItems . first , createMouseEvent ( 'mousedown' ) ) ;
228
242
dispatchFakeEvent ( document , 'scroll' ) ;
229
243
230
244
expect ( spy ) . toHaveBeenCalled ( ) ;
0 commit comments