From f2776745cdf412df28d4e4520fb37bde4866a1cb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 28 Sep 2016 11:25:12 +0530 Subject: [PATCH] Fix right margin not visible on small screens such as the iPhone 5 --- src/pyj/read_book/view.pyj | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 981fe09c20..083d194535 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -140,6 +140,11 @@ class View: set_css(document.getElementById('book-bottom-margin'), height=margin_bottom + 'px') def side_margin(which, val): m = document.getElementById('book-{}-margin'.format(which)) + if which is 'left': + # Explicitly set the width of the central panel. This is needed + # on small screens with chrome, without it sometimes the right + # margin goes off the screen. + m.nextSibling.style.maxWidth = 'calc(100vw - {}px)'.format(margin_left + margin_right) set_css(m, width=val + 'px') val = min(val, 75) m.firstChild.style.width = val + 'px' @@ -204,7 +209,9 @@ class View: def on_resize(self): if self.book and self.currently_showing.name: - self.set_margins() # needed because of max text height/width + sd = get_session_data() + if sd.get('max_text_width') or sd.get('max_text_height'): + self.set_margins() def show_loading(self): title = self.book.metadata.title