修复提示语坐标bug

This commit is contained in:
zhw2590582 committed 2019-04-21 20:42:17 +08:00
1 parent a04900bcba
commit e453033792
6 files changed
+38 -25

No files matched your search

+11 -7
View File
@@ -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) {
+1
View File
@@ -100,6 +100,7 @@
background: rgba(0,0,0,.7);
border-radius: 3px;
font-weight: bold;
white-space: nowrap;
}
}