@@ -71,22 +71,22 @@ describe('MdSlider', () => {
71
71
expect ( sliderInstance . value ) . toBe ( 19 ) ;
72
72
} ) ;
73
73
74
- it ( 'should update the value on a drag ' , ( ) => {
74
+ it ( 'should update the value on a slide ' , ( ) => {
75
75
expect ( sliderInstance . value ) . toBe ( 0 ) ;
76
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.89 , gestureConfig ) ;
76
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.89 , gestureConfig ) ;
77
77
// The expected value is 89 from: percentage * difference of max and min.
78
78
expect ( sliderInstance . value ) . toBe ( 89 ) ;
79
79
} ) ;
80
80
81
- it ( 'should set the value as min when dragging before the track' , ( ) => {
81
+ it ( 'should set the value as min when sliding before the track' , ( ) => {
82
82
expect ( sliderInstance . value ) . toBe ( 0 ) ;
83
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , - 1.33 , gestureConfig ) ;
83
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , - 1.33 , gestureConfig ) ;
84
84
expect ( sliderInstance . value ) . toBe ( 0 ) ;
85
85
} ) ;
86
86
87
- it ( 'should set the value as max when dragging past the track' , ( ) => {
87
+ it ( 'should set the value as max when sliding past the track' , ( ) => {
88
88
expect ( sliderInstance . value ) . toBe ( 0 ) ;
89
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 1.75 , gestureConfig ) ;
89
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 1.75 , gestureConfig ) ;
90
90
expect ( sliderInstance . value ) . toBe ( 100 ) ;
91
91
} ) ;
92
92
@@ -116,9 +116,9 @@ describe('MdSlider', () => {
116
116
expect ( thumbDimensions . left ) . toBe ( sliderDimensions . width * 0.5 + sliderDimensions . left ) ;
117
117
} ) ;
118
118
119
- it ( 'should update the track fill on drag ' , ( ) => {
119
+ it ( 'should update the track fill on slide ' , ( ) => {
120
120
expect ( trackFillDimensions . width ) . toBe ( 0 ) ;
121
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.86 , gestureConfig ) ;
121
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.86 , gestureConfig ) ;
122
122
123
123
trackFillDimensions = trackFillElement . getBoundingClientRect ( ) ;
124
124
thumbDimensions = thumbElement . getBoundingClientRect ( ) ;
@@ -130,11 +130,11 @@ describe('MdSlider', () => {
130
130
expect ( Math . round ( trackFillDimensions . width ) ) . toBe ( Math . round ( thumbPosition ) ) ;
131
131
} ) ;
132
132
133
- it ( 'should update the thumb position on drag ' , ( ) => {
133
+ it ( 'should update the thumb position on slide ' , ( ) => {
134
134
expect ( thumbDimensions . left ) . toBe ( sliderDimensions . left ) ;
135
- // The drag event also truncates the position passed in, so 50% is used here as well to
135
+ // The slide event also truncates the position passed in, so 50% is used here as well to
136
136
// ensure the ability to calculate the expected position.
137
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.5 , gestureConfig ) ;
137
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.5 , gestureConfig ) ;
138
138
139
139
thumbDimensions = thumbElement . getBoundingClientRect ( ) ;
140
140
expect ( thumbDimensions . left ) . toBe ( sliderDimensions . width * 0.5 + sliderDimensions . left ) ;
@@ -165,19 +165,19 @@ describe('MdSlider', () => {
165
165
expect ( containerElement . classList ) . not . toContain ( 'md-slider-active' ) ;
166
166
} ) ;
167
167
168
- it ( 'should add and remove the md-slider-dragging class when dragging ' , ( ) => {
168
+ it ( 'should add and remove the md-slider-sliding class when sliding ' , ( ) => {
169
169
let containerElement = sliderNativeElement . querySelector ( '.md-slider-container' ) ;
170
- expect ( containerElement . classList ) . not . toContain ( 'md-slider-dragging ' ) ;
170
+ expect ( containerElement . classList ) . not . toContain ( 'md-slider-sliding ' ) ;
171
171
172
- dispatchDragStartEvent ( sliderNativeElement , 0 , gestureConfig ) ;
172
+ dispatchSlideStartEvent ( sliderNativeElement , 0 , gestureConfig ) ;
173
173
fixture . detectChanges ( ) ;
174
174
175
- expect ( containerElement . classList ) . toContain ( 'md-slider-dragging ' ) ;
175
+ expect ( containerElement . classList ) . toContain ( 'md-slider-sliding ' ) ;
176
176
177
- dispatchDragEndEvent ( sliderNativeElement , 0.34 , gestureConfig ) ;
177
+ dispatchSlideEndEvent ( sliderNativeElement , 0.34 , gestureConfig ) ;
178
178
fixture . detectChanges ( ) ;
179
179
180
- expect ( containerElement . classList ) . not . toContain ( 'md-slider-dragging ' ) ;
180
+ expect ( containerElement . classList ) . not . toContain ( 'md-slider-sliding ' ) ;
181
181
} ) ;
182
182
} ) ;
183
183
@@ -208,9 +208,9 @@ describe('MdSlider', () => {
208
208
expect ( sliderInstance . value ) . toBe ( 0 ) ;
209
209
} ) ;
210
210
211
- it ( 'should not change the value on drag when disabled' , ( ) => {
211
+ it ( 'should not change the value on slide when disabled' , ( ) => {
212
212
expect ( sliderInstance . value ) . toBe ( 0 ) ;
213
- dispatchDragEvent ( sliderNativeElement , sliderNativeElement , 0 , 0.5 , gestureConfig ) ;
213
+ dispatchSlideEvent ( sliderNativeElement , sliderNativeElement , 0 , 0.5 , gestureConfig ) ;
214
214
expect ( sliderInstance . value ) . toBe ( 0 ) ;
215
215
} ) ;
216
216
@@ -224,14 +224,14 @@ describe('MdSlider', () => {
224
224
expect ( containerElement . classList ) . not . toContain ( 'md-slider-active' ) ;
225
225
} ) ;
226
226
227
- it ( 'should not add the md-slider-dragging class on drag when disabled' , ( ) => {
227
+ it ( 'should not add the md-slider-sliding class on slide when disabled' , ( ) => {
228
228
let containerElement = sliderNativeElement . querySelector ( '.md-slider-container' ) ;
229
- expect ( containerElement . classList ) . not . toContain ( 'md-slider-dragging ' ) ;
229
+ expect ( containerElement . classList ) . not . toContain ( 'md-slider-sliding ' ) ;
230
230
231
- dispatchDragStartEvent ( sliderNativeElement , 0.46 , gestureConfig ) ;
231
+ dispatchSlideStartEvent ( sliderNativeElement , 0.46 , gestureConfig ) ;
232
232
fixture . detectChanges ( ) ;
233
233
234
- expect ( containerElement . classList ) . not . toContain ( 'md-slider-dragging ' ) ;
234
+ expect ( containerElement . classList ) . not . toContain ( 'md-slider-sliding ' ) ;
235
235
} ) ;
236
236
} ) ;
237
237
@@ -274,8 +274,8 @@ describe('MdSlider', () => {
274
274
expect ( sliderInstance . value ) . toBe ( value ) ;
275
275
} ) ;
276
276
277
- it ( 'should set the correct value on drag ' , ( ) => {
278
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.62 , gestureConfig ) ;
277
+ it ( 'should set the correct value on slide ' , ( ) => {
278
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.62 , gestureConfig ) ;
279
279
// Computed by multiplying the difference between the min and the max by the percentage from
280
280
// the click and adding that to the minimum.
281
281
let value = Math . round ( 4 + ( 0.62 * ( 6 - 4 ) ) ) ;
@@ -295,11 +295,11 @@ describe('MdSlider', () => {
295
295
expect ( Math . round ( trackFillDimensions . width ) ) . toBe ( Math . round ( thumbPosition ) ) ;
296
296
} ) ;
297
297
298
- it ( 'should snap the thumb and fill to the nearest value on drag ' , ( ) => {
299
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.74 , gestureConfig ) ;
298
+ it ( 'should snap the thumb and fill to the nearest value on slide ' , ( ) => {
299
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.74 , gestureConfig ) ;
300
300
fixture . detectChanges ( ) ;
301
301
302
- dispatchDragEndEvent ( sliderNativeElement , 0.74 , gestureConfig ) ;
302
+ dispatchSlideEndEvent ( sliderNativeElement , 0.74 , gestureConfig ) ;
303
303
fixture . detectChanges ( ) ;
304
304
305
305
let trackFillDimensions = trackFillElement . getBoundingClientRect ( ) ;
@@ -343,8 +343,8 @@ describe('MdSlider', () => {
343
343
expect ( sliderInstance . value ) . toBe ( 92 ) ;
344
344
} ) ;
345
345
346
- it ( 'should set the correct value on drag ' , ( ) => {
347
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.32 , gestureConfig ) ;
346
+ it ( 'should set the correct value on slide ' , ( ) => {
347
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.32 , gestureConfig ) ;
348
348
expect ( sliderInstance . value ) . toBe ( 32 ) ;
349
349
} ) ;
350
350
} ) ;
@@ -396,18 +396,18 @@ describe('MdSlider', () => {
396
396
expect ( Math . round ( trackFillDimensions . width ) ) . toBe ( Math . round ( thumbPosition ) ) ;
397
397
} ) ;
398
398
399
- it ( 'should set the correct step value on drag ' , ( ) => {
400
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.07 , gestureConfig ) ;
399
+ it ( 'should set the correct step value on slide ' , ( ) => {
400
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.07 , gestureConfig ) ;
401
401
fixture . detectChanges ( ) ;
402
402
403
403
expect ( sliderInstance . value ) . toBe ( 0 ) ;
404
404
} ) ;
405
405
406
- it ( 'should snap the thumb and fill to a step on drag ' , ( ) => {
407
- dispatchDragEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.88 , gestureConfig ) ;
406
+ it ( 'should snap the thumb and fill to a step on slide ' , ( ) => {
407
+ dispatchSlideEvent ( sliderTrackElement , sliderNativeElement , 0 , 0.88 , gestureConfig ) ;
408
408
fixture . detectChanges ( ) ;
409
409
410
- dispatchDragEndEvent ( sliderNativeElement , 0.88 , gestureConfig ) ;
410
+ dispatchSlideEndEvent ( sliderNativeElement , 0.88 , gestureConfig ) ;
411
411
fixture . detectChanges ( ) ;
412
412
413
413
let trackFillDimensions = trackFillElement . getBoundingClientRect ( ) ;
@@ -489,62 +489,62 @@ function dispatchClickEvent(element: HTMLElement, percentage: number): void {
489
489
}
490
490
491
491
/**
492
- * Dispatches a drag event from an element.
492
+ * Dispatches a slide event from an element.
493
493
* @param trackElement The track element from which the event location will be calculated.
494
494
* @param containerElement The container element from which the event will be dispatched.
495
- * @param startPercent The percentage of the slider where the drag will begin.
496
- * @param endPercent The percentage of the slider where the drag will end.
497
- * @param gestureConfig The gesture config for the test to handle emitting the drag events.
495
+ * @param startPercent The percentage of the slider where the slide will begin.
496
+ * @param endPercent The percentage of the slider where the slide will end.
497
+ * @param gestureConfig The gesture config for the test to handle emitting the slide events.
498
498
*/
499
- function dispatchDragEvent ( trackElement : HTMLElement , containerElement : HTMLElement ,
500
- startPercent : number , endPercent : number ,
501
- gestureConfig : TestGestureConfig ) : void {
499
+ function dispatchSlideEvent ( trackElement : HTMLElement , containerElement : HTMLElement ,
500
+ startPercent : number , endPercent : number ,
501
+ gestureConfig : TestGestureConfig ) : void {
502
502
let dimensions = trackElement . getBoundingClientRect ( ) ;
503
503
let startX = dimensions . left + ( dimensions . width * startPercent ) ;
504
504
let endX = dimensions . left + ( dimensions . width * endPercent ) ;
505
505
506
- gestureConfig . emitEventForElement ( 'dragstart ' , containerElement , {
507
- // The actual event has a center with an x value that the drag listener is looking for.
506
+ gestureConfig . emitEventForElement ( 'slidestart ' , containerElement , {
507
+ // The actual event has a center with an x value that the slide listener is looking for.
508
508
center : { x : startX } ,
509
509
// The event needs a source event with a prevent default so we fake one.
510
510
srcEvent : { preventDefault : jasmine . createSpy ( 'preventDefault' ) }
511
511
} ) ;
512
512
513
- gestureConfig . emitEventForElement ( 'drag ' , containerElement , {
513
+ gestureConfig . emitEventForElement ( 'slide ' , containerElement , {
514
514
center : { x : endX } ,
515
515
srcEvent : { preventDefault : jasmine . createSpy ( 'preventDefault' ) }
516
516
} ) ;
517
517
}
518
518
519
519
/**
520
- * Dispatches a dragstart event from an element.
520
+ * Dispatches a slidestart event from an element.
521
521
* @param element The element from which the event will be dispatched.
522
- * @param startPercent The percentage of the slider where the drag will begin.
523
- * @param gestureConfig The gesture config for the test to handle emitting the drag events.
522
+ * @param startPercent The percentage of the slider where the slide will begin.
523
+ * @param gestureConfig The gesture config for the test to handle emitting the slide events.
524
524
*/
525
- function dispatchDragStartEvent ( element : HTMLElement , startPercent : number ,
526
- gestureConfig : TestGestureConfig ) : void {
525
+ function dispatchSlideStartEvent ( element : HTMLElement , startPercent : number ,
526
+ gestureConfig : TestGestureConfig ) : void {
527
527
let dimensions = element . getBoundingClientRect ( ) ;
528
528
let x = dimensions . left + ( dimensions . width * startPercent ) ;
529
529
530
- gestureConfig . emitEventForElement ( 'dragstart ' , element , {
530
+ gestureConfig . emitEventForElement ( 'slidestart ' , element , {
531
531
center : { x : x } ,
532
532
srcEvent : { preventDefault : jasmine . createSpy ( 'preventDefault' ) }
533
533
} ) ;
534
534
}
535
535
536
536
/**
537
- * Dispatches a dragend event from an element.
537
+ * Dispatches a slideend event from an element.
538
538
* @param element The element from which the event will be dispatched.
539
- * @param endPercent The percentage of the slider where the drag will end.
540
- * @param gestureConfig The gesture config for the test to handle emitting the drag events.
539
+ * @param endPercent The percentage of the slider where the slide will end.
540
+ * @param gestureConfig The gesture config for the test to handle emitting the slide events.
541
541
*/
542
- function dispatchDragEndEvent ( element : HTMLElement , endPercent : number ,
543
- gestureConfig : TestGestureConfig ) : void {
542
+ function dispatchSlideEndEvent ( element : HTMLElement , endPercent : number ,
543
+ gestureConfig : TestGestureConfig ) : void {
544
544
let dimensions = element . getBoundingClientRect ( ) ;
545
545
let x = dimensions . left + ( dimensions . width * endPercent ) ;
546
546
547
- gestureConfig . emitEventForElement ( 'dragend ' , element , {
547
+ gestureConfig . emitEventForElement ( 'slideend ' , element , {
548
548
center : { x : x } ,
549
549
srcEvent : { preventDefault : jasmine . createSpy ( 'preventDefault' ) }
550
550
} ) ;
0 commit comments