File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -187,8 +187,15 @@ export const scroller = () => {
187
187
diffX = targetX - initialX ;
188
188
189
189
if ( ! force ) {
190
+ // When the container is the default (body) we need to use the viewport
191
+ // height, not the entire body height
192
+ const containerHeight =
193
+ container . tagName . toLowerCase ( ) === "body"
194
+ ? document . documentElement . clientHeight ||
195
+ window . innerHeight
196
+ : container . offsetHeight ;
190
197
const containerTop = initialY ;
191
- const containerBottom = containerTop + container . offsetHeight ;
198
+ const containerBottom = containerTop + containerHeight ;
192
199
const elementTop = targetY ;
193
200
const elementBottom = elementTop + element . offsetHeight ;
194
201
if (
@@ -197,7 +204,7 @@ export const scroller = () => {
197
204
) {
198
205
// make sure to call the onDone callback even if there is no need to
199
206
// scroll the container. Fixes #111 (ref #118)
200
- onDone ( element ) ;
207
+ if ( onDone ) onDone ( element ) ;
201
208
return ;
202
209
}
203
210
}
You can’t perform that action at this time.
0 commit comments