mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a hacky workaround for the lack of fullscreen on the ipad
This commit is contained in:
parent
c497402864
commit
752cec5d6b
@ -300,10 +300,11 @@ class IframeBoss:
|
|||||||
self.update_toc_position()
|
self.update_toc_position()
|
||||||
|
|
||||||
def onresize(self):
|
def onresize(self):
|
||||||
|
self.send_message('request_size')
|
||||||
if self.content_ready:
|
if self.content_ready:
|
||||||
if is_ios:
|
if is_ios:
|
||||||
# On iOS window.innerWidth/Height are wrong inside the iframe
|
# On iOS window.innerWidth/Height are wrong inside the iframe,
|
||||||
self.send_message('request_size')
|
# so we wait for the reply from request_size
|
||||||
return
|
return
|
||||||
self.onresize_stage2()
|
self.onresize_stage2()
|
||||||
|
|
||||||
@ -323,7 +324,8 @@ class IframeBoss:
|
|||||||
|
|
||||||
def received_window_size(self, data):
|
def received_window_size(self, data):
|
||||||
window_width.from_parent, window_height.from_parent = data.width, data.height
|
window_width.from_parent, window_height.from_parent = data.width, data.height
|
||||||
self.onresize_stage2()
|
if self.content_ready:
|
||||||
|
self.onresize_stage2()
|
||||||
|
|
||||||
def onwheel(self, evt):
|
def onwheel(self, evt):
|
||||||
if self.content_ready:
|
if self.content_ready:
|
||||||
|
@ -22,7 +22,7 @@ from read_book.touch import set_left_margin_handler, set_right_margin_handler
|
|||||||
from read_book.toc import update_visible_toc_nodes
|
from read_book.toc import update_visible_toc_nodes
|
||||||
from read_book.goto import get_next_section
|
from read_book.goto import get_next_section
|
||||||
from book_list.theme import get_color, get_font_family
|
from book_list.theme import get_color, get_font_family
|
||||||
from utils import parse_url_params, username_key
|
from utils import parse_url_params, username_key, is_ios
|
||||||
|
|
||||||
LOADING_DOC = '''
|
LOADING_DOC = '''
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -62,6 +62,11 @@ def margin_elem(sd, which, id, onclick):
|
|||||||
)
|
)
|
||||||
if onclick:
|
if onclick:
|
||||||
ans.addEventListener('click', onclick)
|
ans.addEventListener('click', onclick)
|
||||||
|
if is_ios and which is 'margin_bottom':
|
||||||
|
# On iOS 100vh includes the size of the navbar and there is no way to
|
||||||
|
# go fullscreen, so to make the bottom bar visible we add a margin to
|
||||||
|
# the bottom bar
|
||||||
|
ans.style.marginBottom = '25px'
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
@ -140,14 +145,16 @@ class View:
|
|||||||
self.send_message('gesture_from_margin', gesture=gesture)
|
self.send_message('gesture_from_margin', gesture=gesture)
|
||||||
|
|
||||||
def iframe_size(self):
|
def iframe_size(self):
|
||||||
w, h = window.innerWidth, window.innerHeight
|
|
||||||
iframe = self.iframe
|
iframe = self.iframe
|
||||||
w -= 2 * iframe.offsetLeft
|
l, r = document.getElementById('book-left-margin'), document.getElementById('book-right-margin')
|
||||||
h -= 2 * iframe.offsetTop
|
w = r.offsetLeft - l.offsetLeft - iframe.offsetLeft
|
||||||
|
t, b = document.getElementById('book-top-margin'), document.getElementById('book-bottom-margin')
|
||||||
|
h = b.offsetTop - t.offsetTop - iframe.offsetTop
|
||||||
return w, h
|
return w, h
|
||||||
|
|
||||||
def on_request_size(self, data):
|
def on_request_size(self, data):
|
||||||
# On iOS/Safari window.innerWidth/Height are incorrect inside an iframe
|
# On iOS/Safari window.innerWidth/Height are incorrect inside an iframe
|
||||||
|
window.scrollTo(0, 0) # ensure the window is at 0 because otherwise it sometimes moves down a bit on mobile thanks to the disappearing nav bar
|
||||||
w, h = self.iframe_size()
|
w, h = self.iframe_size()
|
||||||
self.send_message('window_size', width=w, height=h)
|
self.send_message('window_size', width=w, height=h)
|
||||||
|
|
||||||
@ -279,10 +286,12 @@ class View:
|
|||||||
ans = resolve_color_scheme()
|
ans = resolve_color_scheme()
|
||||||
if apply_to_margins:
|
if apply_to_margins:
|
||||||
for which in 'left top right bottom'.split(' '):
|
for which in 'left top right bottom'.split(' '):
|
||||||
s = document.getElementById('book-{}-margin'.format(which)).style
|
m = document.getElementById('book-{}-margin'.format(which))
|
||||||
|
s = m.style
|
||||||
if which is 'top' or which is 'bottom':
|
if which is 'top' or which is 'bottom':
|
||||||
s.color = ans.foreground # Setting a color for the side margins causes the hover arrow to become visible
|
s.color = ans.foreground # Setting a color for the side margins causes the hover arrow to become visible
|
||||||
s.backgroundColor = ans.background
|
s.backgroundColor = ans.background
|
||||||
|
m.parentNode.style.backgroundColor = ans.background # this is needed on iOS where the bottom margin has its own margin, so we dont want the body background color to bleed through
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def on_resize(self):
|
def on_resize(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user