Commit Graph
301 Commits
Author SHA1 Message Date
john-okeefe 60332911e6 Fix right iframe zoom and improve pan/drag behavior in fixed-layout e-books
This commit addresses several issues with zoom and pan functionality,
particularly when zooming from the right iframe in a two-page spread:

- Add source iframe tracking to wheel and mouse events
  * Pass frameId parameter through frame creation pipeline
  * Tag events with sourceIframe and sourceFrame properties
  * Enable proper cursor position calculation regardless of event source

- Fix zoom cursor calculation for two-page spreads
  * Calculate cursor position relative to spread viewport, not individual pages
  * Simplify scroll position calculation to work uniformly for both left and right pages
  * Add debug logging for cursor calculation verification

- Improve drag/pan behavior across zoom modes
  * Add draggable state property to control drag availability
  * Handle fit-page mode differently with dragOffset tracking
  * Direct scroll manipulation for zoom levels above 1
  * Add console logging for ignored drag scenarios

- Prevent native image drag interference
  * Set draggable="false" on all images in iframe documents
  * Disable user select and webkit drag on images
  * Prevent default behavior on iframe mouse events

These changes ensure that zoom operations work correctly from both left and
right iframes, maintaining proper cursor focus and scroll position.
2026-04-17 16:56:18 -04:00
john-okeefe 5b822b682b Fix drag offset calculation and scrolling behavior in FixedLayout component
This commit fixes several issues with the drag functionality in the FixedLayout
component to ensure smooth and accurate dragging behavior:

Changes:
- Initialize dragOffset to (0, 0) instead of scroll position when drag starts
- Fix drag offset calculation direction (changed from -= to +=)
- Add proper scroll position updates during drag operations
- Ensure dragOffset is reset to (0, 0) when drag completes

The previous implementation was incorrectly initializing dragOffset with the
current scroll position, which caused the drag offset to compound with scroll
position and led to incorrect rendering. The new approach starts drag offset
at zero and directly updates the scroll position during drag operations.

This ensures that:
1. Drag movements are accurately tracked relative to the drag start point
2. Scroll position is properly synchronized with drag movements
3. Drag state is cleanly reset when drag operations complete
2026-04-17 11:02:26 -04:00
john-okeefe 3f9ab7528b Implement zoom control functionality for fixed-layout e-books
This commit adds comprehensive zoom control capabilities for fixed-layout
e-book content, allowing users to zoom in, out, and reset zoom levels for
better readability and content inspection.

Key features added:
- Zoom control UI with +/- buttons and percentage display
- Keyboard shortcuts for zoom operations (Ctrl/Cmd +, -, 0)
- Mouse wheel zoom with Ctrl/Cmd modifier key
- Drag-to-pan functionality when zoomed in
- Smooth zoom transitions and state management
- Zoom constraints (min/max limits) to prevent over-zooming

Changes include:
- FixedLayout: Enhanced with zoom state management, drag handlers,
  and keyboard/mouse event listeners for intuitive zoom control
- Reader UI: Added zoom control toolbar with visual feedback
- FixedLayout renderer integration with reader zoom controls

The zoom controls provide a seamless experience for users who need to
examine fixed-layout content more closely or adjust content size for
their preferred reading experience.
2026-04-16 21:37:54 -04:00
Zeedif 76dcd8f0f7 OPDS: support non-standard and legacy link relations (#126) 2026-04-10 16:29:25 +00:00
John Factotum 5ba02c71c9 TTS: fix error & nodes getting skipped
Fixes #115
2026-04-09 05:22:49 +08:00
ArtificialSloth 6e13f240f7 Add draw options for search matches (#122) 2026-04-08 15:10:47 +00:00
LarzansandLars E. 9a676796f7 Fix MOBI anchors being calculated too late (#118)
The MOBI6.init() method builds #fileposList (the map of all filepos byte-offset references, used to insert <a id="fileposXXXX"> anchors into section HTML) after calling getGuide() and the TOC-section loader — both of which call createDocument() → loadText(), which caches the section HTML. Since #fileposList is still empty at that point, the cached HTML has no anchor elements.

Later, when Foliate calls getElementById('filepos12345') on the cached (anchor-less) document, it returns null, so the paginator falls back to ?? 0 — i.e. scroll to position 0 = first page.

For EPUB this doesn't happen because chapters are separate files; navigation loads a new section by index, not by searching for an anchor element within one section.

Co-authored-by: Lars E. <lars@ermert.es>
2026-04-03 16:01:12 +00:00
John Factotum 399248a67a Run eslint --fix 2026-03-05 16:36:03 +08:00
John Factotum 1217096245 Update PDF.js to 5.5.207
Fixes https://github.com/johnfactotum/foliate-js/issues/85
2026-03-05 15:52:38 +08:00
Francesco Martini ab5abb9dd4 EPUB: Add pageBreakSource metadata property (#109) 2026-03-05 06:05:25 +00:00
John Factotum 3393b85c80 CBZ: sort pages numerically
Fixes https://github.com/johnfactotum/foliate/issues/1549
2026-03-05 14:02:01 +08:00
fondoger b74d50e6d4 Fix: selections inside FILTER_SKIP wrappers must preserve offsets (#101) 2026-03-05 05:45:31 +00:00
John Factotum 675fdafeeb Update dependencies 2026-03-05 06:08:53 +08:00
John Factotum a70ad3a10f EPUB: support multiple publishers
This also fixes https://github.com/johnfactotum/foliate/issues/1633
2026-03-05 05:52:35 +08:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> b0c02a5221 Bump rollup from 4.24.0 to 4.59.0 (#113)
Bumps [rollup](https://github.com/rollup/rollup) from 4.24.0 to 4.59.0.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v4.24.0...v4.59.0)

---
updated-dependencies:
- dependency-name: rollup
  dependency-version: 4.59.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-04 19:50:43 +00:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> fd20452d31 Bump tar and pdfjs-dist (#111)
Removes [tar](https://github.com/isaacs/node-tar). It's no longer used after updating ancestor dependency [pdfjs-dist](https://github.com/mozilla/pdf.js). These dependencies need to be updated together.


Removes `tar`

Updates `pdfjs-dist` from 4.7.76 to 4.10.38
- [Release notes](https://github.com/mozilla/pdf.js/releases)
- [Commits](https://github.com/mozilla/pdf.js/compare/v4.7.76...v4.10.38)

---
updated-dependencies:
- dependency-name: tar
  dependency-version: 
  dependency-type: indirect
- dependency-name: pdfjs-dist
  dependency-version: 4.10.38
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-04 19:50:24 +00:00
Huang Xin 6b11e17443 Properly handle empty fragments for MOBI (#107) 2025-11-28 22:39:57 +00:00
John Factotum c49ded0cc4 Fix indentation 2025-09-24 14:05:30 +08:00
John Factotum 26788cdae9 EPUB: support srcset
Closes #98
2025-09-24 14:01:27 +08:00
Huang Xin b1f72c0395 Fixed multibyte characters in MOBI fragment selectors (#99) 2025-09-23 15:22:33 +00:00
Huang Xin bdae473012 Add custom event for loading manifest item (#76) 2025-08-01 23:44:52 +00:00
Huang Xin 9fd2209b4d Fix blocked animate when running in background (#80) 2025-08-01 23:43:27 +00:00
Huang Xin 55c0027d11 Speed up text sectioning for large MOBI books (#92) 2025-08-01 23:19:23 +00:00
Huang Xin f1d4a4290d Fixed multibyte characters in MOBI fragment selectors (#91)
For Chinese/CJK text, multibyte character offsets
were being incorrectly used as bytes offsets after decoding
2025-08-01 23:17:33 +00:00
Huang Xin 0d4a92ae75 Add optional highlight function when initializing TTS (#82) 2025-06-16 17:28:18 +00: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
Huang Xin 4ee127d88f Textwalker with optional filter func parameter (#77) 2025-06-10 12:45:43 +00:00
Huang Xin d7affcf969 Create ID lookup cache for manifest (#75) 2025-06-10 12:09:54 +00:00
Huang Xin f2d32152df Add transform target for KF8 files (#74) 2025-06-10 10:43:34 +00:00
John Factotum 76527e8324 Create eslint.yml (#72) 2025-05-31 04:32:22 +00: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
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
Protected 55f1a28406 Prevent exception on Firefox due to getSelection returning null (#57) 2025-05-13 12:49:18 +00:00
John Factotum 052123beaf Add an EventTarget for transforming the book
And use it to do paginator-specific CSS replacements.

And use it to catch loading errors in reader.js.

Fixes #14
Closes #18
2025-03-29 15:09:23 +08:00
John Factotum d4696cea4b FB2: only check <binary>s when getting data
Fixes https://github.com/johnfactotum/foliate/issues/1492
2025-03-12 17:28:30 +08:00
Ray-D-Song e2014ee753 Fix selection handling in Paginator component (#46) 2025-02-13 07:52:19 +00:00
Huang Xin 27f8b57d05 Init view TTS with text segmentation granularity (#47)
in order to support more TTS backends

This PR also fixes a potential off-by-one error at the end boundary of the segment using `sentence` granularity.
2025-02-13 07:52:03 +00:00
John Factotum 34b9079a1b Fix comparing CFIs with different number of !s
Fixes #45
2024-12-21 04:56:43 +08:00
John Factotum 63a5dbf3e3 Don't scroll to anchor if caret's moved by pointer
In Safari, clicking on links triggers `selectionchange`. Since we do not
move the caret when flipping through pages, when you have flipped to the
next or previous pages and click on any link, it would take you back to
the caret instead of activating the link.

Note that the bug occurs in Safari 17 but not in WebKitGTK 2.46.

Not sure if there's a way to fix this and still retain the "set anchor
to caret on click" behavior. But I guess this behavior isn't really that
essential, anyway. So removing it for now.

Fixes #44
2024-12-12 09:35:33 +08:00
John Factotum cc2882ff39 Update README.md
Reflect the changes after 022ea7da87, and
other clarifications.
2024-12-02 18:39:45 +08:00
John Factotum 2e30f3db35 Footnotes: improve superscript detection 2024-12-02 17:57:01 +08:00
John Factotum 6f8eb1b85b Fix missing trailing comma 2024-12-02 09:54:55 +08:00
John Factotum 936c4f78e5 FB2: fix tables
Fixes https://github.com/johnfactotum/foliate/issues/1445
2024-12-02 09:47:58 +08: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 24187b79f9 EPUB: fix opf:file-as
Fixes #39
2024-11-03 11:19:14 +08:00
John Factotum 519c0329b2 PDF: improve metadata 2024-10-18 13:42:49 +08:00