Browser-floor cleanup: drop legacy polyfills + modernise wheel/scroll#153
Browser-floor cleanup: drop legacy polyfills + modernise wheel/scroll#153moodyjmz wants to merge 4 commits into
Conversation
Both polyfills are unreachable in any supported browser — native fetch/Promise are universal since Chrome 42/FF 39/Safari 10.1. The codebase already calls fetch() unconditionally at multiple sites regardless of the locale.js guard. The locale.js guard was already stripped at build time by the locale-fetch string-replace-loader rule (webpack.editor.factory.mjs:161). vendor/fetch/ and vendor/es6-promise/ stay in-tree so upstream pulls stay clean; they are no longer copied to BUILD_ROOT. Closes #129 (fetch/es6-promise portion). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
…event
DOMMouseScroll was removed in Firefox 87 (March 2021). The UA sniff routed all
Firefox users into registering a DOMMouseScroll listener — an event that is never
dispatched. Firefox scroll was silently broken in the document area of all editors.
Replace with the standard wheel event (universal since 2014) across all 11 affected
files. Two listener patterns updated:
- DocumentHolder.js × 5 editors + DocumentHolderExt.js: event name + collapse the
isChrome/jQuery ternary to a single document.addEventListener('wheel', ..., {passive:false})
- Print.js × 5 editors: event name only
- TabBar.js: unify Mac/non-Mac binding (both now use wheel → _onMouseWheelThrottled);
fix delta reading with deltaMode normalisation so Firefox line-unit deltas (deltaMode=1)
are not swallowed by the magnitude threshold
vendor/perfect-scrollbar/src/jquery.mousewheel.js left alone (vendored upstream source).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
|
|
||
| var eventname = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; | ||
| var eventname = 'wheel'; | ||
| this.printSettings.$previewBox.on(eventname, _.bind(this.onPreviewWheel, this)); |
There was a problem hiding this comment.
as far as I understand $previewBox is a jquery obj and in current version of it which is 3.5.1 the wheel event doesn't expose deltaY on the jquery event object which means e.deltaY would be undefined so forward wil lbe always false
would it make sense to change the event back to mousewheel in all printjs files? The jquery.mousewheel plugin can provide e.deltaY for mousewheel events
There was a problem hiding this comment.
Good catch — you're right. jQuery 3 wraps events and doesn't copy deltaY into the wrapper, so e.deltaY was undefined and forward always evaluated to false.
Fixed in 230a052: switched all five Print.js files from $previewBox.on('wheel', ...) to native $previewBox[0].addEventListener('wheel', ..., {passive: false}). The {passive: false} is needed because onPreviewWheel calls preventDefault() on Ctrl+scroll — consistent with how DocumentHolder.js already binds its wheel listener.
There was a problem hiding this comment.
Fair point, and you were right about the version you saw — jQuery wasn't exposing deltaY on the wheel event. Since switched to native addEventListener('wheel', …) which does. Apologies for the drive-by review request though — Claude got a bit eager and pinged reviewers when this should've gone up as a draft first. Marking it draft now while I finish the runtime testing. :P
There was a problem hiding this comment.
@moodyjmz
No need to apologize!!! we're a team and the whole point of reviews is to catch things together and make the project better
It happens to every single of us especially in a big codebase even claude misses things sometimes!
other than that I didn't find any other issues and LGTM!
…EventListener
jQuery 3 wraps events and does not copy deltaY to the wrapper object, so
$el.on('wheel', handler) produces e.deltaY === undefined — forward always false.
Switch to native addEventListener (consistent with DocumentHolder.js) so the
handler receives a real WheelEvent. Pass {passive: false} since onPreviewWheel
calls preventDefault() on Ctrl+scroll.
Caught by MonaAghili in PR review.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
…heel handlers
The old jQuery .on('mousewheel') path routed through the jquery.mousewheel plugin
(vendor/perfect-scrollbar/src/jquery.mousewheel.js) which negates native deltaY to
up-positive (scroll up = positive). Native wheel event is down-positive. TabBar.js
already accounts for this. The other two handler families did not.
Print.js (×5): forward = (e.deltaY||...) < 0 → scroll down gave deltaY>0, forward=false,
onChangePreviewPage(false) → previous page. Inverted on all browsers, including Chrome
(regression from this PR). Fix: forward = e.deltaY > 0.
DocumentHolder.js (×5): delta reading fell through to event.deltaY when wheelDelta was
absent (Firefox), giving down-positive delta → Ctrl+scroll up → zoomOut. Inverted on
Firefox. Fix: negate deltaY (-event.deltaY) to match the up-positive convention the
existing delta<0/delta>0 zoom branches expect.
Caught by independent code review.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
|
Independent review caught two sign-inversion bugs introduced by this PR — both now fixed in 0ffa044. Root causeThe old jQuery Bug 1 — Print preview scroll direction inverted (all browsers)
// before: down-scroll → deltaY > 0 → forward = false → previous page (wrong)
var forward = (e.deltaY || ...) < 0;
// after
var forward = e.deltaY > 0;This regressed Chrome, which worked before the PR. Bug 2 — Ctrl+scroll zoom direction inverted (Firefox)
// before: Firefox has no wheelDelta → fell through to raw deltaY → down-positive
// scroll up → deltaY < 0 → delta < 0 → zoomOut (wrong)
var delta = (_.isUndefined(event.originalEvent)) ? event.wheelDelta : event.originalEvent.wheelDelta;
if (_.isUndefined(delta)) { delta = event.deltaY; }
// after: negate deltaY → up-positive → existing delta>0=zoomIn stays correct
var delta = event.deltaY !== undefined ? -event.deltaY : event.wheelDelta;Firefox had no working Ctrl+zoom before this PR (DOMMouseScroll path was dead). The fix makes it correct rather than merely swapping dead for inverted. |
696e515 to
0ffa044
Compare
Low-hanging-fruit browser-floor cleanup — removes dead weight, no behavioural risk on the modern floor.
fetch/es6-promisepolyfills (unused once IE/legacy is off the floor).DOMMouseScroll/mousewheelUA-sniffing with the standardwheelevent across desktop editors.Details
Polyfills —
fetchandes6-promiseare dropped frombuild/vendor.manifest.mjs, so the deploy step stops copying them. The vendor dirs stay in the tree (upstream keeps shipping them); we just don't deploy them.Wheel/scroll — three fixes in the desktop editors'
Print.js/DocumentHolder.js:DOMMouseScroll/mousewheelUA-sniff with the standardwheelevent.Print.jsbinding from jQuery.on()toaddEventListener.deltasign inPrint.jsandDocumentHolder.js.Part of the browser-floor-stage1 work; the mobile/ES2022 half is a separate PR.