Commit Graph
11 Commits
Author SHA1 Message Date
john-okeefe ea268dffbe Add webtoon (vertical-scroll) renderer for comics
New <foliate-webtoon> custom element: every page stacked in one
scrolling column (max-width 900px centered on wide screens), the
standard long-strip manga reading mode.

- Pages lazy-load through an IntersectionObserver with a 150% root
  margin so they're ready before scrolling into view; placeholders
  carry an estimated min-height until the image loads, then the real
  aspect-ratio — set on the placeholder element — so geometry stays
  stable across unloads and the scrollbar never jumps.
- Pages more than 12 positions from the reading point are unloaded
  (image removed, section blob URL revoked) to bound memory on long
  webtoons; they simply reload if the user scrolls back.
- Relocate events ({reason:'scroll', index, fraction, size:1}) fire on
  rAF-throttled scroll with the viewport-center page as index and the
  visible position within it as fraction — compatible with view.js's
  SectionProgress enrichment, so progress saving/restoring, the
  slider, and the back-stack all work unchanged.
- Renderer contract mirrors fixed-layout: goTo(await {index}) scrolls
  the page into view; next/prev page by ~one screen (view.init()'s
  fresh-start probe is a no-op that reports location); goLeft/goRight
  map to prev/next (vertical flow is direction-independent).
  No zoom/magnifier APIs — the host already gates those on the flow.
- Page images honor --fx-filter from the host for the new
  brightness/contrast/invert controls.

view.js picks the renderer when book.format === 'comic' (now tagged
by makeComicBook) and options.comic.flow === 'webtoon'.
2026-08-18 08:15:59 -04:00
john-okeefe aba68d8723 Rect annotations for fixed-layout: fraction-space overlay + hit-testing
Adds a parallel annotation pipeline for PDF/comic pages (the CFI
overlayer pipeline only exists for the reflowable paginator):

- addRectAnnotation({key, index, rects, color}) /
  removeRectAnnotation(key): rects are page-fraction [x,y,w,h]
  quads, stored per key and rendered into a full-bleed SVG injected
  into the page iframe. The SVG uses viewBox 0 0 100 100 with
  preserveAspectRatio none, so fraction rects stay aligned through
  iframe CSS-zoom (comics), the host transform-based pan/zoom, and
  PDF hi-res re-renders (pdf.js rebuilds canvas/textLayer but not
  body children) — no re-anchoring hooks needed anywhere.
- Frames carry their section index; annotations re-render into each
  freshly created iframe (#showSpread destroys and recreates frames
  on every spread change).
- Clicks are hit-tested against the fraction rects (in iframe
  coordinate space, denominator = img or documentElement bounding
  rect so PDF's devicePixelRatio transform cancels) and emit
  show-rect-annotation with host-space popover coordinates. Skipped
  while a text selection is active so drag-selecting text doesn't
  pop the editor.
- Comic page img is now display:block so the document box equals
  the image box (no inline-baseline gap inflating denominators).
2026-08-16 12:44:22 -04:00
john-okeefe e9e61d885b Touch gestures for fixed-layout: pinch-zoom, pan, swipe paging, double-tap
- Single finger: pan while zoomed; horizontal swipe pages at fit
  (direction mapped through next()/prev() so RTL manga reads
  correctly); drag on PDF text still defers to selection via the
  existing smart-detection (realTarget).
- Two fingers: pinch-zoom around the midpoint (through the shared
  zoom machinery, so PDF re-render scheduling works) plus
  midpoint-pan; lifts back to single-finger pan when one lifts.
- Double-tap: zoom 2.5x at the point / reset to fit.
- Touch events forwarded from page iframes with converted
  coordinates; preventDefault only when the engine actually consumes
  the gesture so native selection/taps stay intact.
- touch-action: none on :host and in comic/pdf page documents so the
  browser does not fight the gesture engine inside iframes.
2026-08-14 15:54:00 -04:00
john-okeefe 016b93d987 Add image-rendering: high-quality to comic book pages
Ensures browsers use highest-quality interpolation when scaling
raster comic book images during zoom. No effect on browsers that
don't support this value (they fall back to default bilinear).
2026-04-17 21:46:45 -04:00
John Factotum 3393b85c80 CBZ: sort pages numerically
Fixes https://github.com/johnfactotum/foliate/issues/1549
2026-03-05 14:02:01 +08:00
Protected 1e8080754c Generate full document for comic-book iframes in order to prevent warning spam. (#60)
Prevents the document from rendering in quirks mode unnecessarily and warnings about encoding.
2025-05-13 13:17:02 +00:00
John Factotum b5ae4c22c1 CBZ: remove body margin
Fixes https://github.com/johnfactotum/foliate/issues/1421
2024-11-04 05:37:40 +08:00
John Factotum d9da576611 CBZ: add support for AVIF
Also throw when there are no images to show
2024-01-20 12:09:02 +08:00
John Factotum 35f749dd7c CBZ: add JPEG XL support 2023-12-30 12:21:08 +08:00
John Factotum 5da3be5200 Add destroy method
Which revokes all blob URLs and removes the element from document.
2023-05-09 14:02:07 +08:00
John Factotum 5fc72d121c Add files via upload 2022-10-18 18:55:54 +00:00