[fix] GestureDetector: fix multiswipe direction detection code (#4640)

Unfortunately a mistake snuck into the final steps of refactoring <https://github.com/koreader/koreader/pull/4607>.

Thanks to @poire-z for pointing it out [here](https://github.com/koreader/koreader/pull/4607#issuecomment-464856789).
pull/4643/head
Frans de Jonge 5 years ago committed by GitHub
parent 365a5ad876
commit 260427d226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -505,23 +505,24 @@ function GestureDetector:handlePan(tev)
local msd_cnt = #self.multiswipe_directions
local msd_direction_prev = (msd_cnt > 0) and self.multiswipe_directions[msd_cnt][1] or ""
local prev_ms_ev, fake_first_tev
-- recompute a more accurate direction and distance in a multiswipe context
if msd_cnt > 0 then
prev_ms_ev = self.multiswipe_directions[msd_cnt][2]
fake_first_tev = {
[slot] = {
["x"] = prev_ms_ev.pos.x,
["y"] = prev_ms_ev.pos.y,
["slot"] = slot,
},
}
pan_direction = self:getPath(slot, false, fake_first_tev)
end
if msd_cnt == 0
or pan_direction ~= msd_direction_prev
then
local prev_ms_ev, fake_first_tev
if msd_cnt > 0 then
prev_ms_ev = self.multiswipe_directions[msd_cnt][2]
fake_first_tev = {
[slot] = {
["x"] = prev_ms_ev.pos.x,
["y"] = prev_ms_ev.pos.y,
["slot"] = slot,
},
}
end
local msd_direction, msd_distance = self:getPath(slot, true, fake_first_tev)
if msd_distance > self.MULTISWIPE_THRESHOLD

Loading…
Cancel
Save