File tree Expand file tree Collapse file tree 2 files changed +19
-22
lines changed
Expand file tree Collapse file tree 2 files changed +19
-22
lines changed Original file line number Diff line number Diff line change 11import { getEventPath , stopAndPrevent } from './event.js'
2- import { hasScrollbar , hasScrollbarX } from './scroll.js'
2+ import { hasScrollbar } from './scroll.js'
33import Platform from '../plugins/platform.js'
44
55let registered = 0
@@ -17,13 +17,12 @@ function shouldPreventScroll (e) {
1717
1818 const
1919 path = getEventPath ( e ) ,
20- scrollY = Math . abs ( e . deltaX ) <= Math . abs ( e . deltaY ) ,
21- testFn = scrollY ? hasScrollbar : hasScrollbarX
20+ scrollY = Math . abs ( e . deltaX ) <= Math . abs ( e . deltaY )
2221
2322 for ( let index = 0 ; index < path . length ; index ++ ) {
2423 const el = path [ index ]
2524
26- if ( testFn ( el ) ) {
25+ if ( hasScrollbar ( el , scrollY ) ) {
2726 return scrollY
2827 ? (
2928 e . deltaY < 0 && el . scrollTop === 0
Original file line number Diff line number Diff line change @@ -96,28 +96,26 @@ export function getScrollbarWidth () {
9696 return size
9797}
9898
99- export function hasScrollbar ( el ) {
99+ export function hasScrollbar ( el , onY = true ) {
100100 if ( ! el || el . nodeType !== Node . ELEMENT_NODE ) {
101101 return false
102102 }
103103
104- return el . scrollHeight > el . clientHeight && (
105- el . classList . contains ( 'scroll' ) ||
106- el . classList . contains ( 'overflow-auto' ) ||
107- [ 'auto' , 'scroll' ] . includes ( window . getComputedStyle ( el ) [ 'overflow-y' ] )
108- )
109- }
110-
111- export function hasScrollbarX ( el ) {
112- if ( ! el || el . nodeType !== Node . ELEMENT_NODE ) {
113- return false
114- }
115-
116- return el . scrollWidth > el . clientWidth && (
117- el . classList . contains ( 'scroll' ) ||
118- el . classList . contains ( 'overflow-auto' ) ||
119- [ 'auto' , 'scroll' ] . includes ( window . getComputedStyle ( el ) [ 'overflow-x' ] )
120- )
104+ return onY
105+ ? (
106+ el . scrollHeight > el . clientHeight && (
107+ el . classList . contains ( 'scroll' ) ||
108+ el . classList . contains ( 'overflow-auto' ) ||
109+ [ 'auto' , 'scroll' ] . includes ( window . getComputedStyle ( el ) [ 'overflow-y' ] )
110+ )
111+ )
112+ : (
113+ el . scrollWidth > el . clientWidth && (
114+ el . classList . contains ( 'scroll' ) ||
115+ el . classList . contains ( 'overflow-auto' ) ||
116+ [ 'auto' , 'scroll' ] . includes ( window . getComputedStyle ( el ) [ 'overflow-x' ] )
117+ )
118+ )
121119}
122120
123121export default {
You can’t perform that action at this time.
0 commit comments