* 绑定歌词事件
()
| 959 | * 绑定歌词事件 |
| 960 | */ |
| 961 | bindLyrics() { |
| 962 | if (this.bindingFlags.lyrics || !this.dom.lyricsDisplay) return; |
| 963 | this.bindingFlags.lyrics = true; |
| 964 | |
| 965 | delegate(this.dom.lyricsDisplay, 'click', '.lyric-line', (event) => { |
| 966 | // 使用 event.target.closest 获取实际的歌词行元素 |
| 967 | // event.currentTarget 指向绑定事件的父容器,而非被点击的 .lyric-line |
| 968 | const lyricLine = event.target.closest('.lyric-line'); |
| 969 | if (lyricLine) { |
| 970 | this.handleLyricActivate(lyricLine); |
| 971 | this.state.sentence = false; |
| 972 | } |
| 973 | }); |
| 974 | |
| 975 | delegate(this.dom.lyricsDisplay, 'keydown', '.lyric-line', (event) => { |
| 976 | if (event.key !== 'Enter' && event.key !== ' ') return; |
| 977 | event.preventDefault(); |
| 978 | |
| 979 | // 使用 event.target.closest 获取实际的歌词行元素 |
| 980 | const lyricLine = event.target.closest('.lyric-line'); |
| 981 | if (lyricLine) { |
| 982 | this.handleLyricActivate(lyricLine); |
| 983 | this.state.sentence = false; |
| 984 | } |
| 985 | }); |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * 绑定播放器控制事件 |
no test coverage detected