Skip to content

Commit

Permalink
feat(slider): fix normalize step
Browse files Browse the repository at this point in the history
  • Loading branch information
DiyanDimitrov committed Nov 16, 2021
1 parent 3303916 commit 41fd1d3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class IgcSliderComponent extends EventEmitterMixin<
public firstUpdated() {
this._hasViewInit = true;
this.positionHandlersAndUpdateTrack();
this.normalizeByStep(this.value);
this.normalizeByStep();
}

@query('#thumbFrom')
Expand Down Expand Up @@ -405,18 +405,16 @@ export default class IgcSliderComponent extends EventEmitterMixin<
}

@watch('step', { waitUntilFirstUpdate: true })
private normalizeByStep(value: IRangeSliderValue | number) {
private normalizeByStep() {
if (this.isRange) {
const rangeValue = this.value as IRangeSliderValue;
this.value = {
lower:
(value as IRangeSliderValue).lower -
((value as IRangeSliderValue).lower % this.step),
upper:
(value as IRangeSliderValue).upper -
((value as IRangeSliderValue).upper % this.step),
lower: rangeValue.lower - (rangeValue.lower % this.step),
upper: rangeValue.upper - (rangeValue.upper % this.step),
};
} else {
this.value = (value as number) - ((value as number) % this.step);
const numValue = this.value as number;
this.value = numValue - (numValue % this.step);
}
}

Expand Down

0 comments on commit 41fd1d3

Please sign in to comment.