Optimize setBar event and reduce delay for hiding chapter title in artplayer-plugin-chapter

This commit is contained in:
Harvey Zack committed 2024-06-03 00:17:32 +08:00
1 parent e8d7ae91f0
commit 94e34320e0
6 files changed
+20 -13

No files matched your search

@@ -74,7 +74,7 @@ export default function artplayerPluginChapter({ chapters = [] }) {
clearTimeout(titleTimer);
titleTimer = setTimeout(() => {
setStyle($title, 'display', 'none');
}, 1000);
}, 500);
}
} else {
if (type === 'hover') {
+6 -4
View File
@@ -71,8 +71,8 @@ export default function progress(options) {
}
}
function showTime(event) {
const { width, time } = getPosFromEvent(art, event);
function showTime(event, touch) {
const { width, time } = touch || getPosFromEvent(art, event);
$tip.innerText = time;
const tipWidth = $tip.clientWidth;
if (width <= tipWidth / 2) {
@@ -99,11 +99,13 @@ export default function progress(options) {
if (isMobile && event) {
setStyle($tip, 'display', 'flex');
showTime(event);
const width = $control.clientWidth * percentage;
const time = secondToTime(percentage * art.duration);
showTime(event, { width, time });
clearTimeout(tipTimer);
tipTimer = setTimeout(() => {
setStyle($tip, 'display', 'none');
}, 1000);
}, 500);
}
}
}