From b8776e6d3857d275cbb8b5983cb2f3b51eb44cb0 Mon Sep 17 00:00:00 2001 From: Boutade Date: Tue, 15 Oct 2019 11:28:10 -0500 Subject: added optional on-complete callback --- animise.lisp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/animise.lisp b/animise.lisp index 7103a0a..9f2eb0c 100644 --- a/animise.lisp +++ b/animise.lisp @@ -56,7 +56,11 @@ (setter) (accessor :initarg :accessor - :initform (error "Must supply an accessor function")))) + :initform (error "Must supply an accessor function")) + (on-complete + :accessor on-complete + :initarg :on-complete + :initform nil))) (defmethod initialize-instance :after ((tween tween) &key) (with-slots (getter setter accessor) tween @@ -151,6 +155,11 @@ (if rounding (round new-val) new-val) target))))) +(defmethod run-tween :after ((tween tween) time) + (when (and (on-complete tween) (tween-finished-p tween time)) + (funcall (on-complete tween)) + (setf (on-complete tween) nil))) + ;;; Interface implementations for TWEEN-SEQ (defmethod start-time ((ob tween-seq)) -- cgit v1.2.3