summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--catbird/node-2d.scm26
1 files changed, 15 insertions, 11 deletions
diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm
index 41f82db..34a7417 100644
--- a/catbird/node-2d.scm
+++ b/catbird/node-2d.scm
@@ -487,19 +487,23 @@
(move-to node x y duration smoothstep))
(define-method (move-by (node <node-2d>) dx dy)
- (let ((p (position node)))
- (move-to node (+ (vec2-x p) dx) (+ (vec2-y p) dy))))
+ ;; No-op if the node wouldn't be moved at all.
+ (unless (and (= dx 0.0) (= dy 0.0))
+ (let ((p (position node)))
+ (move-to node (+ (vec2-x p) dx) (+ (vec2-y p) dy)))))
(define-method (move-by (node <node-2d>) dx dy duration ease)
- (let* ((p (position node))
- (start-x (vec2-x p))
- (start-y (vec2-y p)))
- (tween duration 0.0 1.0
- (lambda (n)
- (move-to node
- (+ start-x (* dx n))
- (+ start-y (* dy n))))
- #:ease ease)))
+ ;; No-op if the node wouldn't be moved at all.
+ (unless (and (= dx 0.0) (= dy 0.0))
+ (let* ((p (position node))
+ (start-x (vec2-x p))
+ (start-y (vec2-y p)))
+ (tween duration 0.0 1.0
+ (lambda (n)
+ (move-to node
+ (+ start-x (* dx n))
+ (+ start-y (* dy n))))
+ #:ease ease))))
(define-method (move-by (node <node-2d>) dx dy duration)
(move-by node dx dy duration smoothstep))