Skip to content

perf: stop redrawing the sunburst on hover - #4

Merged
whes1015 merged 1 commit into
mainfrom
perf/sunburst-hover
Oct 20, 2026
Merged

whes1015 merged 1 commit into
mainfrom
perf/sunburst-hover

Conversation

@whes1015

Copy link
Copy Markdown
Member

這個 PR 做了什麼

旭日圖在扇區之間移動時會整頁重畫,每個扇區的淡出動畫也會重跑。角度、顏色、透明度、提示框和點進去的行為維持原樣。

  • 正式程式碼只動 src/app/analyze/page.tsx
  • 弧線在建立圖層時算一次,畫的時候直接用算好的 path。換扇區不再重跑 sin/cos
  • hover 不再讓整頁 setState 之後走訪每一個扇區改 class。變淡是 svg 上的一個 class;換扇區只拿掉上一個、加上現在這個
  • 提示框位置沿用原本的左右/上下判斷。移動時用上次量到的寬高,不再每個 mousemove 讀 offsetWidth
  • 檔案列表的對應列仍會亮起。列表用父層 class 變淡,捲動後新掛上的列也會跟著變淡
  • 點進資料夾會關掉上一層的提示框。以前那個 state 會留在新的圖上

幾何是同一組式子。8 層半徑、起角每 7°、張角 2/15/90/181/360 度,共 2080 組,字串不一致 0 筆。1620 段弧建一次約 0.49 ms;若每次換扇區都重算,30 次約 40.2 ms(平均 1.34 ms)。這是 Apple M4 Max 上的 bun,只量幾何,不含 DOM。舊實作另外還會對每個扇區改 class,並讓 opacity transition 重跑。

沒有改掃描,也沒有改配色公式。沒有在 Tauri 視窗裡掃過目錄看圖。

相關 issue

沒有對應的 issue。接續 #3。

怎麼驗

  • bunx tsc --noEmit 通過
  • bun run build 通過
  • 幾何字串對照 2080 組,0 筆不一致
  • 尚未在 Tauri 裡看過圖:請掃一個多層目錄,確認扇區顏色、角度、「其他」與可用空間、滑過時其他扇區淡到 0.15、目前這個是 1、提示框跟檔案列表還對得起來,點資料夾會進去

檢查清單

  • tool/check/commits.sh:這個 repo 沒有這支腳本
  • 一個 commit 一件事
  • flutter analyze / flutter test:這是 Tauri / Next,不適用。代替的是上面的 tsc 和 next build
  • 沒有新增使用者可見字串
  • CI:workflow 只在對 main 的 PR 跑,這個 PR 的 base 是 perf/simplify-hot-paths,所以現在不會跑。本機 bun run build 已過
  • 實機看過圖:還沒有。透明度仍是圖 0.15/1、列表 0.3/1,顏色和角度沒改

Moving across a wedge rebuilt every arc and restarted the opacity transition on all of them. Arcs are built once, and hover only updates the active wedge.
Base automatically changed from perf/simplify-hot-paths to main October 20, 2026 00:11
@whes1015
whes1015 merged commit a226f85 into main Oct 20, 2026
@whes1015
whes1015 deleted the perf/sunburst-hover branch October 20, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant