Skip to content

Instantly share code, notes, and snippets.

@rdnt
Created March 25, 2020 15:29
Show Gist options
  • Save rdnt/5aa63200e2b2c1f82ac53a9fcd16d4d9 to your computer and use it in GitHub Desktop.
Save rdnt/5aa63200e2b2c1f82ac53a9fcd16d4d9 to your computer and use it in GitHub Desktop.
handleMousewheel(event) {
this.holdingCtrl = event.ctrlKey;
if (event.deltaY == 0 && event.deltaX == 0) {
// inertial scroll has started
this.inertialScroll = true;
}
clearTimeout(this.timer);
this.timer = setTimeout(() => {
// inertial scroll has stopped
this.inertialScroll = false;
}, 150);
if (
event.ctrlKey && !this.inertialScroll &&
this.config.get('editor.zoomFontWhenCtrlScrolling') &&
event.target.closest('atom-text-editor') != null
) {
if (event.wheelDeltaY > 0) {
this.model.increaseFontSize();
} else if (event.wheelDeltaY < 0) {
this.model.decreaseFontSize();
}
event.preventDefault();
event.stopPropagation();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment