is-opaque.js 529 B

12345678910111213141516
  1. import elementHasImage from '../color/element-has-image';
  2. import getOwnBackgroundColor from '../color/get-own-background-color';
  3. /**
  4. * Determines whether an element has a fully opaque background, whether solid color or an image
  5. * @param {Element} node
  6. * @return {Boolean} false if the background is transparent, true otherwise
  7. */
  8. function isOpaque(node) {
  9. const style = window.getComputedStyle(node);
  10. return (
  11. elementHasImage(node, style) || getOwnBackgroundColor(style).alpha === 1
  12. );
  13. }
  14. export default isOpaque;