File tree 1 file changed +14
-0
lines changed 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> {
15
15
* Make sidebar narrow.
16
16
*/
17
17
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
18
26
/**
19
27
* Event emitted after visibility of component changed.
20
28
*/
@@ -60,6 +68,8 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
60
68
children,
61
69
className,
62
70
narrow,
71
+ onHide,
72
+ onShow,
63
73
onVisibleChange,
64
74
overlaid,
65
75
position,
@@ -84,6 +94,8 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
84
94
85
95
useEffect ( ( ) => {
86
96
typeof inViewport !== 'undefined' && onVisibleChange && onVisibleChange ( inViewport )
97
+ ! inViewport && onHide && onHide ( )
98
+ inViewport && onShow && onShow ( )
87
99
} , [ inViewport ] )
88
100
89
101
useEffect ( ( ) => {
@@ -186,6 +198,8 @@ CSidebar.propTypes = {
186
198
children : PropTypes . node ,
187
199
className : PropTypes . string ,
188
200
narrow : PropTypes . bool ,
201
+ onHide : PropTypes . func ,
202
+ onShow : PropTypes . func ,
189
203
onVisibleChange : PropTypes . func ,
190
204
overlaid : PropTypes . bool ,
191
205
position : PropTypes . oneOf ( [ 'fixed' , 'sticky' ] ) ,
You can’t perform that action at this time.
0 commit comments