Sha256: 0319449d25688b5b0e9a586ec415575f91a559b7b1ac44c90194b0d89e89ffe8

Contents?: true

Size: 906 Bytes

Versions: 25

Compression:

Stored size: 906 Bytes

Contents

const isMac = navigator.platform.toUpperCase().indexOf('MAC') !== -1;

const isVisible = element =>
  !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);

const getOffset = (elment) => {
  const box = elment.getBoundingClientRect();

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

const computeBoundingBox = (element) => {
  if (!isVisible(element)) {
    return null;
  }

  const boxFrame = getOffset(element);
  boxFrame.right = boxFrame.left + element.offsetWidth;
  boxFrame.bottom = boxFrame.top + element.offsetHeight;

  return {
    left: boxFrame.left,
    top: boxFrame.top,
    width: boxFrame.right - boxFrame.left,
    height: boxFrame.bottom - boxFrame.top,
  };
};

export { isMac, isVisible, getOffset, computeBoundingBox };

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
copy_tuner_client-0.12.0 src/util.js
copy_tuner_client-0.11.0 src/util.js
copy_tuner_client-0.10.0 src/util.js
copy_tuner_client-0.9.0 src/util.js
copy_tuner_client-0.8.1 src/util.js
copy_tuner_client-0.8.0 src/util.js
copy_tuner_client-0.7.0 src/util.js
copy_tuner_client-0.6.2 src/util.js
copy_tuner_client-0.6.1 src/util.js
copy_tuner_client-0.5.3 src/util.js
copy_tuner_client-0.5.2 src/util.js
copy_tuner_client-0.5.1 src/util.js
copy_tuner_client-0.5.0 src/util.js
copy_tuner_client-0.5.0.pre src/util.js
copy_tuner_client-0.4.12 src/util.js
copy_tuner_client-0.4.11 src/util.js
copy_tuner_client-0.4.10 src/util.js
copy_tuner_client-0.4.9 src/util.js
copy_tuner_client-0.4.8 src/util.js
copy_tuner_client-0.4.7 src/util.js