@@ -85,12 +85,12 @@ class NativeScrollbars {
8585
8686 setScrollLeft ( pos ) {
8787 if ( this . horiz . scrollLeft != pos ) this . horiz . scrollLeft = pos
88- if ( this . disableHoriz ) this . enableZeroWidthBar ( this . horiz , this . disableHoriz )
88+ if ( this . disableHoriz ) this . enableZeroWidthBar ( this . horiz , this . disableHoriz , "horiz" )
8989 }
9090
9191 setScrollTop ( pos ) {
9292 if ( this . vert . scrollTop != pos ) this . vert . scrollTop = pos
93- if ( this . disableVert ) this . enableZeroWidthBar ( this . vert , this . disableVert )
93+ if ( this . disableVert ) this . enableZeroWidthBar ( this . vert , this . disableVert , "vert" )
9494 }
9595
9696 zeroWidthHack ( ) {
@@ -101,17 +101,18 @@ class NativeScrollbars {
101101 this . disableVert = new Delayed
102102 }
103103
104- enableZeroWidthBar ( bar , delay ) {
104+ enableZeroWidthBar ( bar , delay , type ) {
105105 bar . style . pointerEvents = "auto"
106106 function maybeDisable ( ) {
107107 // To find out whether the scrollbar is still visible, we
108108 // check whether the element under the pixel in the bottom
109- // left corner of the scrollbar box is the scrollbar box
109+ // right corner of the scrollbar box is the scrollbar box
110110 // itself (when the bar is still visible) or its filler child
111111 // (when the bar is hidden). If it is still visible, we keep
112112 // it enabled, if it's hidden, we disable pointer events.
113113 let box = bar . getBoundingClientRect ( )
114- let elt = document . elementFromPoint ( box . left + 1 , box . bottom - 1 )
114+ let elt = type == "vert" ? document . elementFromPoint ( box . right - 1 , ( box . top + box . bottom ) / 2 )
115+ : document . elementFromPoint ( ( box . right + box . left ) / 2 , box . bottom - 1 )
115116 if ( elt != bar ) bar . style . pointerEvents = "none"
116117 else delay . set ( 1000 , maybeDisable )
117118 }
0 commit comments