File tree Expand file tree Collapse file tree 4 files changed +16
-20
lines changed
packages/coreui-react/src Expand file tree Collapse file tree 4 files changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,9 @@ import React, {
1010import PropTypes from 'prop-types'
1111import classNames from 'classnames'
1212
13+ import { isVisible } from '../../utils'
1314import { useForkedRef } from '../../utils/hooks'
1415
15- const isVisible = ( element : HTMLDivElement ) => {
16- const rect = element . getBoundingClientRect ( )
17- return (
18- rect . top >= 0 &&
19- rect . left >= 0 &&
20- rect . bottom <= ( window . innerHeight || document . documentElement . clientHeight ) &&
21- rect . right <= ( window . innerWidth || document . documentElement . clientWidth )
22- )
23- }
24-
2516export interface CCarouselProps extends HTMLAttributes < HTMLDivElement > {
2617 /**
2718 * index of the active item.
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
33import PropTypes from 'prop-types'
44import classNames from 'classnames'
55
6+ import { isVisible } from '../../utils'
67import { useForkedRef } from '../../utils/hooks'
78import { CBackdrop } from '../backdrop/CBackdrop'
89
@@ -52,16 +53,6 @@ export interface CSidebarProps extends HTMLAttributes<HTMLDivElement> {
5253const isOnMobile = ( element : HTMLDivElement ) =>
5354 Boolean ( getComputedStyle ( element ) . getPropertyValue ( '--cui-is-mobile' ) )
5455
55- const isVisible = ( element : HTMLDivElement ) => {
56- const rect = element . getBoundingClientRect ( )
57- return (
58- rect . top >= 0 &&
59- rect . left >= 0 &&
60- rect . bottom <= ( window . innerHeight || document . documentElement . clientHeight ) &&
61- rect . right <= ( window . innerWidth || document . documentElement . clientWidth )
62- )
63- }
64-
6556export const CSidebar = forwardRef < HTMLDivElement , CSidebarProps > (
6657 (
6758 {
Original file line number Diff line number Diff line change 1+ import isVisible from './isVisible'
2+
3+ export { isVisible }
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments