computeScroll method

double computeScroll(
  1. int toLine,
  2. int playLine,
  3. LyricUI ui
)

Implementation

double computeScroll(int toLine, int playLine, LyricUI ui) {
  if (toLine <= 0) return 0;
  var targetLine = lyrics[toLine];
  double offset = 0;
  if (!targetLine.hasExt && !targetLine.hasMain) {
    offset += ui.getBlankLineHeight() + ui.getLineSpace();
  } else {
    offset += ui.getLineSpace();
    offset += LyricHelper.centerOffset(
        targetLine, toLine == playLine, ui, playLine);
  }
  //需要特殊处理往上偏移的第一行
  return -LyricHelper.getTotalHeight(
          lyrics.sublist(0, toLine), playLine, ui) +
      firstCenterOffset(playLine, ui) -
      offset;
}