Math.sign of translationX

This commit is contained in:
Diego Mello 2023-10-26 15:02:08 -03:00
parent c8a148f05b
commit c3f7f8a485
1 changed files with 5 additions and 1 deletions

View File

@ -60,7 +60,11 @@ const Seek = ({ currentTime, duration, loaded = false, onChangeTime }: ISeek) =>
ctx.startX = timePosition.value;
},
onActive: (event, ctx: any) => {
timePosition.value = clamp(ctx.startX + event.translationX, 0, maxWidth.value);
timePosition.value = clamp(
ctx.startX + event.translationX + (THUMB_SEEK_SIZE / 2) * Math.sign(event.translationX),
0,
maxWidth.value
);
isTimeChanged.value = true;
scale.value = 1.3;
currentTime.value = (timePosition.value * duration.value) / maxWidth.value || 0;