Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,35 @@ 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, we need to convert the vertical scroll to horizontal scroll
if (event.shiftKey) {
let horizontalDelta = event.deltaX;

if (event.deltaY !== 0) {
horizontalDelta = event.deltaY;
}

// apply the horizontal scrolling
if (horizontalDelta !== 0) {
$editor[0].scrollLeft += horizontalDelta;
event.preventDefault();
return;
}
}

// 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;
$editor[0].scrollTop += (scrollDelta/scrollScaleFactor);
event.preventDefault();
}
});
}

Expand Down
Loading