@@ -10,6 +10,7 @@ export interface ScrollStrategyData {
10
10
root : Ref < HTMLElement | undefined >
11
11
contentEl : Ref < HTMLElement | undefined >
12
12
targetEl : Ref < HTMLElement | undefined >
13
+ target : Ref < HTMLElement | [ x : number , y : number ] | undefined >
13
14
isActive : Ref < boolean >
14
15
updateLocation : Ref < ( ( e : Event ) => void ) | undefined >
15
16
}
@@ -69,13 +70,16 @@ function closeScrollStrategy (data: ScrollStrategyData) {
69
70
data . isActive . value = false
70
71
}
71
72
72
- bindScroll ( data . targetEl . value ?? data . contentEl . value , onScroll )
73
+ bindScroll ( data . target . value ?? data . contentEl . value , onScroll )
73
74
}
74
75
75
76
function blockScrollStrategy ( data : ScrollStrategyData , props : StrategyProps ) {
76
77
const offsetParent = data . root . value ?. offsetParent
78
+ const target = Array . isArray ( data . target . value )
79
+ ? document . elementFromPoint ( ...data . target . value )
80
+ : data . target . value
77
81
const scrollElements = [ ...new Set ( [
78
- ...getScrollParents ( data . targetEl . value , props . contained ? offsetParent : undefined ) ,
82
+ ...getScrollParents ( target , props . contained ? offsetParent : undefined ) ,
79
83
...getScrollParents ( data . contentEl . value , props . contained ? offsetParent : undefined ) ,
80
84
] ) ] . filter ( el => ! el . classList . contains ( 'v-overlay-scroll-blocked' ) )
81
85
const scrollbarWidth = window . innerWidth - document . documentElement . offsetWidth
@@ -136,7 +140,7 @@ function repositionScrollStrategy (data: ScrollStrategyData, props: StrategyProp
136
140
137
141
ric = ( typeof requestIdleCallback === 'undefined' ? ( cb : Function ) => cb ( ) : requestIdleCallback ) ( ( ) => {
138
142
scope . run ( ( ) => {
139
- bindScroll ( data . targetEl . value ?? data . contentEl . value , e => {
143
+ bindScroll ( data . target . value ?? data . contentEl . value , e => {
140
144
if ( slow ) {
141
145
// If the position calculation is slow,
142
146
// defer updates until scrolling is finished.
@@ -162,7 +166,8 @@ function repositionScrollStrategy (data: ScrollStrategyData, props: StrategyProp
162
166
}
163
167
164
168
/** @private */
165
- function bindScroll ( el : HTMLElement | undefined , onScroll : ( e : Event ) => void ) {
169
+ function bindScroll ( target : HTMLElement | [ x : number , y : number ] | undefined , onScroll : ( e : Event ) => void ) {
170
+ const el = Array . isArray ( target ) ? document . elementFromPoint ( ...target ) : target
166
171
const scrollElements = [ document , ...getScrollParents ( el ) ]
167
172
scrollElements . forEach ( el => {
168
173
el . addEventListener ( 'scroll' , onScroll , { passive : true } )
0 commit comments