Skip to content

Commit

Permalink
refactor: isVisible support IE11 (#434)
Browse files Browse the repository at this point in the history
* refactor: support IE11

* chore: back of eslint
  • Loading branch information
zombieJ committed Mar 15, 2023
1 parent dc2dfb4 commit 1403811
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -51,7 +51,7 @@
"create-react-class": "^15.6.3",
"cross-env": "^7.0.2",
"dumi": "^2.1.3",
"eslint": "~7.31.0",
"eslint": "~7.32.0",
"father": "^4.1.3",
"glob": "^7.1.6",
"husky": "^8.0.3",
Expand Down
28 changes: 15 additions & 13 deletions src/Dom/isVisible.ts
@@ -1,23 +1,25 @@
export default (element: HTMLElement | SVGGraphicsElement): boolean => {
export default (element: Element): boolean => {
if (!element) {
return false;
}

if (element instanceof HTMLElement && element.offsetParent) {
return true;
}

if (element instanceof SVGGraphicsElement && element.getBBox) {
const { width, height } = element.getBBox();
if (width || height) {
if (element instanceof Element) {
if ((element as HTMLElement).offsetParent) {
return true;
}
}

if (element instanceof HTMLElement && element.getBoundingClientRect) {
const { width, height } = element.getBoundingClientRect();
if (width || height) {
return true;
if ((element as SVGGraphicsElement).getBBox) {
const { width, height } = (element as SVGGraphicsElement).getBBox();
if (width || height) {
return true;
}
}

if (element.getBoundingClientRect) {
const { width, height } = element.getBoundingClientRect();
if (width || height) {
return true;
}
}
}

Expand Down

1 comment on commit 1403811

@vercel
Copy link

@vercel vercel bot commented on 1403811 Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

util – ./

util.vercel.app
util-git-master-react-component.vercel.app
util-react-component.vercel.app

Please sign in to comment.