Parcourir la source

对歌词的优化

onecold il y a 7 mois
Parent
commit
ab9cbd2f22
1 fichiers modifiés avec 5 ajouts et 18 suppressions
  1. 5 18
      lib/src/main/ets/view/LyricView2.ets

+ 5 - 18
lib/src/main/ets/view/LyricView2.ets

@@ -60,11 +60,9 @@ export struct LyricView2 {
     @State isHighlightBold: boolean = false
     @State alignMode: 'left' | 'center' = 'center'
     @State emptyHint: string = ''
-    @State cacheSize: number = 0
+    @State cacheSize: number = 3
     @State animDuration: number = 300
     @State isUserTouching: boolean = false
-    private centerOffsetSize: number = 0
-    // seek action: center line view
     @State seekPosition: number = -1
     @State scrollDurationText: string = '00:00'
     @State seekIndex: number = -1
@@ -111,10 +109,10 @@ export struct LyricView2 {
                         this.listAdapter.addData(line, false);
                     });
                     // fill the bottom empty gap
-                    let last = lyricLines[lyricLines.length - 1].nextTime;
-                    for (let i = 0; i < this.centerOffsetSize; i++) {
-                        this.listAdapter.addData(new LyricLine(' ', last + i, last + i), false);
-                    }
+                    // let last = lyricLines[lyricLines.length - 1].nextTime;
+                    // for (let i = 0; i < this.centerOffsetSize; i++) {
+                    //     this.listAdapter.addData(new LyricLine(' ', last + i, last + i), false);
+                    // }
 
                 }
 
@@ -126,7 +124,6 @@ export struct LyricView2 {
         this.isLyricEmpty = this.listAdapter.isEmpty();
         this.currentIndex = 0;
         this.animateToIndex(0);
-        printW('loadData isEmpty = ' + this.isLyricEmpty);
 
     }
 
@@ -242,10 +239,6 @@ export struct LyricView2 {
             curve: curves.springCurve(100, 10, 80, 10),
             duration: 500
         })
-        // .transition(TransitionEffect.asymmetric(
-        //      this.isSingleLine? TransitionEffect.scale({ x: 1.2, y: 1.2 }).animation({ duration: 500 }):
-        //      TransitionEffect.move(TransitionEdge.BOTTOM).animation({ duration: 500 }),
-        //     TransitionEffect.scale({ x: 0, y: 0 })  ))
         .visibility(this.isLoadingData ? Visibility.Hidden : Visibility.Visible)
         .onScrollIndex((_, __, center) => {
             const now = Date.now()
@@ -630,9 +623,6 @@ export struct LyricView2 {
             } else {
                 this.LyricListView()
             }
-            if (this.seekUIStyle == 'seekLine') {
-                this.SeekLine()
-            }
         }
         .width('100%')
         .height('100%')
@@ -640,9 +630,6 @@ export struct LyricView2 {
             printW('onSizeChanged: ' + JSON.stringify(newSize))
             this.h = newSize.height as number
             this.w = newSize.width as number
-            let lineH = this.textSize + this.lineSpace
-            this.centerOffsetSize = Math.floor((this.h - lineH) / 2 / lineH)
-            printW('offsetSize = ' + this.centerOffsetSize)
             if (this.currentLyric) {
                 this.loadData(this.currentLyric)
             }