@lemuria/absolute-proxy
@lemuria/absolute-proxy
Assigns Styles To Position Element Absolutely On Top Of The Target One.
yarn add @lemuria/absolute-proxy
Table Of Contents
API
The package is available by importing its default function:
import absoluteProxy from '@lemuria/absolute-proxy'
absoluteProxy(
obj: HTMLElement,
element: HTMLElement,
): void
Computes the getBoundingClientRect
and getComputedStyle
of the target element to find out the position that should be set on the obj for it to appear on the same place on screen, but with absolute position (e.g., relative to body
).
Accounts for padding
and border
.
import positionAbsolute from '@lemuria/absolute-proxy'
const obj = document.createElement('object')
obj.type = 'image/svg+xml'
obj.data = src
const element = document.getElementById('example')
positionAbsolute(obj, element)
window.addEventListener('resize', () => {
positionAbsolute(obj, element)
})
Copyright
© Art Deco 2019 | Tech Nation Visa Sucks |
---|