Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to page or to annotation #65

Merged
merged 10 commits into from
Aug 30, 2024
Merged

Scroll to page or to annotation #65

merged 10 commits into from
Aug 30, 2024

Conversation

lfoppiano
Copy link
Owner

@lfoppiano lfoppiano commented Aug 16, 2024

This PR proposes a simple method to scroll down to a specific page or an annotation. Since Streamlit has quite a complex approach which reload at each interaction, it makes hard for any component to handle the scrolling in a customized way.

With this PR we added two additional parameters: scroll_to_page and scroll_to_annotation (mutually exclusive, scrol_to_page has priority) which require an integer in input. The integer represent the positional item (page or annotation) from 1 to n.

In order to know in advance number of pages and annotations, the pdf_viewer(...) call returns a dict as follow:

{ 
'pages: [
   'id1', 
   'id2'
  ], 
'annotations': [
   'ann-id1', 
   'ann-id2'
  ....
]
}

Those ids are the same used in the DOM and may be used for javascript calls, however I did not manage to achieve anything with it. Nevertheless, they can be used to build a set of buttons that allow calling again the pdf_viewer with proper parameters for pages or annotations.

This PR should solve issue #24, #47, #55, and #61

@lfoppiano lfoppiano requested a review from t29mato August 16, 2024 15:29
@lfoppiano lfoppiano added the enhancement New feature or request label Aug 16, 2024
@lfoppiano lfoppiano marked this pull request as ready for review August 18, 2024 19:02
@lfoppiano lfoppiano merged commit d5e1d8f into main Aug 30, 2024
14 checks passed
@lfoppiano lfoppiano deleted the scroll-to-html-id branch August 30, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant