Fixed the gird position detection when the mouse is clicked by using event.offsetx/y rather than pagex/y page x/y gets the position relative to the page, but offset gets it relative to the canvas.