emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/scroll-on-drag 81623ccc59 10/35: Add pre/post hooks


From: ELPA Syncer
Subject: [nongnu] elpa/scroll-on-drag 81623ccc59 10/35: Add pre/post hooks
Date: Thu, 7 Jul 2022 12:02:48 -0400 (EDT)

branch: elpa/scroll-on-drag
commit 81623ccc5965de021dd202681d373f638f82cc68
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Add pre/post hooks
    
    Useful for having functionality run during scroll
    which won't run if scroll isn't initiated.
---
 scroll-on-drag.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/scroll-on-drag.el b/scroll-on-drag.el
index 74433b2daa..0ab08d8207 100644
--- a/scroll-on-drag.el
+++ b/scroll-on-drag.el
@@ -61,6 +61,16 @@
   :group 'scroll-on-drag
   :type  'boolean)
 
+(defcustom scroll-on-drag-pre-hook nil
+  "List of functions to be called when scroll-on-drag starts."
+  :group 'scroll-on-drag
+  :type 'hook)
+
+(defcustom scroll-on-drag-post-hook nil
+  "List of functions to be called when scroll-on-drag finishes."
+  :group 'scroll-on-drag
+  :type 'hook)
+
 
 ;; Generic scrolling functions.
 ;;
@@ -361,6 +371,10 @@ Returns true when scrolling took place, otherwise nil."
                     (when scroll-on-drag-smooth
                       (funcall scroll-consrtain-point-below-window-start-fn))
                     (setq has-scrolled t))
+                  (unless has-scrolled-real
+                    (let
+                      ((inhibit-redisplay nil))
+                        (run-hooks 'scroll-on-drag-pre-hook)))
                   (setq has-scrolled-real t)
                   (funcall timer-stop-fn)
                   (funcall timer-update-fn timer-update-fn)))
@@ -390,6 +404,11 @@ Returns true when scrolling took place, otherwise nil."
       (setq x-pointer-shape restore-x-pointer-shape)
       (set-mouse-color nil))
 
+    (when has-scrolled-real
+      (let
+        ((inhibit-redisplay nil))
+          (run-hooks 'scroll-on-drag-post-hook)))
+
     ;; Result so we know if any scrolling occurred,
     ;; allowing a fallback action on 'click'.
     has-scrolled-real))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]