MOBILE-4362 core: Fix isElementVisible helper
Some elements return 0 for clientWidth even if they have a size in the final rendering, so we'll use getBoundingClientRect which is more reliable.main
parent
aebbe3365c
commit
781a4da551
|
@ -123,8 +123,12 @@ export class CoreDom {
|
|||
* @returns True if element is visible inside the DOM.
|
||||
*/
|
||||
static isElementVisible(element: HTMLElement, checkSize = true): boolean {
|
||||
if (checkSize && (element.clientWidth === 0 || element.clientHeight === 0)) {
|
||||
return false;
|
||||
if (checkSize) {
|
||||
const dimensions = element.getBoundingClientRect();
|
||||
|
||||
if (dimensions.width === 0 || dimensions.height === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const style = getComputedStyle(element);
|
||||
|
|
Loading…
Reference in New Issue