Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions pwa/src/app/browse/[gid]/[token]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { RatingStars } from '@/components/RatingStars'
import { toast } from 'sonner'
import { t } from '@/lib/i18n'
import { ArrowLeft, ChevronDown, ChevronUp } from 'lucide-react'

Check warning on line 11 in pwa/src/app/browse/[gid]/[token]/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend Lint

'ChevronUp' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 11 in pwa/src/app/browse/[gid]/[token]/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend Lint

'ChevronDown' is defined but never used. Allowed unused vars must match /^_/u
import type { EhComment } from '@/lib/types'

Check warning on line 12 in pwa/src/app/browse/[gid]/[token]/page.tsx

View workflow job for this annotation

GitHub Actions / Frontend Lint

'EhComment' is defined but never used. Allowed unused vars must match /^_/u

// ── Preview grid with scaled sprite offsets ─────────────────────────────

Expand Down Expand Up @@ -39,11 +39,10 @@
return (
<div ref={gridRef} className="grid grid-cols-3 sm:grid-cols-6 gap-2">
{thumbs.map((thumb) => {
// Scale based on width only — backend normalizes sprite heights.
const tw = thumb.width ?? 200
// Scale X offset using height-based ratio — auto 100% forces sprite
// height to match the container, so X offset must use the same ratio.
const th = thumb.height ?? 300
const scale = cellSize.w ? cellSize.w / tw : 1
const scaledH = th * scale
const hScale = cellSize.h ? cellSize.h / th : 1
return (
<button
key={thumb.page}
Expand All @@ -56,8 +55,8 @@
className="w-full h-full"
style={{
backgroundImage: `url(${thumb.url})`,
backgroundPosition: `${(thumb.offsetX ?? 0) * scale}px center`,
backgroundSize: `auto ${scaledH}px`,
backgroundPosition: `${(thumb.offsetX ?? 0) * hScale}px 0px`,
backgroundSize: `auto 100%`,
backgroundRepeat: 'no-repeat',
}}
/>
Expand Down
11 changes: 6 additions & 5 deletions pwa/src/components/Reader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,14 @@ function ThumbnailStrip({ images, currentPage, onPageSelect, previews }: Thumbna
const ox = Number(parts[1])
const cellW = Number(parts[2]) || 200
const cellH = Number(parts[3]) || 300
// Scale based on width only — backend normalizes sprite heights.
const scale = 48 / cellW
const scaledOx = ox * scale
// Scale based on container height (64px) — auto 100% forces sprite
// height to match the container, so X offset must use the same ratio.
const hScale = 64 / cellH
const scaledOx = ox * hScale
spriteStyle = {
backgroundImage: `url(/api/eh/thumb-proxy?url=${encodeURIComponent(spriteUrl)})`,
backgroundPosition: `${scaledOx}px center`,
backgroundSize: `auto ${cellH * scale}px`,
backgroundPosition: `${scaledOx}px 0px`,
backgroundSize: `auto 100%`,
backgroundRepeat: 'no-repeat',
width: '100%',
height: '100%',
Expand Down
Loading