mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Footnotes: fix current link being unhighlight in some cases
When a link is covered by the footnote widget, we highlight it again when closing the footnote, and schedule an unhighlight 0.5s later. When we tap on another footnote link, this was happening too but the unhighlight unhighlighted all, including the new footnote link. This disable the former when the latter happens.
This commit is contained in:
@@ -1016,6 +1016,7 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location)
|
||||
-- (which might not be seen when covered by FootnoteWidget)
|
||||
local close_callback = nil
|
||||
if link.from_xpointer then -- coherent xpointer
|
||||
self.ui.document:highlightXPointer() -- clear any previous one
|
||||
self.ui.document:highlightXPointer(link.from_xpointer)
|
||||
UIManager:setDirty(self.dialog, "ui")
|
||||
close_callback = function(footnote_height)
|
||||
@@ -1055,10 +1056,14 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location)
|
||||
UIManager:close(popup)
|
||||
self:onGotoLink(link, neglect_current_location)
|
||||
end,
|
||||
on_tap_close_callback = function(arg, ges)
|
||||
-- on tap outside, see if we are tapping on another footnote,
|
||||
on_tap_close_callback = function(arg, ges, footnote_height)
|
||||
-- On tap outside, see if we are tapping on another footnote,
|
||||
-- and display it if we do (avoid the need for 2 taps)
|
||||
self:onTap(arg, ges)
|
||||
if not self:onTap(arg, ges) then
|
||||
-- If we did tap on another link, onTap has already cleared our
|
||||
-- highlight. If not, call close_callback to unhighlight it.
|
||||
close_callback(footnote_height)
|
||||
end
|
||||
end,
|
||||
dialog = self.dialog,
|
||||
}
|
||||
|
||||
@@ -289,9 +289,6 @@ function FootnoteWidget:onShow()
|
||||
end
|
||||
|
||||
function FootnoteWidget:onCloseWidget()
|
||||
if self.close_callback then
|
||||
self.close_callback(self.height)
|
||||
end
|
||||
UIManager:setDirty(self.dialog, function()
|
||||
return "partial", self.container.dimen
|
||||
end)
|
||||
@@ -310,7 +307,9 @@ function FootnoteWidget:onTapClose(arg, ges)
|
||||
-- it. This avoids having to tap 2 times to
|
||||
-- see another footnote.
|
||||
if self.on_tap_close_callback then
|
||||
self.on_tap_close_callback(arg, ges)
|
||||
self.on_tap_close_callback(arg, ges, self.height)
|
||||
elseif self.close_callback then
|
||||
self.close_callback(self.height)
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -320,6 +319,9 @@ end
|
||||
function FootnoteWidget:onSwipeFollow(arg, ges)
|
||||
if ges.direction == "west" then
|
||||
if self.follow_callback then
|
||||
if self.close_callback then
|
||||
self.close_callback(self.height)
|
||||
end
|
||||
return self.follow_callback()
|
||||
end
|
||||
elseif ges.direction == "south" or ges.direction == "east" then
|
||||
@@ -328,6 +330,9 @@ function FootnoteWidget:onSwipeFollow(arg, ges)
|
||||
-- work only when started outside the footnote.
|
||||
-- Also allow closing with swipe east (like we do to go back
|
||||
-- from link)
|
||||
if self.close_callback then
|
||||
self.close_callback(self.height)
|
||||
end
|
||||
self:onClose()
|
||||
return true
|
||||
elseif ges.direction == "north" then
|
||||
|
||||
Reference in New Issue
Block a user