@@ -41,6 +41,12 @@ export function wheelEventPixels(e) {
4141
4242export function onScrollWheel ( cm , e ) {
4343 let delta = wheelEventDelta ( e ) , dx = delta . x , dy = delta . y
44+ let pixelsPerUnit = wheelPixelsPerUnit
45+ if ( event . deltaMode === 0 ) {
46+ dx = e . deltaX
47+ dy = e . deltaY
48+ pixelsPerUnit = 1
49+ }
4450
4551 let display = cm . display , scroll = display . scroller
4652 // Quit if there's nothing to scroll here
@@ -69,10 +75,10 @@ export function onScrollWheel(cm, e) {
6975 // estimated pixels/delta value, we just handle horizontal
7076 // scrolling entirely here. It'll be slightly off from native, but
7177 // better than glitching out.
72- if ( dx && ! gecko && ! presto && wheelPixelsPerUnit != null ) {
78+ if ( dx && ! gecko && ! presto && pixelsPerUnit != null ) {
7379 if ( dy && canScrollY )
74- updateScrollTop ( cm , Math . max ( 0 , scroll . scrollTop + dy * wheelPixelsPerUnit ) )
75- setScrollLeft ( cm , Math . max ( 0 , scroll . scrollLeft + dx * wheelPixelsPerUnit ) )
80+ updateScrollTop ( cm , Math . max ( 0 , scroll . scrollTop + dy * pixelsPerUnit ) )
81+ setScrollLeft ( cm , Math . max ( 0 , scroll . scrollLeft + dx * pixelsPerUnit ) )
7682 // Only prevent default scrolling if vertical scrolling is
7783 // actually possible. Otherwise, it causes vertical scroll
7884 // jitter on OSX trackpads when deltaX is small and deltaY
@@ -85,15 +91,15 @@ export function onScrollWheel(cm, e) {
8591
8692 // 'Project' the visible viewport to cover the area that is being
8793 // scrolled into view (if we know enough to estimate it).
88- if ( dy && wheelPixelsPerUnit != null ) {
89- let pixels = dy * wheelPixelsPerUnit
94+ if ( dy && pixelsPerUnit != null ) {
95+ let pixels = dy * pixelsPerUnit
9096 let top = cm . doc . scrollTop , bot = top + display . wrapper . clientHeight
9197 if ( pixels < 0 ) top = Math . max ( 0 , top + pixels - 50 )
9298 else bot = Math . min ( cm . doc . height , bot + pixels + 50 )
9399 updateDisplaySimple ( cm , { top : top , bottom : bot } )
94100 }
95101
96- if ( wheelSamples < 20 ) {
102+ if ( wheelSamples < 20 && e . deltaMode !== 0 ) {
97103 if ( display . wheelStartX == null ) {
98104 display . wheelStartX = scroll . scrollLeft ; display . wheelStartY = scroll . scrollTop
99105 display . wheelDX = dx ; display . wheelDY = dy
0 commit comments