mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[chore] Deprecate TapForward/TapBackward (#4689)
Also fix previous page action in gesture manager.
This commit is contained in:
@@ -512,11 +512,11 @@ function ReaderGesture:gestureAction(action)
|
||||
elseif action == "page_jmp_fwd_10" then
|
||||
self:pageUpdate(10)
|
||||
elseif action == "page_jmp_fwd_1" then
|
||||
self.ui:handleEvent(Event:new("TapForward"))
|
||||
self.ui:handleEvent(Event:new("GotoViewRel", 1))
|
||||
elseif action == "page_jmp_back_10" then
|
||||
self:pageUpdate(-10)
|
||||
elseif action == "page_jmp_back_1" then
|
||||
self:pageUpdate(-1)
|
||||
self.ui:handleEvent(Event:new("GotoViewRel", -1))
|
||||
elseif action == "next_chapter" then
|
||||
self.ui:handleEvent(Event:new("GotoNextChapter"))
|
||||
elseif action == "prev_chapter" then
|
||||
|
||||
@@ -44,11 +44,11 @@ function ReaderPaging:init()
|
||||
if Device:hasKeys() then
|
||||
self.key_events.GotoNextPage = {
|
||||
{Input.group.PgFwd}, doc = "go to next page",
|
||||
event = "PagingRel", args = 1,
|
||||
event = "GotoViewRel", args = 1,
|
||||
}
|
||||
self.key_events.GotoPrevPage = {
|
||||
{Input.group.PgBack}, doc = "go to previous page",
|
||||
event = "PagingRel", args = -1,
|
||||
event = "GotoViewRel", args = -1,
|
||||
}
|
||||
end
|
||||
if Device:hasKeyboard() then
|
||||
@@ -111,13 +111,13 @@ function ReaderPaging:setupTapTouchZones()
|
||||
id = "tap_forward",
|
||||
ges = "tap",
|
||||
screen_zone = forward_zone,
|
||||
handler = function() return self:onTapForward() end
|
||||
handler = function() return self:onGotoViewRel(1) end,
|
||||
},
|
||||
{
|
||||
id = "tap_backward",
|
||||
ges = "tap",
|
||||
screen_zone = backward_zone,
|
||||
handler = function() return self:onTapBackward() end
|
||||
handler = function() return self:onGotoViewRel(-1) end,
|
||||
},
|
||||
})
|
||||
end
|
||||
@@ -262,16 +262,6 @@ function ReaderPaging:getPagePosition(page)
|
||||
return self.page_positions[page] or 0
|
||||
end
|
||||
|
||||
function ReaderPaging:onTapForward()
|
||||
self:onPagingRel(1)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderPaging:onTapBackward()
|
||||
self:onPagingRel(-1)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderPaging:onTogglePageFlipping()
|
||||
self.view.flipping_visible = not self.view.flipping_visible
|
||||
self.page_flipping_mode = self.view.flipping_visible
|
||||
@@ -373,15 +363,15 @@ function ReaderPaging:onSwipe(_, ges)
|
||||
self:_gotoPage(self.original_page)
|
||||
elseif ges.direction == "west" then
|
||||
if self.inverse_reading_order then
|
||||
self:onPagingRel(-1)
|
||||
self:onGotoViewRel(-1)
|
||||
else
|
||||
self:onPagingRel(1)
|
||||
self:onGotoViewRel(1)
|
||||
end
|
||||
elseif ges.direction == "east" then
|
||||
if self.inverse_reading_order then
|
||||
self:onPagingRel(1)
|
||||
self:onGotoViewRel(1)
|
||||
else
|
||||
self:onPagingRel(-1)
|
||||
self:onGotoViewRel(-1)
|
||||
end
|
||||
else
|
||||
-- update footer (time & battery)
|
||||
@@ -454,7 +444,7 @@ function ReaderPaging:onGotoPercent(percent)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderPaging:onPagingRel(diff)
|
||||
function ReaderPaging:onGotoViewRel(diff)
|
||||
if self.view.page_scroll then
|
||||
self:onScrollPageRel(diff)
|
||||
else
|
||||
|
||||
@@ -273,13 +273,13 @@ function ReaderRolling:setupTouchZones()
|
||||
id = "tap_forward",
|
||||
ges = "tap",
|
||||
screen_zone = forward_zone,
|
||||
handler = function() return self:onTapForward() end
|
||||
handler = function() return self:onGotoViewRel(1) end,
|
||||
},
|
||||
{
|
||||
id = "tap_backward",
|
||||
ges = "tap",
|
||||
screen_zone = backward_zone,
|
||||
handler = function() return self:onTapBackward() end
|
||||
handler = function() return self:onGotoViewRel(-1) end,
|
||||
},
|
||||
{
|
||||
id = "double_tap_forward",
|
||||
@@ -388,16 +388,6 @@ function ReaderRolling:getLastPercent()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderRolling:onTapForward()
|
||||
self:onGotoViewRel(1)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRolling:onTapBackward()
|
||||
self:onGotoViewRel(-1)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRolling:onSwipe(_, ges)
|
||||
if ges.direction == "west" then
|
||||
if self.inverse_reading_order then
|
||||
|
||||
@@ -136,13 +136,25 @@ describe("ReaderLink module", function()
|
||||
readerui.view:onSetScrollMode(true)
|
||||
assert.is.same(true, readerui.view.page_scroll)
|
||||
assert.is.same(1, readerui.paging.current_page)
|
||||
readerui.paging:onTapForward()
|
||||
|
||||
readerui.paging:onGotoViewRel(1)
|
||||
assert.is.same(2, readerui.paging.current_page)
|
||||
readerui.paging:onTapForward()
|
||||
|
||||
readerui.paging:onGotoViewRel(-1)
|
||||
assert.is.same(1, readerui.paging.current_page)
|
||||
|
||||
readerui.paging:onGotoViewRel(1)
|
||||
readerui.paging:onGotoViewRel(1)
|
||||
assert.is.same(3, readerui.paging.current_page)
|
||||
readerui.paging:onTapForward()
|
||||
|
||||
readerui.paging:onGotoViewRel(-1)
|
||||
assert.is.same(2, readerui.paging.current_page)
|
||||
|
||||
readerui.paging:onGotoViewRel(1)
|
||||
readerui.paging:onGotoViewRel(1)
|
||||
assert.is.same(4, readerui.paging.current_page)
|
||||
assert.are.same(expected_page_states, readerui.view.page_states)
|
||||
|
||||
readerui.link:onTap(nil, {pos = {x = 181, y = 366}})
|
||||
UIManager:run()
|
||||
assert.is.same(22, readerui.paging.current_page)
|
||||
|
||||
@@ -31,7 +31,7 @@ describe("Readerpaging module", function()
|
||||
readerui.onEndOfBook = function()
|
||||
called = true
|
||||
end
|
||||
paging:onPagingRel(1)
|
||||
paging:onGotoViewRel(1)
|
||||
assert.is.truthy(called)
|
||||
readerui.onEndOfBook = nil
|
||||
UIManager:quit()
|
||||
@@ -64,8 +64,8 @@ describe("Readerpaging module", function()
|
||||
readerui.onEndOfBook = function()
|
||||
called = true
|
||||
end
|
||||
paging:onPagingRel(1)
|
||||
paging:onPagingRel(1)
|
||||
paging:onGotoViewRel(1)
|
||||
paging:onGotoViewRel(1)
|
||||
assert.is.truthy(called)
|
||||
readerui.onEndOfBook = nil
|
||||
UIManager:quit()
|
||||
|
||||
Reference in New Issue
Block a user