readerpaging(fix): set the corrent page number on GoBackLink event

pull/2160/head
Qingping Hou 8 years ago
parent 3339ed4e5f
commit f30e487959

@ -428,8 +428,7 @@ end
function ReaderPaging:onRestoreBookLocation(saved_location) function ReaderPaging:onRestoreBookLocation(saved_location)
if self.view.page_scroll then if self.view.page_scroll then
self.view:restoreViewContext(saved_location) self.view:restoreViewContext(saved_location)
self:_gotoPage(self.view.page_states[#self.view.page_states].page, self:_gotoPage(self.view.page_states[1].page, "scrolling")
"scrolling")
else else
-- gotoPage will emit PageUpdate event, which will trigger recalculate -- gotoPage will emit PageUpdate event, which will trigger recalculate
-- in ReaderView and resets the view context. So we need to call -- 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) assert.is.same(22, readerui.paging.current_page)
end) 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() it("should be able to go back after link jump in epub", function()
local readerui = ReaderUI:new{ local readerui = ReaderUI:new{
document = DocumentRegistry:openDocument(sample_epub), document = DocumentRegistry:openDocument(sample_epub),
@ -57,6 +69,20 @@ describe("ReaderLink module", function()
assert.is.same(1, readerui.paging.current_page) assert.is.same(1, readerui.paging.current_page)
end) 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() it("should be able to go back after link jump in pdf in scroll mode", function()
UIManager:quit() UIManager:quit()
local expected_page_states = { local expected_page_states = {
@ -109,7 +135,7 @@ describe("ReaderLink module", function()
UIManager:run() UIManager:run()
assert.is.same(22, readerui.paging.current_page) assert.is.same(22, readerui.paging.current_page)
readerui.link:onGoBackLink() 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) assert.are.same(expected_page_states, readerui.view.page_states)
end) end)
end) end)

Loading…
Cancel
Save