添加桌面歌词滚动对齐方式、歌词间距设置

This commit is contained in:
lyswhut
2022-10-29 15:20:59 +08:00
parent 72418194e9
commit 07898cdfd6
15 changed files with 100 additions and 29 deletions
@@ -4,6 +4,13 @@ import { lyric } from '@lyric/store/lyric'
import { isPlay, setting } from '@lyric/store/state'
import { setWindowBounds } from '@lyric/utils/ipc'
const getOffsetTop = (contentHeight, lineHeight) => {
switch (setting['desktopLyric.scrollAlign']) {
case 'top': return setting['desktopLyric.style.lineGap'] / 2
default: return contentHeight * 0.5 - lineHeight / 2
}
}
export default () => {
const dom_lyric = ref(null)
const dom_lyric_text = ref(null)
@@ -32,7 +39,7 @@ export default () => {
}
if (isStopScroll) return
let dom_p = dom_lines[lyric.line]
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - dom_lyric.value.clientHeight * 0.5 + dom_p.clientHeight / 2) : 0, duration)
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - getOffsetTop(dom_lyric.value.clientHeight, dom_p.clientHeight)) : 0, duration)
}
const clearLyricScrollTimeout = () => {
if (!timeout) return