Skip to content

Commit f4437a5

Browse files
devvaannshabose
authored andcommitted
fix: diagonal scrolling issues
1 parent f155f9f commit f4437a5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/editor/Editor.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,11 @@ define(function (require, exports, module) {
445445
const lineHeight = parseFloat(getComputedStyle($editor[0]).lineHeight);
446446
const defaultHeight = 14, scrollScaleFactor = lineHeight/defaultHeight;
447447

448-
// when user is pressing the 'Shift' key or deltaX is present, we should handle horizontal scrolling
449-
if (event.shiftKey || event.deltaX !== 0) {
448+
// when user is pressing the 'Shift' key, we need to convert the vertical scroll to horizontal scroll
449+
if (event.shiftKey) {
450450
let horizontalDelta = event.deltaX;
451451

452-
if (event.shiftKey && event.deltaY !== 0) {
452+
if (event.deltaY !== 0) {
453453
horizontalDelta = event.deltaY;
454454
}
455455

@@ -461,6 +461,11 @@ define(function (require, exports, module) {
461461
}
462462
}
463463

464+
// apply horizontal scrolling if present. for the diagonal scrolling
465+
if (event.deltaX !== 0) {
466+
$editor[0].scrollLeft += event.deltaX;
467+
}
468+
464469
// apply the vertical scrolling normally
465470
if (event.deltaY !== 0) {
466471
const scrollDelta = event.deltaY;

0 commit comments

Comments
 (0)