@@ -2,6 +2,7 @@ import "regenerator-runtime/runtime"; // needed for ``await`` support
2
2
import "../../core/jquery-ext" ;
3
3
import $ from "jquery" ;
4
4
import Base from "../../core/base" ;
5
+ import dom from "../../core/dom" ;
5
6
import logging from "../../core/logging" ;
6
7
import Parser from "../../core/parser" ;
7
8
import utils from "../../core/utils" ;
@@ -123,26 +124,6 @@ export default Base.extend({
123
124
}
124
125
} ,
125
126
126
- findScrollContainer ( el ) {
127
- const direction = this . options . direction ;
128
- let scrollable = $ ( el )
129
- . parents ( )
130
- . filter ( ( idx , el ) => {
131
- return (
132
- [ "auto" , "scroll" ] . indexOf ( $ ( el ) . css ( "overflow" ) ) > - 1 ||
133
- ( direction === "top" &&
134
- [ "auto" , "scroll" ] . indexOf ( $ ( el ) . css ( "overflow-y" ) ) > - 1 ) ||
135
- ( direction === "left" &&
136
- [ "auto" , "scroll" ] . indexOf ( $ ( el ) . css ( "overflow-x" ) ) > - 1 )
137
- ) ;
138
- } )
139
- . first ( ) ;
140
- if ( typeof scrollable [ 0 ] === "undefined" ) {
141
- scrollable = $ ( "body" ) ;
142
- }
143
- return scrollable ;
144
- } ,
145
-
146
127
_get_selector_target ( ) {
147
128
const selector = this . options . selector ;
148
129
if ( ! selector && this . el . href ?. includes ( "#" ) ) {
@@ -162,11 +143,21 @@ export default Base.extend({
162
143
let scrollable ;
163
144
if ( this . options . selector === "top" ) {
164
145
// Just scroll up or left, period.
165
- scrollable = this . findScrollContainer ( this . $el ) ;
146
+ scrollable = $ (
147
+ dom . find_scroll_container (
148
+ this . el . parentElement ,
149
+ this . options . direction === "top" ? "y" : "x"
150
+ )
151
+ ) ;
166
152
options [ scroll ] = 0 ;
167
153
} else if ( this . options . selector === "bottom" ) {
168
154
// Just scroll down or right, period.
169
- scrollable = this . findScrollContainer ( this . $el ) ;
155
+ scrollable = $ (
156
+ dom . find_scroll_container (
157
+ this . el . parentElement ,
158
+ this . options . direction === "top" ? "y" : "x"
159
+ )
160
+ ) ;
170
161
if ( scroll === "scrollTop" ) {
171
162
options . scrollTop = scrollable [ 0 ] . scrollHeight ;
172
163
} else {
@@ -184,7 +175,12 @@ export default Base.extend({
184
175
return ;
185
176
}
186
177
187
- scrollable = this . findScrollContainer ( target ) ;
178
+ scrollable = $ (
179
+ dom . find_scroll_container (
180
+ target [ 0 ] . parentElement ,
181
+ this . options . direction === "top" ? "y" : "x"
182
+ )
183
+ ) ;
188
184
189
185
if ( scrollable [ 0 ] === document . body ) {
190
186
// positioning context is document
0 commit comments