Spaces:
Sleeping
Sleeping
Gallinator commited on
visualization: add offset from click to control point when moving
Browse files
app/static/js/visualization.js
CHANGED
|
@@ -124,6 +124,7 @@ class CurveEditor {
|
|
| 124 |
this.moving = false
|
| 125 |
this.movingId = false
|
| 126 |
this.isDeleteKeyDown = false
|
|
|
|
| 127 |
|
| 128 |
this.handler = { onupdate: () => { } }
|
| 129 |
|
|
@@ -146,6 +147,8 @@ class CurveEditor {
|
|
| 146 |
if (this.isWithinThreshold(clickedPoint, p) && this.isSelectable(i)) {
|
| 147 |
this.moving = true;
|
| 148 |
this.movingId = i;
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
})
|
| 151 |
});
|
|
@@ -164,7 +167,7 @@ class CurveEditor {
|
|
| 164 |
if (!this.moving)
|
| 165 |
return
|
| 166 |
|
| 167 |
-
this.curve.moveControlPoint(this.movingId, mousePoint.x, mousePoint.y)
|
| 168 |
|
| 169 |
this.onupdate();
|
| 170 |
});
|
|
|
|
| 124 |
this.moving = false
|
| 125 |
this.movingId = false
|
| 126 |
this.isDeleteKeyDown = false
|
| 127 |
+
this.offset = { "x": 0, "y": 0 }
|
| 128 |
|
| 129 |
this.handler = { onupdate: () => { } }
|
| 130 |
|
|
|
|
| 147 |
if (this.isWithinThreshold(clickedPoint, p) && this.isSelectable(i)) {
|
| 148 |
this.moving = true;
|
| 149 |
this.movingId = i;
|
| 150 |
+
this.offset.x = clickedPoint.x - p.x
|
| 151 |
+
this.offset.y = clickedPoint.y - p.y
|
| 152 |
}
|
| 153 |
})
|
| 154 |
});
|
|
|
|
| 167 |
if (!this.moving)
|
| 168 |
return
|
| 169 |
|
| 170 |
+
this.curve.moveControlPoint(this.movingId, mousePoint.x - this.offset.x, mousePoint.y - this.offset.y)
|
| 171 |
|
| 172 |
this.onupdate();
|
| 173 |
});
|