How to use @pacote/get-style - 5 common examples

To help you get started, we’ve selected a few @pacote/get-style examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github goblindegook / littlefoot / src / dom / footnote.ts View on Github external
activate: onActivate => {
      button.classList.add(CLASS_CHANGING)
      button.setAttribute('aria-expanded', 'true')
      button.classList.add(CLASS_ACTIVE)

      button.insertAdjacentElement('afterend', popover)

      popover.style.maxWidth = `${document.body.clientWidth}px`
      const contentMaxHeight = getStyle(content, 'maxHeight')
      maxHeight = Math.round(pixels(contentMaxHeight, content))

      if (typeof onActivate === 'function') {
        onActivate(popover, button)
      }
    },
github goblindegook / littlefoot / src / dom / layout.ts View on Github external
export function getAvailableRoom(element: HTMLElement): Room {
  const marginLeft = parseFloat(getStyle(element, 'marginLeft'))
  const width = element.offsetWidth - marginLeft
  const height = element.offsetHeight
  const rect = element.getBoundingClientRect()
  const left = rect.left + width / 2
  const top = rect.top + height / 2

  return {
    top,
    bottom: window.innerHeight - top,
    leftRelative: left / window.innerWidth
  }
}
github goblindegook / littlefoot / src / dom / footnote.ts View on Github external
resize: () => {
      if (popover.parentElement) {
        const room = getAvailableRoom(button)
        const maxWidth = content.offsetWidth
        const buttonMarginLeft = parseInt(getStyle(button, 'marginLeft'), 10)
        const left =
          -room.leftRelative * maxWidth +
          buttonMarginLeft +
          button.offsetWidth / 2

        popover.style.left = left + 'px'
        wrapper.style.maxWidth = maxWidth + 'px'

        repositionTooltip(popover, room.leftRelative)
      }
    },
github goblindegook / littlefoot / src / dom / layout.ts View on Github external
function isPopoverOnTop(footnote: HTMLElement, room: Room): boolean {
  const marginSize = parseInt(getStyle(footnote, 'marginTop'), 10)
  const totalHeight = 2 * marginSize + footnote.offsetHeight

  return room.bottom < totalHeight && room.bottom < room.top
}
github goblindegook / littlefoot / src / dom / layout.ts View on Github external
export function getAvailableHeight(footnote: HTMLElement, room: Room): number {
  const isTop = isPopoverOnTop(footnote, room)
  const marginSize = parseInt(getStyle(footnote, 'marginTop'), 10)
  return room[isTop ? TOP : BOTTOM] - marginSize - 15
}

@pacote/get-style

Get an element's computed style for the provided CSS property.

MIT
Latest version published 2 months ago

Package Health Score

69 / 100
Full package analysis

Popular @pacote/get-style functions