Skip to content

Commit 933e0b5

Browse files
author
Andreas Kugel
committed
isVisble correction with try/catch
1 parent 525dc79 commit 933e0b5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/coreui-vue/src/components/carousel/CCarousel.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ import {
1313

1414
const isVisible = (element: HTMLDivElement) => {
1515
// check e ei not null to prevent error when leaving page
16-
if ((element || "") === "") return false
17-
const rect = element.getBoundingClientRect()
18-
return (
19-
rect.top >= 0 &&
20-
rect.left >= 0 &&
21-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
22-
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
23-
)
16+
try {
17+
const rect = element.getBoundingClientRect()
18+
return (
19+
rect.top >= 0 &&
20+
rect.left >= 0 &&
21+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
22+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
23+
)
24+
} catch(e:any) {
25+
return false
26+
}
2427
}
2528

2629
const CCarousel = defineComponent({

0 commit comments

Comments
 (0)