Sha256: 613d2d75e4fe3fadcba8ba86853fc26ad0372a9c5d2881245bc32383e2adb10f

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

Contents

const isMac = navigator.platform.toUpperCase().includes('MAC')

// @ts-expect-error TS7006
const isVisible = (element) => !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length > 0)

// @ts-expect-error TS7006
const getOffset = (elment) => {
  const box = elment.getBoundingClientRect()

  return {
    top: box.top + (window.pageYOffset - document.documentElement.clientTop),
    left: box.left + (window.pageXOffset - document.documentElement.clientLeft),
  }
}

// @ts-expect-error TS7006
const computeBoundingBox = (element) => {
  if (!isVisible(element)) {
    return null
  }

  const boxFrame = getOffset(element)
  // @ts-expect-error TS2339
  boxFrame.right = boxFrame.left + element.offsetWidth
  // @ts-expect-error TS2339
  boxFrame.bottom = boxFrame.top + element.offsetHeight

  return {
    left: boxFrame.left,
    top: boxFrame.top,
    // @ts-expect-error TS2339
    width: boxFrame.right - boxFrame.left,
    // @ts-expect-error TS2339
    height: boxFrame.bottom - boxFrame.top,
  }
}

export { isMac, isVisible, getOffset, computeBoundingBox }

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
copy_tuner_client-0.19.0 src/util.ts
copy_tuner_client-0.18.0 src/util.ts
copy_tuner_client-0.17.1 src/util.ts
copy_tuner_client-0.16.3 src/util.ts
copy_tuner_client-0.16.2 src/util.ts
copy_tuner_client-0.16.1 src/util.ts
copy_tuner_client-0.16.0 src/util.ts
copy_tuner_client-0.15.1 src/util.ts
copy_tuner_client-0.15.0 src/util.ts
copy_tuner_client-0.14.2 src/util.ts
copy_tuner_client-0.14.1 src/util.ts
copy_tuner_client-0.14.0 src/util.ts
copy_tuner_client-0.13.6 src/util.ts
copy_tuner_client-0.13.5 src/util.ts
copy_tuner_client-0.13.3 src/util.ts
copy_tuner_client-0.13.2 src/util.ts
copy_tuner_client-0.13.1 src/util.ts
copy_tuner_client-0.13.0 src/util.ts