-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: check and use parents scale css for tabs underline position (#2178)
* fix: check and use parents scale css * fix: move refs access back in useEffect * fix: handle NaN value * fix: check if window is defined for ssr
- Loading branch information
1 parent
ffb5bbc
commit b57cacb
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//Check if the element, or its parent, has a scale property | ||
export const getParentScale = (element: HTMLElement | null): number => { | ||
//If the element doesn't exist, or if window is undefined, return 1 | ||
if (!element || typeof window === 'undefined') return 1 | ||
const elementScale = Number(window.getComputedStyle(element).scale) | ||
|
||
//If the scale property is not unvalid or undefined, return its value | ||
//Else check the parent's scale property | ||
if (!isNaN(elementScale)) { | ||
return elementScale | ||
} else { | ||
return getParentScale(element.parentElement) | ||
} | ||
} |