diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index d3a9dc36..d206b712 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -6,18 +6,19 @@ namespace rack { void RackScrollWidget::step() { - Vec pos = gRackWidget->lastMousePos; + Vec pos = gMousePos; + Rect viewport = getViewport(box.zeroPos()); // Scroll rack if dragging cable near the edge of the screen if (gRackWidget->wireContainer->activeWire) { float margin = 20.0; float speed = 15.0; - if (pos.x <= margin) + if (pos.x <= viewport.pos.x + margin) offset.x -= speed; - if (pos.x >= box.size.x - margin) + if (pos.x >= viewport.pos.x + viewport.size.x - margin) offset.x += speed; - if (pos.y <= margin) + if (pos.y <= viewport.pos.y + margin) offset.y -= speed; - if (pos.y >= box.size.y - margin) + if (pos.y >= viewport.pos.y + viewport.size.y - margin) offset.y += speed; } ScrollWidget::step();