mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[fix] cre: fix position and page number after window resize (#4754)
This commit is contained in:
@@ -665,21 +665,34 @@ function ReaderRolling:onRedrawCurrentView()
|
||||
end
|
||||
|
||||
function ReaderRolling:onSetDimensions(dimen)
|
||||
self.ui.document:setViewDimen(Screen:getSize())
|
||||
if self.ui.postReaderCallback ~= nil then
|
||||
-- ReaderUI:init() not yet done: just set document dimensions
|
||||
self.ui.document:setViewDimen(Screen:getSize())
|
||||
-- (what's done in the following else is done elsewhere by
|
||||
-- the initialization code)
|
||||
else
|
||||
-- Initialization done: we are called on orientation change
|
||||
-- or on window resize (SDL, Android possibly).
|
||||
-- We need to temporarily re-enable internal history as crengine
|
||||
-- uses it to reposition after resize
|
||||
self.ui.document:enableInternalHistory(true)
|
||||
-- Set document dimensions
|
||||
self.ui.document:setViewDimen(Screen:getSize())
|
||||
-- Re-setup previous position
|
||||
self:onChangeViewMode()
|
||||
self:onUpdatePos()
|
||||
-- Re-disable internal history, with required redraw
|
||||
self.ui.document:enableInternalHistory(false)
|
||||
self:onRedrawCurrentView()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderRolling:onChangeScreenMode(mode, rotation)
|
||||
-- We need to temporarily re-enable internal history as crengine
|
||||
-- uses it to reposition after resize
|
||||
self.ui.document:enableInternalHistory(true)
|
||||
-- Flag it as interactive so we can properly swap to Inverted orientations (we usurp the second argument, which usually means rotation)
|
||||
-- Flag it as interactive so we can properly swap to Inverted orientations
|
||||
-- (we usurp the second argument, which usually means rotation)
|
||||
self.ui:handleEvent(Event:new("SetScreenMode", mode, rotation or true))
|
||||
self.ui.document:setViewDimen(Screen:getSize())
|
||||
self:onChangeViewMode()
|
||||
self:onUpdatePos()
|
||||
-- Re-disable internal history, with required redraw
|
||||
self.ui.document:enableInternalHistory(false)
|
||||
self:onRedrawCurrentView()
|
||||
-- (This had the above ReaderRolling:onSetDimensions() called to resize
|
||||
-- document dimensions and keep up with current position)
|
||||
end
|
||||
|
||||
function ReaderRolling:onColorRenderingUpdate()
|
||||
|
||||
Reference in New Issue
Block a user