@@ -80,6 +80,7 @@ export const WithGNB = () => {
8080 This is GNB
8181 </ GNB >
8282 < Navigation
83+ withScroll
8384 title = { text ( 'navigation title' , '고객 연락처' ) }
8485 fixedTitle = { boolean ( 'fixed title' , false ) }
8586 maxWidth = { number ( 'max width' , 540 ) }
@@ -125,3 +126,66 @@ export const WithGNB = () => {
125126 </ div >
126127 )
127128}
129+
130+ export const ProgrammaticScroll = ( ) => {
131+ const scrollAreaRef = useRef < HTMLDivElement | null > ( null )
132+ const firstMilestone = useRef < HTMLDivElement | null > ( null )
133+ const secondMilestone = useRef < HTMLDivElement | null > ( null )
134+ const scrollToTop = useCallback ( ( ) => {
135+ scrollAreaRef . current . scrollTop = 0
136+ } , [ ] )
137+
138+ const scrollToBottom = useCallback ( ( ) => {
139+ scrollAreaRef . current . scrollTop = scrollAreaRef . current . scrollHeight
140+ } , [ ] )
141+
142+ return (
143+ < div
144+ style = { { display : 'flex' , height : '100%' } }
145+ >
146+ < ThemeProvider theme = { LightTheme } >
147+ < Navigation
148+ scrollRef = { scrollAreaRef }
149+ withScroll
150+ >
151+ < div
152+ style = { {
153+ position : 'relative' ,
154+ height : 15000 ,
155+ } }
156+ >
157+ < div style = { { position : 'absolute' , top : 0 } } >
158+ Hi, This is TOP!
159+ </ div >
160+
161+ < div
162+ ref = { firstMilestone }
163+ style = { { position : 'absolute' , top : 3000 } }
164+ >
165+ 1st Milestone
166+ </ div >
167+
168+ < div
169+ ref = { secondMilestone }
170+ style = { { position : 'absolute' , top : 8000 } }
171+ >
172+ 2nd Milestone
173+ </ div >
174+
175+ < div style = { { position : 'absolute' , bottom : 0 } } >
176+ Oh hello, This is BOTTOM!
177+ </ div >
178+ </ div >
179+ </ Navigation >
180+ < div >
181+ < button type = "button" onClick = { scrollToTop } >
182+ Go to Top
183+ </ button >
184+ < button type = "button" onClick = { scrollToBottom } >
185+ Go to Bottom
186+ </ button >
187+ </ div >
188+ </ ThemeProvider >
189+ </ div >
190+ )
191+ }
0 commit comments