(currentX: number)
| 595 | } |
| 596 | |
| 597 | private update(currentX: number) { |
| 598 | // figure out where the pointer is currently at |
| 599 | // update the knob being interacted with |
| 600 | const rect = this.rect; |
| 601 | let ratio = clamp(0, (currentX - rect.left) / rect.width, 1); |
| 602 | if (isRTL(this.el)) { |
| 603 | ratio = 1 - ratio; |
| 604 | } |
| 605 | |
| 606 | if (this.snaps) { |
| 607 | // snaps the ratio to the current value |
| 608 | ratio = valueToRatio(ratioToValue(ratio, this.min, this.max, this.step), this.min, this.max); |
| 609 | } |
| 610 | |
| 611 | // update which knob is pressed |
| 612 | if (this.pressedKnob === 'A') { |
| 613 | this.ratioA = ratio; |
| 614 | } else { |
| 615 | this.ratioB = ratio; |
| 616 | } |
| 617 | |
| 618 | // Update input value |
| 619 | this.updateValue(); |
| 620 | } |
| 621 | |
| 622 | private setPressedKnob(currentX: number) { |
| 623 | const rect = (this.rect = this.rangeSlider!.getBoundingClientRect() as any); |
no test coverage detected