Highlights: turn page when start or end crosses pages (#5984)

More generally: switch to the page that contains the highlight
edge that we are currently moving.
reviewable/pr5999/r1
poire-z 4 years ago committed by GitHub
parent e9d0c7a96e
commit 8e68dc11db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -329,6 +329,26 @@ function ReaderHighlight:updateHighlight(page, index, side, direction, move_by_c
datetime = highlight_time,
updated_highlight = new_highlight
}, true)
if side == 0 then
-- Ensure we show the page with the new beginning of highlight
if not self.ui.document:isXPointerInCurrentPage(new_beginning) then
self.ui:handleEvent(Event:new("GotoXPointer", new_beginning))
end
else
-- Ensure we show the page with the new end of highlight
if not self.ui.document:isXPointerInCurrentPage(new_end) then
if self.view.view_mode == "page" then
self.ui:handleEvent(Event:new("GotoXPointer", new_end))
else
-- Not easy to get the y that would show the whole line
-- containing new_end. So, we scroll so that new_end
-- is at 2/3 of the screen.
local end_y = self.ui.document:getPosFromXPointer(new_end)
local top_y = end_y - math.floor(Screen:getHeight() * 2/3)
self.ui.rolling:_gotoPos(top_y)
end
end
end
UIManager:setDirty(self.dialog, "ui")
end

Loading…
Cancel
Save