Skip to content

Commit

Permalink
fix(video-slider): tooltip text and position
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitaru committed Mar 21, 2024
1 parent b0e2fbf commit 81fa06d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/video-slider/Video-slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class VideoSlider extends LitElement {
y,
);
this.tooltipPopper.update();
emit(this, "hovering", { position: x });
emit(this, "hovering", { position: percents });
};

handleSlotChange = (e: Event & { target: HTMLSlotElement }) => {
Expand All @@ -195,8 +195,12 @@ export class VideoSlider extends LitElement {
const { clientX, target, touches } = e;
const { y, x, width } = target.getBoundingClientRect();
const xPosition = touches?.[0]?.clientX || clientX;
const percents = ((100 / width) * (xPosition - x)).toFixed(3);
return [Math.min(width + x, Math.max(x, xPosition)), y, String(percents)];
const percents = Number(((100 / width) * (xPosition - x)).toFixed(3));
return [
Math.min(width + x, Math.max(x, xPosition)),
y,
String(Math.min(100, Math.max(0, percents))),
];
}

createPopper(element: HTMLElement) {
Expand Down

0 comments on commit 81fa06d

Please sign in to comment.