1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +01:00

fix offset top and length causing drag issues

This commit is contained in:
Brady Madden 2020-01-04 13:36:02 -05:00
parent c5d65ccb39
commit cc132acdd1

@ -208,6 +208,8 @@ type SceneState = {
const SCROLLBAR_WIDTH = 6; const SCROLLBAR_WIDTH = 6;
const SCROLLBAR_MARGIN = 4; const SCROLLBAR_MARGIN = 4;
const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)"; const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
const CANVAS_WINDOW_OFFSET_LEFT = 250;
const CANVAS_WINDOW_OFFSET_TOP = 0;
function getScrollbars( function getScrollbars(
canvasWidth: number, canvasWidth: number,
@ -981,8 +983,8 @@ class App extends React.Component<{}, AppState> {
</div> </div>
<canvas <canvas
id="canvas" id="canvas"
width={window.innerWidth - 250} width={window.innerWidth - CANVAS_WINDOW_OFFSET_LEFT}
height={window.innerHeight} height={window.innerHeight - CANVAS_WINDOW_OFFSET_TOP}
onWheel={e => { onWheel={e => {
e.preventDefault(); e.preventDefault();
const { deltaX, deltaY } = e; const { deltaX, deltaY } = e;
@ -1117,12 +1119,12 @@ class App extends React.Component<{}, AppState> {
if (!draggingElement) return; if (!draggingElement) return;
let width = let width =
e.clientX - e.clientX -
target.offsetLeft - CANVAS_WINDOW_OFFSET_LEFT -
draggingElement.x - draggingElement.x -
this.state.scrollX; this.state.scrollX;
let height = let height =
e.clientY - e.clientY -
target.offsetTop - CANVAS_WINDOW_OFFSET_TOP -
draggingElement.y - draggingElement.y -
this.state.scrollY; this.state.scrollY;
draggingElement.width = width; draggingElement.width = width;