Skip to content

Commit 67820ec

Browse files
committed
refactor: move isVisible to utilities
1 parent 8aee4c7 commit 67820ec

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ import {
1111
watch,
1212
} from 'vue'
1313

14-
const isVisible = (element: HTMLDivElement) => {
15-
const rect = element.getBoundingClientRect()
16-
return (
17-
rect.top >= 0 &&
18-
rect.left >= 0 &&
19-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
20-
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
21-
)
22-
}
14+
import { isVisible } from './../../utils'
2315

2416
const CCarousel = defineComponent({
2517
name: 'CCarousel',

packages/coreui-vue/src/components/sidebar/CSidebar.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from 'vue'
22
import { CBackdrop } from '../backdrop'
33

4+
import { isVisible } from './../../utils'
5+
46
const isOnMobile = (element: HTMLDivElement) =>
57
Boolean(getComputedStyle(element).getPropertyValue('--cui-is-mobile'))
68

7-
const isVisible = (element: HTMLDivElement) => {
8-
const rect = element.getBoundingClientRect()
9-
return (
10-
rect.top >= 0 &&
11-
rect.left >= 0 &&
12-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
13-
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
14-
)
15-
}
16-
179
const CSidebar = defineComponent({
1810
name: 'CSidebar',
1911
props: {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import isVisible from './isVisible'
2+
3+
export { isVisible }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const isVisible = (element: HTMLElement) => {
2+
const rect = element.getBoundingClientRect()
3+
return (
4+
rect.top >= 0 &&
5+
rect.left >= 0 &&
6+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
7+
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
8+
)
9+
}
10+
11+
export default isVisible

0 commit comments

Comments
 (0)