[fix] GestureDetector: add PAN_DELAYED_INTERVAL (#4666)

When multiswipes are enabled, this fixes the long-standing complaint that swiping to open the menu could unintentionally trigger some light panning. With the introduction of multiswipes, this problem has become more noticeable.
pull/4686/head
Frans de Jonge 5 years ago committed by GitHub
parent 96823df503
commit 4547b2d65f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -401,8 +401,12 @@ function ReaderPaging:onPan(_, ges)
self.view:PanningStart(-ges.relative.x, -ges.relative.y)
end
elseif ges.direction == "north" or ges.direction == "south" then
self:onPanningRel(self.last_pan_relative_y - ges.relative.y)
self.last_pan_relative_y = ges.relative.y
local relative_type = "relative"
if self.ui.gesture and self.ui.gesture.multiswipes_enabled then
relative_type = "relative_delayed"
end
self:onPanningRel(self.last_pan_relative_y - ges[relative_type].y)
self.last_pan_relative_y = ges[relative_type].y
end
return true
end

@ -421,10 +421,14 @@ end
function ReaderRolling:onPan(_, ges)
if self.view.view_mode == "scroll" then
local distance_type = "distance"
if self.ui.gesture and self.ui.gesture.multiswipes_enabled then
distance_type = "distance_delayed"
end
if ges.direction == "north" then
self:_gotoPos(self.current_pos + ges.distance)
self:_gotoPos(self.current_pos + ges[distance_type])
elseif ges.direction == "south" then
self:_gotoPos(self.current_pos - ges.distance)
self:_gotoPos(self.current_pos - ges[distance_type])
end
end
return true

@ -53,6 +53,7 @@ local GestureDetector = {
DOUBLE_TAP_INTERVAL = 300 * 1000,
TWO_FINGER_TAP_DURATION = 300 * 1000,
HOLD_INTERVAL = 500 * 1000,
PAN_DELAYED_INTERVAL = 500 * 1000,
SWIPE_INTERVAL = 900 * 1000,
-- pinch/spread direction table
DIRECTION_TABLE = {
@ -482,6 +483,7 @@ function GestureDetector:handlePan(tev)
return self:handleTwoFingerPan(tev)
else
local pan_direction, pan_distance = self:getPath(slot)
local tv_diff = self.last_tevs[slot].timev - self.first_tevs[slot].timev
local pan_ev = {
ges = "pan",
@ -490,13 +492,30 @@ function GestureDetector:handlePan(tev)
x = 0,
y = 0,
},
relative_delayed = {
-- default to pan 0
x = 0,
y = 0,
},
pos = nil,
direction = pan_direction,
distance = pan_distance,
distance_delayed = 0,
time = tev.timev,
}
-- regular pan
pan_ev.relative.x = tev.x - self.first_tevs[slot].x
pan_ev.relative.y = tev.y - self.first_tevs[slot].y
-- delayed pan, used where necessary to reduce potential activation of panning
-- when swiping is intended (e.g., for the menu or for multiswipe)
if not ((tv_diff.sec == 0) and (tv_diff.usec < self.PAN_DELAYED_INTERVAL)) then
pan_ev.relative_delayed.x = tev.x - self.first_tevs[slot].x
pan_ev.relative_delayed.y = tev.y - self.first_tevs[slot].y
pan_ev.distance_delayed = pan_distance
end
pan_ev.pos = Geom:new{
x = self.last_tevs[slot].x,
y = self.last_tevs[slot].y,

Loading…
Cancel
Save