Skip to content

fix: sprite thumbnail rendering — use height-based scaling and top-align#22

Closed
patrick3399 wants to merge 1 commit intomainfrom
fix/sprite-thumbnail-rendering
Closed

fix: sprite thumbnail rendering — use height-based scaling and top-align#22
patrick3399 wants to merge 1 commit intomainfrom
fix/sprite-thumbnail-rendering

Conversation

@patrick3399
Copy link
Copy Markdown
Owner

Problem

Thumbnails in the Reader bottom strip (ThumbnailStrip) and Gallery detail preview grid (PreviewGrid) were either split (showing adjacent sprite cells) or obscured by black areas.

Root Cause

E-Hentai uses CSS sprite sheets for preview thumbnails. The frontend rendering had two bugs:

  1. �ackgroundSize: auto px — The computed height was larger than the container (e.g. 70px in a 64px container), causing the sprite to overflow
  2. �ackgroundPosition: ... center — Vertical centering misaligned the sprite, showing parts of adjacent cells or black padding

Fix

  • Use backgroundSize: auto 100% so sprite height exactly matches the container
  • Use backgroundPosition: Xpx 0px (top-aligned) to prevent vertical centering misalignment
  • Recalculate X offset using height-based scale factor (since auto 100% makes the browser scale proportionally from height)

Files Changed

  • pwa/src/components/Reader/index.tsxThumbnailStrip component
  • pwa/src/app/browse/[gid]/[token]/page.tsxPreviewGrid component

Thumbnails in ThumbnailStrip (Reader) and PreviewGrid (gallery detail)
were split across cells or obscured by black areas due to incorrect
CSS sprite scaling.

Root cause:
- backgroundSize used 'auto {computed}px' which produced a height
  larger than the container
- backgroundPosition used 'center' for vertical alignment, causing
  the sprite to be vertically offset and show adjacent cells or
  black padding

Fix:
- Use 'backgroundSize: auto 100%' so sprite height exactly matches
  the container
- Use 'backgroundPosition: Xpx 0px' (top-aligned) to prevent
  vertical centering misalignment
- Recalculate X offset using height-based scale factor since the
  browser scales proportionally from height with auto 100%
@patrick3399 patrick3399 closed this Mar 8, 2026
@patrick3399 patrick3399 deleted the fix/sprite-thumbnail-rendering branch March 9, 2026 12:39
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