Skip to content

fix(zoom-ui): align screenshot button + Ruby zoom column with scratch-blocks v2#639

Merged
takaokouji merged 1 commit into
feat/upstream-merge-2026-05from
fix/zoom-ui-screenshot-button-position
May 5, 2026
Merged

fix(zoom-ui): align screenshot button + Ruby zoom column with scratch-blocks v2#639
takaokouji merged 1 commit into
feat/upstream-merge-2026-05from
fix/zoom-ui-screenshot-button-position

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

scratch-blocks v2 で zoom controls の位置が変わったため、Code タブの命令ブロック撮影ボタン(カメラアイコン)と Ruby タブの zoom UI カラムの位置を再調整。

Background

過去 (Mar 8, 2026) の v2 対応 commit a27336b3e6 でも同様の調整が入っていたが、5e5163708a で v1.3.0 互換のため revert され、その後の 6f748844fd でも v1 値に戻っていた。今回の upstream merge は v2 を本採用するため再度 v2 値に戻す + 改善を行う。

Changes

1. Code タブのカメラボタン (BlocksScreenshotButton)

  • CSS-only から runtime measurement へ: useLayoutEffect + ResizeObserver.blocklyZoomIn 要素の位置を測定し、その上 8px に揃える
  • スクロールバー幅の差 (macOS overlay vs Windows classic) や mobile / window-resize に強い
  • CSS のフォールバック値も v2 layout (MARGIN(20) + ZOOM_HEIGHT(124) + GAP(8) = bottom 152, right 20) に更新

2. Ruby タブの zoom UI カラム (zoomControlsWrapper)

  • right: 22/bottom: 22right: 31/bottom: 31
  • v2 zoom controls の見た目 X/Y 座標 (= MARGIN 20 + scratch-blocks scrollbar 11) と一致させる
  • Code タブとの切替時の視覚的なジャンプを 1px 以内に抑制

3. クリーンアップ

.downloadButton / .downloadIcon / .downloadWrapper の使われていない CSS rule を削除(ruby-tab.jsx から既に参照されていなかった)

Test plan

  • Code タブ: カメラボタンが zoom-in と同じ X 列、8px 上に表示 (1500x800)
  • Code タブ: 800x700 リサイズでも整列維持 (right: aligned, gap: 8)
  • Code タブ: 812x375 (mobile landscape) でも整列維持
  • Ruby タブ: カメラ位置が Code タブと 1px 以内 (1062 vs 1061)
  • lint + prettier OK

Related

  • 過去の v2 対応 commit (revert 済み): a27336b3e6 fix: align screenshot button and ruby tab zoom with Blockly zoom controls
  • scratch-blocks v2 の zoom controls layout: ScratchZoomControls (MARGIN_VERTICAL = MARGIN_HORIZONTAL = 20, total height 124px)

…-blocks v2

scratch-blocks v2's `ScratchZoomControls` uses MARGIN_VERTICAL =
MARGIN_HORIZONTAL = 20 (vs v1's 12) inside the workspace's view metrics
(which exclude the 11px scratch-blocks scrollbar). The Code tab camera
button was hard-coded at right=22/bottom=154 — values tuned for v1 — so
it drifted off the v2 zoom column on desktop and shifted further on
mobile / window resize because scrollbar width is platform dependent.

The Ruby tab's zoom column was at right=22/bottom=22, which sat 11px
inboard of the Code tab's actual on-screen position, producing a visible
jump when switching tabs.

Fixes:

- `BlocksScreenshotButton` now measures the live `.blocklyZoomIn`
  position via `useLayoutEffect` + `ResizeObserver` and pins the camera
  button 8px above its top edge, with right edges flush. Survives
  scrollbar variance, mobile orientation, and any v2 zoom-controls
  reflow. CSS keeps right=20/bottom=152 as a one-frame fallback that
  matches the v2 layout (MARGIN(20) + ZOOM_HEIGHT(124) + GAP(8)).

- `ruby-tab.css` `.zoomControlsWrapper` moves to right=31/bottom=31
  (= MARGIN(20) + scratch-blocks scrollbar(11)) so the Ruby tab column
  lands at the same screen X/Y as the Code tab's zoom controls.
  Verified with Playwright at desktop and 800/812-wide viewports —
  camera buttons match within 1px.

Removes orphan `.downloadButton` / `.downloadIcon` / `.downloadWrapper`
rules from ruby-tab.css; ruby-tab.jsx hasn't used them since the camera
moved into `zoomControlsWrapper`.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

@takaokouji takaokouji merged commit f3cc543 into feat/upstream-merge-2026-05 May 5, 2026
9 checks passed
@takaokouji takaokouji deleted the fix/zoom-ui-screenshot-button-position branch May 5, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant