#include "app.hpp"
#include "gui.hpp"


namespace rack {


void RackScrollWidget::step() {
	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 <= viewport.pos.x + margin)
			offset.x -= speed;
		if (pos.x >= viewport.pos.x + viewport.size.x - margin)
			offset.x += speed;
		if (pos.y <= viewport.pos.y + margin)
			offset.y -= speed;
		if (pos.y >= viewport.pos.y + viewport.size.y - margin)
			offset.y += speed;
	}
	ScrollWidget::step();
}


} // namespace rack

#include "app.hpp"
#include "gui.hpp"


namespace rack {


void RackScrollWidget::step() {
	Vec pos = gRackWidget->lastMousePos;
	// 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)
			offset.x -= speed;
		if (pos.x >= box.size.x - margin)
			offset.x += speed;
		if (pos.y <= margin)
			offset.y -= speed;
		if (pos.y >= box.size.y - margin)
			offset.y += speed;
	}
	ScrollWidget::step();
}


} // namespace rack

--- 
+++ 
@@ -6,18 +6,19 @@
 
 
 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();
Fix autoscrolling when dragging near edge of rack
