This event is triggered whenever a mouse button is pressed down. The addEventListener() method is used on this element to listen the ‘mousedown’ event. To detect the click, the canvas element is first selected using the querySelector() method. This subtraction will compensate for the location of the canvas on the page as the event’s x and y position would be relative to the page and not the canvas. the top side of the rectangle can be found using the ‘top’ property. The y-position of the canvas element, i.e. The y-position of the event is found using the ‘clientY’ property. Similarly, the position of y-coordinate of the click is found by subtracting the event’s y position with the bounding rectangle’s y position. the left side of the rectangle can be found using the ‘left’ property. The x position of the canvas element, i.e. The x position of the event is found using the ‘clientX’ property. The position of x-coordinate of the mouse click is found by subtracting the event’s x position with the bounding rectangle’s x position. This method returns the size of an element and its position relative to the viewport. The dimension of the canvas is found using the getBoundingClientRect() function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |