Ensure book details and book readers start with window scrolled to top

This commit is contained in:
Kovid Goyal 2017-05-11 19:11:54 +05:30
parent 67f95c3e1d
commit fdb98fdb4e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 0 deletions

View File

@ -449,6 +449,7 @@ def check_for_books_loaded():
def init(container_id): def init(container_id):
container = document.getElementById(container_id) container = document.getElementById(container_id)
create_top_bar(container, title=_('Book details'), action=back, icon='close') create_top_bar(container, title=_('Book details'), action=back, icon='close')
window.scrollTo(0, 0) # Ensure we are at the top of the window
container.appendChild(E.div(class_=CLASS_NAME)) container.appendChild(E.div(class_=CLASS_NAME))
container.lastChild.appendChild(E.div(_('Loading books from the calibre library, please wait...'), style='margin: 1ex 1em')) container.lastChild.appendChild(E.div(_('Loading books from the calibre library, please wait...'), style='margin: 1ex 1em'))
conditional_timeout(container_id, 5, check_for_books_loaded) conditional_timeout(container_id, 5, check_for_books_loaded)

View File

@ -415,6 +415,7 @@ class ReadUI:
current_state = self.url_data current_state = self.url_data
same = current_query.library_id is current_state.library_id and str(current_query.book_id) is str(current_state.book_id) and current_query.fmt is current_state.fmt same = current_query.library_id is current_state.library_id and str(current_query.book_id) is str(current_state.book_id) and current_query.fmt is current_state.fmt
self.view.overlay.hide() self.view.overlay.hide()
window.scrollTo(0, 0) # Ensure we are at the top of the window
if same: if same:
if current_state.bookpos is not current_query.bookpos and current_query.bookpos: if current_state.bookpos is not current_query.bookpos and current_query.bookpos:
self.view.goto_bookpos(current_query.bookpos) self.view.goto_bookpos(current_query.bookpos)