From cc132acdd106b19efb39738e2844ba402501ced3 Mon Sep 17 00:00:00 2001 From: Brady Madden Date: Sat, 4 Jan 2020 13:36:02 -0500 Subject: [PATCH] fix offset top and length causing drag issues --- src/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index b820c9d7..95b5476b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -208,6 +208,8 @@ type SceneState = { const SCROLLBAR_WIDTH = 6; const SCROLLBAR_MARGIN = 4; const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)"; +const CANVAS_WINDOW_OFFSET_LEFT = 250; +const CANVAS_WINDOW_OFFSET_TOP = 0; function getScrollbars( canvasWidth: number, @@ -981,8 +983,8 @@ class App extends React.Component<{}, AppState> { { e.preventDefault(); const { deltaX, deltaY } = e; @@ -1117,12 +1119,12 @@ class App extends React.Component<{}, AppState> { if (!draggingElement) return; let width = e.clientX - - target.offsetLeft - + CANVAS_WINDOW_OFFSET_LEFT - draggingElement.x - this.state.scrollX; let height = e.clientY - - target.offsetTop - + CANVAS_WINDOW_OFFSET_TOP - draggingElement.y - this.state.scrollY; draggingElement.width = width;