mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-19 03:11:20 -08:00
feat: Improve panel positioning in danmuku plugin
This commit is contained in:
1 parent
685241de57
commit
b4e3121917
3 files changed
+19
-5
No files matched your search
@@ -581,8 +581,18 @@ export default class Setting {
|
||||
const controlRect = $control.getBoundingClientRect();
|
||||
const panelRect = $panel.getBoundingClientRect();
|
||||
const playerRect = $player.getBoundingClientRect();
|
||||
const diff = Math.max(controlRect.right + panelRect.width / 2 - playerRect.right - controlRect.width / 2, 0);
|
||||
$panel.style.left = `-${panelRect.width / 2 - controlRect.width / 2 + diff}px`;
|
||||
|
||||
const half = panelRect.width / 2 - controlRect.width / 2;
|
||||
const left = playerRect.left - (controlRect.left - half);
|
||||
const right = controlRect.right + half - playerRect.right;
|
||||
|
||||
if (left > 0) {
|
||||
$panel.style.left = `${-half + left}px`;
|
||||
} else if (right > 0) {
|
||||
$panel.style.left = `${-half - right}px`;
|
||||
} else {
|
||||
$panel.style.left = `${-half}px`;
|
||||
}
|
||||
}
|
||||
|
||||
async emit() {
|
||||
|
||||
Reference in new issue
Block a user