支持桌面歌词拖动

This commit is contained in:
lyswhut
2021-03-02 18:41:27 +08:00
parent aef0ffa506
commit f2b6c0a443
4 changed files with 36 additions and 21 deletions
@@ -20,10 +20,11 @@ const createAnimation = (dom, duration) => new window.Animation(new window.Keyfr
// https://jsfiddle.net/ceqpnbky/1/
module.exports = class FontPlayer {
constructor({ lyric = '', className = '', lineModeClassName = '', shadowContent = false, shadowClassName = '' }) {
constructor({ lyric = '', lineClassName = '', fontClassName = '', lineModeClassName = '', shadowContent = false, shadowClassName = '' }) {
this.lyric = lyric
this.className = className
this.lineClassName = lineClassName
this.fontClassName = fontClassName
this.lineModeClassName = lineModeClassName
this.shadowContent = shadowContent
this.shadowClassName = shadowClassName
@@ -47,15 +48,18 @@ module.exports = class FontPlayer {
this.isLineMode = false
this.lineContent = document.createElement('div')
this.lineContent.style = 'position:relative;'
if (this.lineClassName) this.lineContent.classList.add(this.lineClassName)
this.fontContent = document.createElement('div')
this.fontContent.style = 'position:relative;'
this.fontContent.className = this.className
if (this.fontClassName) this.fontContent.classList.add(this.fontClassName)
if (this.shadowContent) {
this.fontShadowContent = document.createElement('div')
this.fontShadowContent.style = 'position:absolute;top:0;left:0;width:100%;z-index:-1;'
this.fontShadowContent.className = this.shadowClassName
this.fontContent.appendChild(this.fontShadowContent)
this.lineContent.appendChild(this.fontShadowContent)
}
this.lineContent.appendChild(this.fontContent)
this._parseLyric()
}