From ef530680d2516e2859776e4d68f19bd7ff09e7c7 Mon Sep 17 00:00:00 2001 From: Pluto Date: Sun, 15 Jun 2025 00:05:37 +0530 Subject: [PATCH 1/2] feat: horizontall scrolling on shift + mouse wheel scroll --- src/editor/Editor.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 2aa2b7c70f..14a8472505 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -443,10 +443,30 @@ define(function (require, exports, module) { // this became a problem after we added the custom line height feature causing jumping scrolls esp in safari // and mac if we dont do this scroll scaling. const lineHeight = parseFloat(getComputedStyle($editor[0]).lineHeight); - const scrollDelta = event.deltaY; const defaultHeight = 14, scrollScaleFactor = lineHeight/defaultHeight; - $editor[0].scrollTop += (scrollDelta/scrollScaleFactor); - event.preventDefault(); + + // when user is pressing the 'Shift' key or deltaX is present, we should handle horizontal scrolling + if (event.shiftKey || event.deltaX !== 0) { + let horizontalDelta = event.deltaX; + + if (event.shiftKey && event.deltaY !== 0) { + horizontalDelta = event.deltaY; + } + + // apply the horizontal scrolling + if (horizontalDelta !== 0) { + $editor[0].scrollLeft += horizontalDelta; + event.preventDefault(); + return; + } + } + + // apply the vertical scrolling normally + if (event.deltaY !== 0) { + const scrollDelta = event.deltaY; + $editor[0].scrollTop += (scrollDelta/scrollScaleFactor); + event.preventDefault(); + } }); } From 77104b24537170ad0c7c9ea57a7bbb64e2503a62 Mon Sep 17 00:00:00 2001 From: Pluto Date: Mon, 16 Jun 2025 15:02:57 +0530 Subject: [PATCH 2/2] fix: diagonal scrolling issues --- src/editor/Editor.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 14a8472505..f31702383b 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -445,11 +445,11 @@ define(function (require, exports, module) { const lineHeight = parseFloat(getComputedStyle($editor[0]).lineHeight); const defaultHeight = 14, scrollScaleFactor = lineHeight/defaultHeight; - // when user is pressing the 'Shift' key or deltaX is present, we should handle horizontal scrolling - if (event.shiftKey || event.deltaX !== 0) { + // when user is pressing the 'Shift' key, we need to convert the vertical scroll to horizontal scroll + if (event.shiftKey) { let horizontalDelta = event.deltaX; - if (event.shiftKey && event.deltaY !== 0) { + if (event.deltaY !== 0) { horizontalDelta = event.deltaY; } @@ -461,6 +461,11 @@ define(function (require, exports, module) { } } + // apply horizontal scrolling if present. for the diagonal scrolling + if (event.deltaX !== 0) { + $editor[0].scrollLeft += event.deltaX; + } + // apply the vertical scrolling normally if (event.deltaY !== 0) { const scrollDelta = event.deltaY;