Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dial-scroll.el
(defun dial-scroll ()
(interactive)
(lexical-let ((last_rad 0.0))
(run-with-timer 0.05 0.05
(lambda ()
(let ((current_x (car (cdr (mouse-position))))
(current_y (cdr (cdr (mouse-position)))))
(let ((diff_x (float (- current_x (/ (window-width) 2))))
(diff_y (float (- current_y (/ (window-height) 2)))))
(let ((rad (atan (/ diff_y diff_x))))
(let ((rad (if (> 0.0 diff_x) rad (+ rad pi))))
(let ((diff (- rad last_rad)))
(let ((diff (if (< diff (* -1 pi)) (+ diff (* 2 pi)) diff)))
(let ((diff (if (> diff pi) (- diff (* 2 pi)) diff)))
(setq last_rad rad)
(when (< 0 diff)
(scroll-up 1))
(when (> 0 diff)
(scroll-down 1))
)))))))))))
(provide 'dial-scroll)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment