]> git.eshelyaron.com Git - emacs.git/commitdiff
Clear scroll interpolation when interpolated scroll completes
authorPo Lu <luangruo@yahoo.com>
Wed, 8 Dec 2021 10:36:18 +0000 (18:36 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 8 Dec 2021 10:36:18 +0000 (18:36 +0800)
* lisp/pixel-scroll.el (pixel-scroll-precision-interpolate): Set
saved interpolation to nil upon completion.

lisp/pixel-scroll.el

index b322bf9a53dcbb44f8b6d6e52a10a0a4db297884..94c14d50dca60d7144bbb0e8408e310bc314bc5a 100644 (file)
@@ -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."