@@ -60,10 +60,10 @@ describe('MatSlider', () => {
60
60
expect ( sliderInstance . max ) . toBe ( 100 ) ;
61
61
} ) ;
62
62
63
- it ( 'should update the value on a click ' , ( ) => {
63
+ it ( 'should update the value on mousedown ' , ( ) => {
64
64
expect ( sliderInstance . value ) . toBe ( 0 ) ;
65
65
66
- dispatchClickEventSequence ( sliderNativeElement , 0.19 ) ;
66
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.19 ) ;
67
67
68
68
expect ( sliderInstance . value ) . toBe ( 19 ) ;
69
69
} ) ;
@@ -92,10 +92,10 @@ describe('MatSlider', () => {
92
92
expect ( sliderInstance . value ) . toBe ( 100 ) ;
93
93
} ) ;
94
94
95
- it ( 'should update the track fill on click ' , ( ) => {
95
+ it ( 'should update the track fill on mousedown ' , ( ) => {
96
96
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(0, 1, 1)' ) ;
97
97
98
- dispatchClickEventSequence ( sliderNativeElement , 0.39 ) ;
98
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.39 ) ;
99
99
fixture . detectChanges ( ) ;
100
100
101
101
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(0.39, 1, 1)' ) ;
@@ -178,7 +178,7 @@ describe('MatSlider', () => {
178
178
} ) ;
179
179
180
180
it ( 'should not have thumb gap when not at min value' , ( ) => {
181
- dispatchClickEventSequence ( sliderNativeElement , 1 ) ;
181
+ dispatchMousedownEventSequence ( sliderNativeElement , 1 ) ;
182
182
fixture . detectChanges ( ) ;
183
183
184
184
// Some browsers use '0' and some use '0px', so leave off the closing paren.
@@ -223,10 +223,10 @@ describe('MatSlider', () => {
223
223
expect ( sliderInstance . disabled ) . toBeTruthy ( ) ;
224
224
} ) ;
225
225
226
- it ( 'should not change the value on click when disabled' , ( ) => {
226
+ it ( 'should not change the value on mousedown when disabled' , ( ) => {
227
227
expect ( sliderInstance . value ) . toBe ( 0 ) ;
228
228
229
- dispatchClickEventSequence ( sliderNativeElement , 0.63 ) ;
229
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.63 ) ;
230
230
231
231
expect ( sliderInstance . value ) . toBe ( 0 ) ;
232
232
} ) ;
@@ -248,10 +248,10 @@ describe('MatSlider', () => {
248
248
expect ( onChangeSpy ) . toHaveBeenCalledTimes ( 0 ) ;
249
249
} ) ;
250
250
251
- it ( 'should not add the mat-slider-active class on click when disabled' , ( ) => {
251
+ it ( 'should not add the mat-slider-active class on mousedown when disabled' , ( ) => {
252
252
expect ( sliderNativeElement . classList ) . not . toContain ( 'mat-slider-active' ) ;
253
253
254
- dispatchClickEventSequence ( sliderNativeElement , 0.43 ) ;
254
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.43 ) ;
255
255
fixture . detectChanges ( ) ;
256
256
257
257
expect ( sliderNativeElement . classList ) . not . toContain ( 'mat-slider-active' ) ;
@@ -305,12 +305,12 @@ describe('MatSlider', () => {
305
305
expect ( sliderInstance . max ) . toBe ( 6 ) ;
306
306
} ) ;
307
307
308
- it ( 'should set the correct value on click ' , ( ) => {
309
- dispatchClickEventSequence ( sliderNativeElement , 0.09 ) ;
308
+ it ( 'should set the correct value on mousedown ' , ( ) => {
309
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.09 ) ;
310
310
fixture . detectChanges ( ) ;
311
311
312
312
// Computed by multiplying the difference between the min and the max by the percentage from
313
- // the click and adding that to the minimum.
313
+ // the mousedown and adding that to the minimum.
314
314
let value = Math . round ( 4 + ( 0.09 * ( 6 - 4 ) ) ) ;
315
315
expect ( sliderInstance . value ) . toBe ( value ) ;
316
316
} ) ;
@@ -320,13 +320,13 @@ describe('MatSlider', () => {
320
320
fixture . detectChanges ( ) ;
321
321
322
322
// Computed by multiplying the difference between the min and the max by the percentage from
323
- // the click and adding that to the minimum.
323
+ // the mousedown and adding that to the minimum.
324
324
let value = Math . round ( 4 + ( 0.62 * ( 6 - 4 ) ) ) ;
325
325
expect ( sliderInstance . value ) . toBe ( value ) ;
326
326
} ) ;
327
327
328
- it ( 'should snap the fill to the nearest value on click ' , ( ) => {
329
- dispatchClickEventSequence ( sliderNativeElement , 0.68 ) ;
328
+ it ( 'should snap the fill to the nearest value on mousedown ' , ( ) => {
329
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.68 ) ;
330
330
fixture . detectChanges ( ) ;
331
331
332
332
// The closest snap is halfway on the slider.
@@ -392,8 +392,8 @@ describe('MatSlider', () => {
392
392
expect ( sliderInstance . value ) . toBe ( 26 ) ;
393
393
} ) ;
394
394
395
- it ( 'should set the correct value on click ' , ( ) => {
396
- dispatchClickEventSequence ( sliderNativeElement , 0.92 ) ;
395
+ it ( 'should set the correct value on mousedown ' , ( ) => {
396
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.92 ) ;
397
397
fixture . detectChanges ( ) ;
398
398
399
399
// On a slider with default max and min the value should be approximately equal to the
@@ -426,17 +426,17 @@ describe('MatSlider', () => {
426
426
trackFillElement = < HTMLElement > sliderNativeElement . querySelector ( '.mat-slider-track-fill' ) ;
427
427
} ) ;
428
428
429
- it ( 'should set the correct step value on click ' , ( ) => {
429
+ it ( 'should set the correct step value on mousedown ' , ( ) => {
430
430
expect ( sliderInstance . value ) . toBe ( 0 ) ;
431
431
432
- dispatchClickEventSequence ( sliderNativeElement , 0.13 ) ;
432
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.13 ) ;
433
433
fixture . detectChanges ( ) ;
434
434
435
435
expect ( sliderInstance . value ) . toBe ( 25 ) ;
436
436
} ) ;
437
437
438
- it ( 'should snap the fill to a step on click ' , ( ) => {
439
- dispatchClickEventSequence ( sliderNativeElement , 0.66 ) ;
438
+ it ( 'should snap the fill to a step on mousedown ' , ( ) => {
439
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.66 ) ;
440
440
fixture . detectChanges ( ) ;
441
441
442
442
// The closest step is at 75% of the slider.
@@ -596,10 +596,10 @@ describe('MatSlider', () => {
596
596
expect ( sliderNativeElement . classList ) . toContain ( 'mat-slider-thumb-label-showing' ) ;
597
597
} ) ;
598
598
599
- it ( 'should update the thumb label text on click ' , ( ) => {
599
+ it ( 'should update the thumb label text on mousedown ' , ( ) => {
600
600
expect ( thumbLabelTextElement . textContent ) . toBe ( '0' ) ;
601
601
602
- dispatchClickEventSequence ( sliderNativeElement , 0.13 ) ;
602
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.13 ) ;
603
603
fixture . detectChanges ( ) ;
604
604
605
605
// The thumb label text is set to the slider's value. These should always be the same.
@@ -757,10 +757,10 @@ describe('MatSlider', () => {
757
757
sliderNativeElement = sliderDebugElement . nativeElement ;
758
758
} ) ;
759
759
760
- it ( 'should emit change on click ' , ( ) => {
760
+ it ( 'should emit change on mousedown ' , ( ) => {
761
761
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
762
762
763
- dispatchClickEventSequence ( sliderNativeElement , 0.2 ) ;
763
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
764
764
fixture . detectChanges ( ) ;
765
765
766
766
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -778,7 +778,7 @@ describe('MatSlider', () => {
778
778
it ( 'should not emit multiple changes for same value' , ( ) => {
779
779
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
780
780
781
- dispatchClickEventSequence ( sliderNativeElement , 0.6 ) ;
781
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.6 ) ;
782
782
dispatchSlideEventSequence ( sliderNativeElement , 0.6 , 0.6 , gestureConfig ) ;
783
783
fixture . detectChanges ( ) ;
784
784
@@ -790,7 +790,7 @@ describe('MatSlider', () => {
790
790
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
791
791
expect ( testComponent . onInput ) . not . toHaveBeenCalled ( ) ;
792
792
793
- dispatchClickEventSequence ( sliderNativeElement , 0.2 ) ;
793
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
794
794
fixture . detectChanges ( ) ;
795
795
796
796
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -802,7 +802,7 @@ describe('MatSlider', () => {
802
802
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 1 ) ;
803
803
expect ( testComponent . onInput ) . toHaveBeenCalledTimes ( 1 ) ;
804
804
805
- dispatchClickEventSequence ( sliderNativeElement , 0.2 ) ;
805
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.2 ) ;
806
806
fixture . detectChanges ( ) ;
807
807
808
808
expect ( testComponent . onChange ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -846,7 +846,7 @@ describe('MatSlider', () => {
846
846
it ( 'should emit an input event when clicking' , ( ) => {
847
847
expect ( testComponent . onChange ) . not . toHaveBeenCalled ( ) ;
848
848
849
- dispatchClickEventSequence ( sliderNativeElement , 0.75 ) ;
849
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.75 ) ;
850
850
851
851
fixture . detectChanges ( ) ;
852
852
@@ -1017,7 +1017,7 @@ describe('MatSlider', () => {
1017
1017
testComponent . invert = true ;
1018
1018
fixture . detectChanges ( ) ;
1019
1019
1020
- dispatchClickEventSequence ( sliderNativeElement , 0.3 ) ;
1020
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
1021
1021
fixture . detectChanges ( ) ;
1022
1022
1023
1023
expect ( sliderInstance . value ) . toBe ( 70 ) ;
@@ -1027,7 +1027,7 @@ describe('MatSlider', () => {
1027
1027
testComponent . dir = 'rtl' ;
1028
1028
fixture . detectChanges ( ) ;
1029
1029
1030
- dispatchClickEventSequence ( sliderNativeElement , 0.3 ) ;
1030
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
1031
1031
fixture . detectChanges ( ) ;
1032
1032
1033
1033
expect ( sliderInstance . value ) . toBe ( 70 ) ;
@@ -1038,7 +1038,7 @@ describe('MatSlider', () => {
1038
1038
testComponent . invert = true ;
1039
1039
fixture . detectChanges ( ) ;
1040
1040
1041
- dispatchClickEventSequence ( sliderNativeElement , 0.3 ) ;
1041
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
1042
1042
fixture . detectChanges ( ) ;
1043
1043
1044
1044
expect ( sliderInstance . value ) . toBe ( 30 ) ;
@@ -1155,39 +1155,39 @@ describe('MatSlider', () => {
1155
1155
trackFillElement = < HTMLElement > sliderNativeElement . querySelector ( '.mat-slider-track-fill' ) ;
1156
1156
} ) ;
1157
1157
1158
- it ( 'updates value on click ' , ( ) => {
1159
- dispatchClickEventSequence ( sliderNativeElement , 0.3 ) ;
1158
+ it ( 'updates value on mousedown ' , ( ) => {
1159
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
1160
1160
fixture . detectChanges ( ) ;
1161
1161
1162
1162
expect ( sliderInstance . value ) . toBe ( 70 ) ;
1163
1163
} ) ;
1164
1164
1165
- it ( 'updates value on click in inverted mode' , ( ) => {
1165
+ it ( 'updates value on mousedown in inverted mode' , ( ) => {
1166
1166
testComponent . invert = true ;
1167
1167
fixture . detectChanges ( ) ;
1168
1168
1169
- dispatchClickEventSequence ( sliderNativeElement , 0.3 ) ;
1169
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.3 ) ;
1170
1170
fixture . detectChanges ( ) ;
1171
1171
1172
1172
expect ( sliderInstance . value ) . toBe ( 30 ) ;
1173
1173
} ) ;
1174
1174
1175
- it ( 'should update the track fill on click ' , ( ) => {
1175
+ it ( 'should update the track fill on mousedown ' , ( ) => {
1176
1176
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(1, 0, 1)' ) ;
1177
1177
1178
- dispatchClickEventSequence ( sliderNativeElement , 0.39 ) ;
1178
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.39 ) ;
1179
1179
fixture . detectChanges ( ) ;
1180
1180
1181
1181
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(1, 0.61, 1)' ) ;
1182
1182
} ) ;
1183
1183
1184
- it ( 'should update the track fill on click in inverted mode' , ( ) => {
1184
+ it ( 'should update the track fill on mousedown in inverted mode' , ( ) => {
1185
1185
testComponent . invert = true ;
1186
1186
fixture . detectChanges ( ) ;
1187
1187
1188
1188
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(1, 0, 1)' ) ;
1189
1189
1190
- dispatchClickEventSequence ( sliderNativeElement , 0.39 ) ;
1190
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.39 ) ;
1191
1191
fixture . detectChanges ( ) ;
1192
1192
1193
1193
expect ( trackFillElement . style . transform ) . toContain ( 'scale3d(1, 0.39, 1)' ) ;
@@ -1241,10 +1241,10 @@ describe('MatSlider', () => {
1241
1241
sliderNativeElement = sliderDebugElement . nativeElement ;
1242
1242
} ) ;
1243
1243
1244
- it ( 'should update the model on click ' , ( ) => {
1244
+ it ( 'should update the model on mousedown ' , ( ) => {
1245
1245
expect ( testComponent . val ) . toBe ( 0 ) ;
1246
1246
1247
- dispatchClickEventSequence ( sliderNativeElement , 0.76 ) ;
1247
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.76 ) ;
1248
1248
fixture . detectChanges ( ) ;
1249
1249
1250
1250
expect ( testComponent . val ) . toBe ( 76 ) ;
@@ -1313,10 +1313,10 @@ describe('MatSlider', () => {
1313
1313
expect ( testComponent . control . value ) . toBe ( 0 ) ;
1314
1314
} ) ;
1315
1315
1316
- it ( 'should update the control on click ' , ( ) => {
1316
+ it ( 'should update the control on mousedown ' , ( ) => {
1317
1317
expect ( testComponent . control . value ) . toBe ( 0 ) ;
1318
1318
1319
- dispatchClickEventSequence ( sliderNativeElement , 0.76 ) ;
1319
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.76 ) ;
1320
1320
fixture . detectChanges ( ) ;
1321
1321
1322
1322
expect ( testComponent . control . value ) . toBe ( 76 ) ;
@@ -1368,7 +1368,7 @@ describe('MatSlider', () => {
1368
1368
1369
1369
// After changing the value, the control should become dirty (not pristine),
1370
1370
// but remain untouched.
1371
- dispatchClickEventSequence ( sliderNativeElement , 0.5 ) ;
1371
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.5 ) ;
1372
1372
fixture . detectChanges ( ) ;
1373
1373
1374
1374
expect ( sliderControl . valid ) . toBe ( true ) ;
@@ -1404,7 +1404,7 @@ describe('MatSlider', () => {
1404
1404
expect ( testComponent . value ) . toBe ( 0 ) ;
1405
1405
expect ( testComponent . slider . value ) . toBe ( 0 ) ;
1406
1406
1407
- dispatchClickEventSequence ( sliderNativeElement , 0.1 ) ;
1407
+ dispatchMousedownEventSequence ( sliderNativeElement , 0.1 ) ;
1408
1408
fixture . detectChanges ( ) ;
1409
1409
1410
1410
expect ( testComponent . value ) . toBe ( 10 ) ;
@@ -1594,20 +1594,20 @@ class SliderWithTwoWayBinding {
1594
1594
}
1595
1595
1596
1596
/**
1597
- * Dispatches a click event sequence (consisting of moueseenter, click ) from an element.
1598
- * Note: The mouse event truncates the position for the click .
1597
+ * Dispatches a mousedown event sequence (consisting of moueseenter, mousedown ) from an element.
1598
+ * Note: The mouse event truncates the position for the event .
1599
1599
* @param sliderElement The mat-slider element from which the event will be dispatched.
1600
- * @param percentage The percentage of the slider where the click should occur. Used to find the
1601
- * physical location of the click .
1600
+ * @param percentage The percentage of the slider where the event should occur. Used to find the
1601
+ * physical location of the pointer .
1602
1602
*/
1603
- function dispatchClickEventSequence ( sliderElement : HTMLElement , percentage : number ) : void {
1603
+ function dispatchMousedownEventSequence ( sliderElement : HTMLElement , percentage : number ) : void {
1604
1604
let trackElement = sliderElement . querySelector ( '.mat-slider-wrapper' ) ! ;
1605
1605
let dimensions = trackElement . getBoundingClientRect ( ) ;
1606
1606
let x = dimensions . left + ( dimensions . width * percentage ) ;
1607
1607
let y = dimensions . top + ( dimensions . height * percentage ) ;
1608
1608
1609
1609
dispatchMouseenterEvent ( sliderElement ) ;
1610
- dispatchMouseEvent ( sliderElement , 'click ' , x , y ) ;
1610
+ dispatchMouseEvent ( sliderElement , 'mousedown ' , x , y ) ;
1611
1611
}
1612
1612
1613
1613
/**
@@ -1687,7 +1687,7 @@ function dispatchSlideEndEvent(sliderElement: HTMLElement, percent: number,
1687
1687
1688
1688
/**
1689
1689
* Dispatches a mouseenter event from an element.
1690
- * Note: The mouse event truncates the position for the click .
1690
+ * Note: The mouse event truncates the position for the event .
1691
1691
* @param element The element from which the event will be dispatched.
1692
1692
*/
1693
1693
function dispatchMouseenterEvent ( element : HTMLElement ) : void {
0 commit comments