Commit Graph
29 Commits
Author SHA1 Message Date
john-okeefe fc9d0ecafb Improve panel mode exit cleanup
When exiting panel mode, now properly resets:
- Remove zoom attribute to clear any zoom state
- Scroll to top position to reset viewport

This ensures a clean state when transitioning back to regular reading mode.
2026-04-13 20:43:46 -04:00
john-okeefe 3373506ed2 Add panel navigation support to fixed-layout renderer
Implement comprehensive panel-aware navigation for manga, comics,
and other fixed-layout content with automatic panel detection.

Core features:
- Panel mode toggle via 'panel-mode' attribute
- Touch gesture support (swipe, tap)
- Visual panel overlay with SVG highlighting
- Auto-zoom to center and fit each panel
- Seamless integration with existing page navigation

Panel detection integration:
- Initialize PanelDetector on component construction
- Detect panels when entering panel mode
- Cache detection results per page
- Support re-detection via force flag

Panel navigation:
- nextPanel(): advance to next panel, wrapping to next page
- prevPanel(): go to previous panel, wrapping to previous page
- Auto-enter panel mode on first panel navigation
- Visual feedback with current panel highlighting

Touch support (previously missing from fixed-layout):
- touchstart: record initial position and timestamp
- touchmove: prevent default for significant movement
- touchend: velocity-based swipe detection
- Panel mode: tap to toggle overlay, swipe to navigate

Visual overlay:
- SVG rectangles showing detected panels
- Highlight current panel in orange (#ff6b35)
- Dim other panels in semi-transparent white
- Pointer-events none for non-blocking overlay

Zoom behavior:
- Calculate scale to fit panel within viewport
- Center panel with scroll positioning
- Apply via existing zoom attribute mechanism
- Re-render overlay after zoom

Internal methods:
- #nextPage() / #prevPage(): bypass panel-mode check
- #enterPanelMode() / #exitPanelMode(): mode management
- #showPanelOverlay() / #hidePanelOverlay(): overlay management
- #zoomToPanel(): auto-center and scale to panel
- #addTouchSupport(): attach touch event listeners
- #onTouchStart/Move/End: touch gesture handling
- #handlePanelTouch: panel-mode specific touch logic

Public API:
- panelCount: number of detected panels
- currentPanelIndex: current panel index
- togglePanelMode(): enter/exit panel mode

Observer attributes:
- 'zoom': existing zoom support
- 'panel-mode': new panel mode attribute

This implementation brings fixed-layout renderer to feature parity
with paginator.js regarding touch support while adding unique
panel-aware navigation capabilities.
2026-04-13 16:43:40 -04:00
John Factotum b26cde2527 FXL: don't use book viewport if it's empty
Fixes https://github.com/johnfactotum/foliate-js/issues/52#issuecomment-2956113877
2025-06-10 20:51:27 +08:00
John Factotum 12dd11d1aa Run eslint --fix 2025-05-31 12:24:30 +08:00
Protected 1fe4803888 Mitigate fixed-layout exception on render when there's no available source for blankWidth and blankHeight (#70) 2025-05-31 04:18:01 +00:00
Protected 42dea3be3d Fix for fixed-layout transform anchor point in RTL context. (#68)
If the viewer is running in an RTL context (this is not the same as the
reading direction of the Book itself), and a fixed-layout rendered view
is scaled (which is often the case), anchoring the transform to the
left breaks page positioning.
2025-05-31 03:52:04 +00:00
Protected ed6400ddcb Re-render single pages when paginating fixed layout (#61) 2025-05-30 08:46:42 +00:00
Protected 9fc0b62803 Fix for FixedLayout.index returning incorrect values depending on position in spread. (#59) 2025-05-13 13:18:03 +00:00
John Factotum b82ec0b294 FXL: add zoom setting
The value of the `zoom` attribute can be either `"fit-page"` (default),
`"fit-width"`, or a number.
2024-10-11 06:41:32 +08:00
John Factotum 1e952102bd PDF: rerender when scale changes
The fixed-layout renderer now accepts an object for the return value of
`load()` (on the `book.sections` items). If it's an object, the `src`
is the URL of the section, and `onZoom`, if present, will be called
when the viewport is zoomed. With this you can scale the page yourself
rather than relying on the renderer's own scaling with CSS transform.

Also upgraded to PDF.js 4.6.82. And now internal links are broken...
Don't know how to fix that yet.
2024-09-28 12:12:59 +08:00
John Factotum b5d0453004 FXL: ignore linear & default to odd pages right
This matches the behavior of other reading systems. See
https://github.com/johnfactotum/foliate/issues/1318#issuecomment-2349375230
2024-09-14 01:21:54 +08:00
John Factotum 819106c71f FXL: fix getting viewport from SVGs 2023-10-08 20:40:16 +08:00
John Factotum 83e709f575 FXL: fix page turning around blank pages 2023-09-09 15:55:01 +08:00
John Factotum 5e0f319382 FXL: fix scaling for page-spread-center 2023-09-09 15:49:07 +08:00
John Factotum 0cebcb93c4 FXL: fix spreads when first section is center 2023-09-09 14:34:43 +08:00
John Factotum 99e246ecb8 FXL: hide empty iframes 2023-09-09 14:34:27 +08:00
John Factotum df95960f82 Expose relocation reason
And fix history not updated when scrolling in scroll mode
2023-08-17 15:18:20 +08:00
John Factotum 57ab79d598 Replace deselect with more general content access method 2023-05-16 19:12:26 +08:00
John Factotum 0a3f4b8f27 Use Shadow DOM 2023-05-15 20:00:35 +08:00
John Factotum 4acfc050ea Turn View into a custom element, and use DOM events
Also change "relocated" -> "relocate"
2023-05-15 15:27:18 +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 41c00942d2 Further reduce header and footer styles
Instead, provide classes.

Also: prefix all classes with `foliate-`.
2023-05-03 17:31:22 +08:00
John Factotum bc1f799c44 FXL: sandbox the iframes 2023-03-30 16:21:28 +08:00
John Factotum 6d2caaad5b FXL: fix container, which should not span whole viewport 2023-03-26 03:58:04 +08:00
John Factotum b6acb4ff5c FXL: fix onLoad callback
Also add deselect method.
2023-03-08 11:40:18 +00:00
John Factotum a11fd9637d FXL: support spread both and portrait
Also fix `page-spread-center` in portrait
2022-10-29 16:45:17 +00:00
John Factotum 3aad499696 FXL: page-spread-center and spread none 2022-10-29 16:10:56 +00:00
John Factotum e74ad4311f FXL: fix overflowing
Which for some reason only happens in Firefox
2022-10-21 10:39:55 +00:00
John Factotum 5fc72d121c Add files via upload 2022-10-18 18:55:54 +00:00