@@ -333,6 +333,21 @@ abstract class _BaseAdapter {
333333mixin _WheelEventListenerMixin on _BaseAdapter {
334334 static double ? _defaultScrollLineHeight;
335335
336+ bool _isAcceleratedMouseWheelDelta (num delta, num ? wheelDelta) {
337+ // On macOS, scrolling using a mouse wheel by default uses an acceleration
338+ // curve, so delta values ramp up and are not at fixed multiples of 120.
339+ // But in this case, the wheelDelta properties of the event still keep
340+ // their original values.
341+ // For all events without this acceleration curve applied, the wheelDelta
342+ // values are by convention three times greater than the delta values and with
343+ // the opposite sign.
344+ if (wheelDelta == null ) {
345+ return false ;
346+ }
347+ // Account for observed issues with integer truncation by allowing +-1px error.
348+ return (wheelDelta - (- 3 * delta)).abs () > 1 ;
349+ }
350+
336351 bool _isTrackpadEvent (DomWheelEvent event) {
337352 // This function relies on deprecated and non-standard implementation
338353 // details. Useful reference material can be found below.
@@ -355,15 +370,8 @@ mixin _WheelEventListenerMixin on _BaseAdapter {
355370 // a trackpad.
356371 return false ;
357372 }
358- if (((event.wheelDeltaX ?? (- 3 * event.deltaX)) != - 3 * event.deltaX) ||
359- ((event.wheelDeltaY ?? (- 3 * event.deltaY)) != - 3 * event.deltaY)) {
360- // On macOS, scrolling using a mouse wheel by default uses an acceleration
361- // curve, so delta values ramp up and are not at fixed multiples of 120.
362- // But in this case, the wheelDelta properties of the event still keep
363- // their original values.
364- // For all events without this acceleration curve applied, the wheelDelta
365- // values are by convention three times greater than the delta values and with
366- // the opposite sign.
373+ if (_isAcceleratedMouseWheelDelta (event.deltaX, event.wheelDeltaX) ||
374+ _isAcceleratedMouseWheelDelta (event.deltaY, event.wheelDeltaY)) {
367375 return false ;
368376 }
369377 return true ;
0 commit comments