From f10d4b31d6d9cc370597a32da4a88ac2d63e7bab Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 8 Dec 2021 18:36:18 +0800 Subject: [PATCH] Clear scroll interpolation when interpolated scroll completes * lisp/pixel-scroll.el (pixel-scroll-precision-interpolate): Set saved interpolation to nil upon completion. --- lisp/pixel-scroll.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el index b322bf9a53d..94c14d50dca 100644 --- a/lisp/pixel-scroll.el +++ b/lisp/pixel-scroll.el @@ -550,7 +550,8 @@ animation." (rem (window-parameter nil 'interpolated-scroll-remainder)) (time (window-parameter nil 'interpolated-scroll-remainder-time))) (when (and rem time - (< (- (float-time) time) 1.0)) + (< (- (float-time) time) 1.0) + (eq (< delta 0) (< rem 0))) (setq delta (+ delta rem))) (while-no-input (unwind-protect @@ -568,11 +569,18 @@ animation." (ceiling (* (* delta factor) (/ between-scroll total-time))))) (setq last-time (float-time))) - (when (< percentage 1) - (set-window-parameter nil 'interpolated-scroll-remainder - (* delta (- 1 percentage))) - (set-window-parameter nil 'interpolated-scroll-remainder-time - (float-time))))))) + (if (< percentage 1) + (progn + (set-window-parameter nil 'interpolated-scroll-remainder + (* delta (- 1 percentage))) + (set-window-parameter nil 'interpolated-scroll-remainder-time + (float-time))) + (set-window-parameter nil + 'interpolated-scroll-remainder + nil) + (set-window-parameter nil + 'interpolated-scroll-remainder-time + nil)))))) (defun pixel-scroll-precision-scroll-up (delta) "Scroll the current window up by DELTA pixels." -- 2.39.2