Skip to content

Commit

Permalink
allow to scroll on laptop and pc
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Jul 24, 2024
1 parent add0931 commit 68d6fe0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/draw/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,26 @@ export const addScroll = (app, objects) => {
container.x = newXPosition;
}
} else {
const deltaX = parseInt(e.deltaX * SPEED);
const deltaY = parseInt(e.deltaY * SPEED);

const newXPosition = container.x - deltaX;
const newYPosition = container.y - deltaY;

const isXInBounds =
newXPosition < 0 &&
newXPosition > screenWidth - getContainerSize().width;
const isYInBounds =
newYPosition < 0 &&
newYPosition > screenHeight - getContainerSize().height;

if (isXInBounds) {
container.x = newXPosition;
}

if (isYInBounds) {
container.y = newYPosition;
}
}

setRenderable(objects);
});
};

0 comments on commit 68d6fe0

Please sign in to comment.