mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 19:01:20 -08:00
修复提示语坐标bug
This commit is contained in:
1 parent
a04900bcba
commit
e453033792
6 files changed
+38
-25
No files matched your search
@@ -41,19 +41,23 @@ export default function progress(controlOption) {
|
||||
const $tip = $control.querySelector('.art-progress-tip');
|
||||
|
||||
function showHighlight(event) {
|
||||
const { text, time } = event.target.dataset;
|
||||
const { width } = getPosFromEvent(art, event);
|
||||
const { text } = event.target.dataset;
|
||||
$tip.innerHTML = text;
|
||||
const left =
|
||||
(Number(time) / art.player.duration) * $control.clientWidth +
|
||||
event.target.clientWidth / 2 -
|
||||
$tip.clientWidth / 2;
|
||||
setStyle($tip, 'left', `${left}px`);
|
||||
const tipWidth = $tip.clientWidth;
|
||||
if (width <= tipWidth / 2) {
|
||||
setStyle($tip, 'left', 0);
|
||||
} else if (width > $control.clientWidth - tipWidth / 2) {
|
||||
setStyle($tip, 'left', `${$control.clientWidth - tipWidth}px`);
|
||||
} else {
|
||||
setStyle($tip, 'left', `${width - tipWidth / 2}px`);
|
||||
}
|
||||
}
|
||||
|
||||
function showTime(event) {
|
||||
const { width, time } = getPosFromEvent(art, event);
|
||||
const tipWidth = $tip.clientWidth;
|
||||
$tip.innerHTML = time;
|
||||
const tipWidth = $tip.clientWidth;
|
||||
if (width <= tipWidth / 2) {
|
||||
setStyle($tip, 'left', 0);
|
||||
} else if (width > $control.clientWidth - tipWidth / 2) {
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
background: rgba(0,0,0,.7);
|
||||
border-radius: 3px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user