File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ export interface CSidebarProps extends HTMLAttributes<HTMLDivElement> {
1515 * Make sidebar narrow.
1616 */
1717 narrow ?: boolean
18+ /**
19+ * Callback fired when the component requests to be hidden.
20+ */
21+ onHide ?: ( ) => void
22+ /**
23+ * Callback fired when the component requests to be shown.
24+ */
25+ onShow ?: ( ) => void
1826 /**
1927 * Event emitted after visibility of component changed.
2028 */
@@ -60,6 +68,8 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
6068 children,
6169 className,
6270 narrow,
71+ onHide,
72+ onShow,
6373 onVisibleChange,
6474 overlaid,
6575 position,
@@ -84,6 +94,8 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
8494
8595 useEffect ( ( ) => {
8696 typeof inViewport !== 'undefined' && onVisibleChange && onVisibleChange ( inViewport )
97+ ! inViewport && onHide && onHide ( )
98+ inViewport && onShow && onShow ( )
8799 } , [ inViewport ] )
88100
89101 useEffect ( ( ) => {
@@ -186,6 +198,8 @@ CSidebar.propTypes = {
186198 children : PropTypes . node ,
187199 className : PropTypes . string ,
188200 narrow : PropTypes . bool ,
201+ onHide : PropTypes . func ,
202+ onShow : PropTypes . func ,
189203 onVisibleChange : PropTypes . func ,
190204 overlaid : PropTypes . bool ,
191205 position : PropTypes . oneOf ( [ 'fixed' , 'sticky' ] ) ,
You can’t perform that action at this time.
0 commit comments