fix(Tabs): can not render line when wrapper is fixed (#5496)

This commit is contained in:
neverland 2020-01-07 17:03:21 +08:00 committed by GitHub
parent 31c94472b1
commit c89d5ee096
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,11 @@
export function isHidden(element: HTMLElement) { export function isHidden(element: HTMLElement) {
return ( const style = window.getComputedStyle(element);
window.getComputedStyle(element).display === 'none' || element.offsetParent === null const isHidden = style.display === 'none';
);
// offsetParent returns null in the following situations:
// 1. The element or its parent element has the display property set to none.
// 2. The element has the position property set to fixed
const isParentHidden = element.offsetParent === null && style.position !== 'fixed';
return isHidden || isParentHidden;
} }