useElementInfo
Provides information about a DOM element, such as size, position, or bounding box.
Usage
Basic usage example to quickly see how the useElementInfo
works.
Component Name=<>
hovered="false"
Width="0", Height="0"
Scroll Position (Element)="0"
Scroll Position (Body)="0"
API References
Necessary to define a ref
on the related element to pass getBoundingClientRect()
.
The rect
returned value is a DOMRect object which is the smallest rectangle which contains the entire element, including its padding and border-width.
windowSize returns the interior width and height of the window in pixels (that is, the width and height of the window's layout viewport). The read-only innerWidth and innerHeight property of the Window interface returns the interior height of the window in pixels, that includes the width of the vertical scroll bar, if one is present and the height of the horizontal scroll bar, if present.
Source Codes
Full working code example, including necessary markup and styles. You can copy and paste this code directly to start using the component immediately.