mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
add goto link function for CreDocument
This commit is contained in:
@@ -183,10 +183,12 @@ function ReaderRolling:onTapBackward()
|
||||
end
|
||||
|
||||
function ReaderRolling:onSwipe(arg, ges)
|
||||
if ges.direction == "west" or ges.direction == "north" then
|
||||
self:onGotoViewRel(1)
|
||||
elseif ges.direction == "east" or ges.direction == "south" then
|
||||
self:onGotoViewRel(-1)
|
||||
if ges.direction == "west" then
|
||||
self.ui.document:goForward()
|
||||
self:onUpdateXPointer()
|
||||
elseif ges.direction == "east" then
|
||||
self.ui.document:goBack()
|
||||
self:onUpdateXPointer()
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -204,11 +206,13 @@ end
|
||||
|
||||
function ReaderRolling:onPosUpdate(new_pos)
|
||||
self.current_pos = new_pos
|
||||
self:updatePageLink()
|
||||
self:updateBatteryState()
|
||||
end
|
||||
|
||||
function ReaderRolling:onPageUpdate(new_page)
|
||||
self.current_page = new_page
|
||||
self:updatePageLink()
|
||||
self:updateBatteryState()
|
||||
end
|
||||
|
||||
@@ -273,6 +277,16 @@ function ReaderRolling:updatePos()
|
||||
UIManager.repaint_all = true
|
||||
end
|
||||
|
||||
function ReaderRolling:onUpdateXPointer()
|
||||
local xp = self.ui.document:getXPointer()
|
||||
if self.view.view_mode == "page" then
|
||||
self.ui:handleEvent(Event:new("PageUpdate", self.ui.document:getPageFromXPointer(xp)))
|
||||
else
|
||||
self.ui:handleEvent(Event:new("PosUpdate", self.ui.document:getPosFromXPointer(xp)))
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRolling:onChangeViewMode()
|
||||
self.ui.document:_readMetadata()
|
||||
self.old_doc_height = self.ui.document.info.doc_height
|
||||
@@ -347,6 +361,12 @@ function ReaderRolling:onGotoPage(number)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRolling:updatePageLink()
|
||||
DEBUG("update page link")
|
||||
local links = self.ui.document:getPageLinks()
|
||||
self.view.links = links
|
||||
end
|
||||
|
||||
function ReaderRolling:updateBatteryState()
|
||||
DEBUG("update battery state")
|
||||
if self.view.view_mode == "page" then
|
||||
|
||||
Reference in New Issue
Block a user