Skip to content

feat(navigation): expose goToPage, getCurrentPage and page-change event - #176

Draft
lfals wants to merge 2 commits into
LibreSign:mainfrom
lfals:feat/page-navigation
Draft

lfals wants to merge 2 commits into
LibreSign:mainfrom
lfals:feat/page-navigation

Conversation

@lfals

@lfals lfals commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Refs: LibreSign/libresign#1863

📝 Summary

The viewer only scrolls continuously and shows a page counter, so hosts cannot build pagination controls or page thumbnails. This adds a small navigation API.

API Responsibility
goToPage(pageIndex, docIndex = 0) Scrolls the page to the top of the viewer; returns false for unknown pages
getCurrentPage() Page occupying most of the viewport, or null
pdf-elements:page-change Emitted when that page changes (scroll and initial load), payload { docIndex, pageIndex }

Also exports PDFElementsPageChangePayload and documents the API in docs/API.md. Thumbnails are handled in a follow-up PR stacked on this one.

🧪 How to test

npm run typecheck && npm run lint && npm run test

Expected: 119 tests pass, including goToPage, invalid pages and page-change de-duplication.

Lets hosts build pagination controls and page thumbnails without relying
on internal DOM structure.

Signed-off-by: Luis Amorim <principal@felps.zip>
@lfals
lfals requested a review from a team as a code owner November 25, 2026 21:29
@lfals
lfals marked this pull request as draft November 25, 2026 21:36
- track rendered pages and ignore placeholder-sized ones in getCurrentPage
- make goToPage return false until the target page has rendered
- recompute the current page after page (re)measure, which covers zoom
- keep the requested page current when the scroll range is clamped
- read only pages around the viewport instead of every page per frame
- cover multi-document, unrendered page and clamp cases in tests

Signed-off-by: Luis Amorim <principal@felps.zip>

This branch has not been deployed

No deployments
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