npm.io
1.0.2 • Published 6 years ago

@lemuria/absolute-proxy

Licence
MIT
Version
1.0.2
Deps
0
Size
8 kB
Vulns
0
Weekly
0
Stars
1

@lemuria/absolute-proxy

npm version

@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)
})

Art Deco Art Deco 2019 Tech Nation Visa Tech Nation Visa Sucks

Keywords