From 7f202f513d4f15a102e2b29f6dabc491a84025b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 15 Dec 2020 21:17:02 +0530 Subject: [PATCH] Animate hint activation --- src/pyj/read_book/iframe.pyj | 6 +++++- src/pyj/read_book/settings.pyj | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj index 379161f2bd..b680933cf8 100644 --- a/src/pyj/read_book/iframe.pyj +++ b/src/pyj/read_book/iframe.pyj @@ -933,7 +933,11 @@ class IframeBoss: hint = data.hint if hint.type is 'link': a = document.body.querySelector(f'[data-calibre-hint-value="{hint.value}"]') - self.activate_link(hint.data.name, hint.data.frag, a) + a.addEventListener("animationend", def (ev): + a.classList.remove('calibre-animated-hint') + self.activate_link(hint.data.name, hint.data.frag, a) + , False) + a.classList.add('calibre-animated-hint') def main(): diff --git a/src/pyj/read_book/settings.pyj b/src/pyj/read_book/settings.pyj index 6f5914d40c..c058c3c63d 100644 --- a/src/pyj/read_book/settings.pyj +++ b/src/pyj/read_book/settings.pyj @@ -125,6 +125,19 @@ def apply_colors(is_content_popup): cursor: default !important;\ padding: 1px !important;\ border: solid 1px {opts.color_scheme.foreground} !important;\ + + }} + + .calibre-animated-hint {{ + animation-name: calibre-animate-hint; \ + animation-duration: 0.3s; \ + animation-timing-function: ease-out; \ + display: inline-block !important; \ + text-indent: 0 !important; \ + }} + @keyframes calibre-animate-hint {{ + from {{ transform: scale(1); }} + to {{ transform: scale(2); }} }} ''' ss.textContent = text