Skip to content

Commit

Permalink
fix(slider): border should only appear when handle nubs are overlapping
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 565179716
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Sep 13, 2023
1 parent 70bfea8 commit 6e72a8e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions slider/internal/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ export class Slider extends LitElement {
}
if (changed.has('range') || changed.has('renderValueStart') ||
changed.has('renderValueEnd') || this.isUpdatePending) {
this.handlesOverlapping = isOverlapping(this.handleStart, this.handleEnd);
// Only check if the handle nubs are overlapping, as the ripple touch
// target extends subtantially beyond the boundary of the handle nub.
const startNub = this.handleStart?.querySelector('.handleNub');
const endNub = this.handleEnd?.querySelector('.handleNub');
this.handlesOverlapping = isOverlapping(startNub, endNub);
}
// called to finish the update imediately;
// note, this is a no-op unless an update is scheduled
Expand Down Expand Up @@ -741,7 +745,8 @@ function inBounds({x, y}: PointerEvent, element?: HTMLElement|null) {
return x >= left && x <= right && y >= top && y <= bottom;
}

function isOverlapping(elA: Element|null, elB: Element|null) {
function isOverlapping(
elA: Element|null|undefined, elB: Element|null|undefined) {
if (!(elA && elB)) {
return false;
}
Expand Down

0 comments on commit 6e72a8e

Please sign in to comment.