isVisible.js 658 B

123456789101112131415161718192021222324252627
  1. export default (function (element) {
  2. if (!element) {
  3. return false;
  4. }
  5. if (element instanceof Element) {
  6. if (element.offsetParent) {
  7. return true;
  8. }
  9. if (element.getBBox) {
  10. var _getBBox = element.getBBox(),
  11. width = _getBBox.width,
  12. height = _getBBox.height;
  13. if (width || height) {
  14. return true;
  15. }
  16. }
  17. if (element.getBoundingClientRect) {
  18. var _element$getBoundingC = element.getBoundingClientRect(),
  19. _width = _element$getBoundingC.width,
  20. _height = _element$getBoundingC.height;
  21. if (_width || _height) {
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. });