减少歌词定时器调用阈值

pull/1446/merge
lyswhut 2023-07-30 12:32:12 +08:00
parent 2a8bfac2c5
commit cfe78fc387
2 changed files with 4 additions and 3 deletions

View File

@ -69,8 +69,8 @@ module.exports = class FontPlayer {
this.lineContent = null
this.timeoutTools = new TimeoutTools(80)
this.waitPlayTimeout = new TimeoutTools(80)
this.timeoutTools = new TimeoutTools(50)
this.waitPlayTimeout = new TimeoutTools(50)
this._init()
}

View File

@ -2,7 +2,7 @@
const getNow = exports.getNow = typeof performance == 'object' && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date)
exports.TimeoutTools = class TimeoutTools {
constructor(thresholdTime = 200) {
constructor(thresholdTime = 80) {
this.invokeTime = 0
this.animationFrameId = null
this.timeoutId = null
@ -17,6 +17,7 @@ exports.TimeoutTools = class TimeoutTools {
// console.log('diff', diff)
if (diff > 0) {
if (diff < this.thresholdTime) return this.run()
// console.log('run timeout', diff, diff - this.thresholdTime)
return this.timeoutId = window.setTimeout(() => {
this.timeoutId = null
this.run()