Skip to content

Commit

Permalink
refactor(slider): rename internal function to avoid collision with `H…
Browse files Browse the repository at this point in the history
…TMLElement.translate` (#10293)

**Related Issue:** #10235

## Summary

[`HTMLElement.translate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/translate)
is a newly available baseline property, so this renames an existing
function to avoid any conflicts.
  • Loading branch information
jcfranco authored Sep 13, 2024
1 parent 81e2bbb commit e52524b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/calcite-components/src/components/slider/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export class Slider
}

const x = event.clientX || event.pageX;
const position = this.translate(x);
const position = this.mapToRange(x);
let prop: ActiveSliderProperty = "value";
if (isRange(this.value)) {
const inRange = position >= this.minValue && position <= this.maxValue;
Expand Down Expand Up @@ -803,7 +803,7 @@ export class Slider

event.preventDefault();
if (this.dragProp) {
const value = this.translate(event.clientX || event.pageX);
const value = this.mapToRange(event.clientX || event.pageX);
if (isRange(this.value) && this.dragProp === "minMaxValue") {
if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
const newMinValue = value - this.minValueDragRange;
Expand Down Expand Up @@ -942,7 +942,7 @@ export class Slider
* @param x
* @internal
*/
private translate(x: number): number {
private mapToRange(x: number): number {
const range = this.max - this.min;
const { left, width } = this.trackEl.getBoundingClientRect();
const percent = (x - left) / width;
Expand Down

0 comments on commit e52524b

Please sign in to comment.