Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix BaseSelector move_to_pointer #588

Closed
@kushalkolar

Description

@kushalkolar

so this has been broken for a while, this should fix it, will PR later:

Subject: [PATCH] a
---
Index: fastplotlib/graphics/selectors/_base_selector.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/fastplotlib/graphics/selectors/_base_selector.py b/fastplotlib/graphics/selectors/_base_selector.py
--- a/fastplotlib/graphics/selectors/_base_selector.py	(revision 84b23e8b03228b003212940205630cf7be75c5cb)
+++ b/fastplotlib/graphics/selectors/_base_selector.py	(date 1723148098223)
@@ -269,7 +269,12 @@
         """
         Calculates delta just using current world object position and calls self._move_graphic().
         """
-        current_position: np.ndarray = self.offset
+        if self.axis == "x":
+            offset = self.offset[0]
+        elif self.axis == "y":
+            offset = self.offset[1]
+
+        current_pos_world: np.ndarray = self.selection + offset
 
         # middle mouse button clicks
         if ev.button != 3:
@@ -281,18 +286,18 @@
         if world_pos is None:
             return
 
-        self.delta = world_pos - current_position
+        self.delta = world_pos - current_pos_world
         self._pygfx_event = ev
 
         # use fill by default as the source, such as in region selectors
         if len(self._fill) > 0:
             self._move_info = MoveInfo(
-                last_position=current_position, source=self._fill[0]
+                last_position=current_pos_world, source=self._fill[0]
             )
         # else use an edge, such as for linear selector
         else:
             self._move_info = MoveInfo(
-                last_position=current_position, source=self._edges[0]
+                last_position=current_pos_world, source=self._edges[0]
             )
 
         self._move_graphic(self.delta)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions