mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
readerpaging(fix): set the corrent page number on GoBackLink event
This commit is contained in:
@@ -428,8 +428,7 @@ end
|
||||
function ReaderPaging:onRestoreBookLocation(saved_location)
|
||||
if self.view.page_scroll then
|
||||
self.view:restoreViewContext(saved_location)
|
||||
self:_gotoPage(self.view.page_states[#self.view.page_states].page,
|
||||
"scrolling")
|
||||
self:_gotoPage(self.view.page_states[1].page, "scrolling")
|
||||
else
|
||||
-- gotoPage will emit PageUpdate event, which will trigger recalculate
|
||||
-- in ReaderView and resets the view context. So we need to call
|
||||
|
||||
@@ -32,6 +32,18 @@ describe("ReaderLink module", function()
|
||||
assert.is.same(22, readerui.paging.current_page)
|
||||
end)
|
||||
|
||||
it("should jump to links in pdf scroll mode", function()
|
||||
UIManager:quit()
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_pdf),
|
||||
}
|
||||
readerui:handleEvent(Event:new("SetScrollMode", true))
|
||||
readerui.paging:onGotoPage(1)
|
||||
readerui.link:onTap(nil, {pos = {x = 250, y = 534}})
|
||||
UIManager:run()
|
||||
assert.is.same(21, readerui.paging.current_page)
|
||||
end)
|
||||
|
||||
it("should be able to go back after link jump in epub", function()
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_epub),
|
||||
@@ -57,6 +69,20 @@ describe("ReaderLink module", function()
|
||||
assert.is.same(1, readerui.paging.current_page)
|
||||
end)
|
||||
|
||||
it("should be able to go back after link jump in pdf scroll mode", function()
|
||||
UIManager:quit()
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_pdf),
|
||||
}
|
||||
readerui:handleEvent(Event:new("SetScrollMode", true))
|
||||
readerui.paging:onGotoPage(1)
|
||||
readerui.link:onTap(nil, {pos = {x = 250, y = 534}})
|
||||
UIManager:run()
|
||||
assert.is.same(21, readerui.paging.current_page)
|
||||
readerui.link:onGoBackLink()
|
||||
assert.is.same(1, readerui.paging.current_page)
|
||||
end)
|
||||
|
||||
it("should be able to go back after link jump in pdf in scroll mode", function()
|
||||
UIManager:quit()
|
||||
local expected_page_states = {
|
||||
@@ -109,7 +135,7 @@ describe("ReaderLink module", function()
|
||||
UIManager:run()
|
||||
assert.is.same(22, readerui.paging.current_page)
|
||||
readerui.link:onGoBackLink()
|
||||
assert.is.same(4, readerui.paging.current_page)
|
||||
assert.is.same(3, readerui.paging.current_page)
|
||||
assert.are.same(expected_page_states, readerui.view.page_states)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user