The getBoundingClientRect() method in JavaScript is a way to retrieve information about an element’s size and its position on a web page in relation to the visible area, known as the viewport. It returns a DOMRect object, which provides details about the element’s dimensions and location.
addEventListener()addEventListener is a method in JavaScript that allows you to attach an event handler function to an HTML element so that the function is executed when a specific event occurs on that element. Events can include things like user interactions (e.g., clicks, mouse movements, keyboard presses) or changes in the state of an element (e.g., the element is loaded, resized, or its content is changed).
Take a look at our DEMO