使用 e.pageX

This commit is contained in:
Harvey Zack committed 2019-06-06 15:45:37 +08:00
1 parent 581b453ed2
commit 896de568cc
4 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ export function getPosFromEvent(art, event) {
} = art;
const { left } = $progress.getBoundingClientRect();
const width = clamp(event.x - left, 0, $progress.clientWidth);
const width = clamp(event.pageX - left, 0, $progress.clientWidth);
const second = (width / $progress.clientWidth) * player.duration;
const time = secondToTime(second);
const percentage = clamp(width / $progress.clientWidth, 0, 1);
+1 -1
View File
@@ -23,7 +23,7 @@ export default function volume(controlOption) {
const { left: panelLeft, width: panelWidth } = $volumePanel.getBoundingClientRect();
const { width: handleWidth } = $volumeHandle.getBoundingClientRect();
const percentage =
clamp(event.x - panelLeft - handleWidth / 2, 0, panelWidth - handleWidth / 2) /
clamp(event.pageX - panelLeft - handleWidth / 2, 0, panelWidth - handleWidth / 2) /
(panelWidth - handleWidth);
return percentage;
}