Skip to content

Commit ee60e4d

Browse files
committed
Small comment fixes
1 parent 28d382f commit ee60e4d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/components/slider/slider.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ describe('MdSlider', () => {
101101
// offset relative to the track, subtract the offset on the track fill.
102102
let thumbPosition = thumbDimensions.left - trackFillDimensions.left;
103103
// The track fill width should be equal to the thumb's position.
104-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
104+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
105105
});
106106

107107
it('should update the thumb position on click', () => {
108108
expect(thumbDimensions.left).toBe(sliderDimensions.left);
109109
// 50% is used here because the click event that is dispatched truncates the position and so
110-
// a value had to be used that would not be affected by the truncation.
110+
// a value had to be used that would not be truncated.
111111
dispatchClickEvent(sliderTrackElement, 0.5);
112112

113113
thumbDimensions = thumbElement.getBoundingClientRect();
@@ -127,11 +127,13 @@ describe('MdSlider', () => {
127127
// offset relative to the track, subtract the offset on the track fill.
128128
let thumbPosition = thumbDimensions.left - trackFillDimensions.left;
129129
// The track fill width should be equal to the thumb's position.
130-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
130+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
131131
});
132132

133133
it('should update the thumb position on drag', () => {
134134
expect(thumbDimensions.left).toBe(sliderDimensions.left);
135+
// The drag event also truncates the position passed in, so 50% is used here as well to
136+
// ensure the ability to calculate the expected position.
135137
dispatchDragEvent(sliderTrackElement, sliderNativeElement, 0, 0.5, gestureConfig);
136138

137139
thumbDimensions = thumbElement.getBoundingClientRect();
@@ -290,7 +292,7 @@ describe('MdSlider', () => {
290292

291293
// The closest snap is halfway on the slider.
292294
expect(thumbDimensions.left).toBe(sliderDimensions.width * 0.5 + sliderDimensions.left);
293-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
295+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
294296
});
295297

296298
it('should snap the thumb and fill to the nearest value on drag', () => {
@@ -306,7 +308,7 @@ describe('MdSlider', () => {
306308

307309
// The closest snap is at the halfway point on the slider.
308310
expect(thumbDimensions.left).toBe(sliderDimensions.left + sliderDimensions.width * 0.5);
309-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
311+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
310312

311313
});
312314
});
@@ -391,7 +393,7 @@ describe('MdSlider', () => {
391393

392394
// The closest step is at 75% of the slider.
393395
expect(thumbDimensions.left).toBe(sliderDimensions.width * 0.75 + sliderDimensions.left);
394-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
396+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
395397
});
396398

397399
it('should set the correct step value on drag', () => {
@@ -414,7 +416,7 @@ describe('MdSlider', () => {
414416

415417
// The closest snap is at the end of the slider.
416418
expect(thumbDimensions.left).toBe(sliderDimensions.width + sliderDimensions.left);
417-
expect(Math.round(trackFillDimensions.width)).toEqual(Math.round(thumbPosition));
419+
expect(Math.round(trackFillDimensions.width)).toBe(Math.round(thumbPosition));
418420
});
419421
});
420422
});

src/components/slider/slider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export class MdSlider implements AfterContentInit {
134134
this.updateValueFromPosition(event.clientX);
135135

136136
// Once the click is over the thumb has to snap to its new physical location.
137-
// This fires at the end of a drag as well.
138137
this.updatePercentFromValue();
139138
this._renderer.updateThumbAndFillPosition(this._percent, this._sliderDimensions.width);
140139
}
@@ -166,8 +165,7 @@ export class MdSlider implements AfterContentInit {
166165
/** TODO: internal */
167166
onDragEnd() {
168167
this.isDragging = false;
169-
// Once the click is over the thumb has to snap to its new physical location.
170-
// This fires at the end of a drag as well.
168+
// Once the drag is over the thumb has to snap to its new physical location.
171169
this.updatePercentFromValue();
172170
this._renderer.updateThumbAndFillPosition(this._percent, this._sliderDimensions.width);
173171
}

0 commit comments

Comments
 (0)