Does the Magic mouse work better now?
First, I had a bug
if (delta >= 1 ) {
zoom_in;
} else if (delta <= -1) {
zoom_out;
}
The second if() was comparing to +1, which works with click wheel, but would make any smooth scrolling device zoom out erratically.
Then I was not handling horizontal scroll which would also cause zoom on left-right movement (with wrong delta too).
The documentation says it well:
https://developer.mozilla.org/en-US/docs/Web/API/Element/mousewheel_event
If the device supports continuous scroll (e.g., trackpad of MacBook or mouse wheel which can be turned smoothly), the value is computed from accelerated scroll amount. In this case, the value is the same as Safari.
If the device does not support continuous scroll (typically, old mouse wheel which cannot be turned smoothly), the value is computed from non-accelerated scroll amount (120 per notch). In this case, the value is different from Safari.