Move ctrl-mousewheel handling out of TextEditorComponent

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2016-07-27 16:02:24 -07:00
committed by Nathan Sobo
parent ab30ecf994
commit e1f8a72995
3 changed files with 50 additions and 10 deletions

View File

@@ -392,15 +392,6 @@ class TextEditorComponent
# Only scroll in one direction at a time
{wheelDeltaX, wheelDeltaY} = event
# Ctrl+MouseWheel adjusts font size.
if event.ctrlKey and @config.get('editor.zoomFontWhenCtrlScrolling')
if wheelDeltaY > 0
@workspace.increaseFontSize()
else if wheelDeltaY < 0
@workspace.decreaseFontSize()
event.preventDefault()
return
if Math.abs(wheelDeltaX) > Math.abs(wheelDeltaY)
# Scrolling horizontally
previousScrollLeft = @presenter.getScrollLeft()

View File

@@ -76,6 +76,8 @@ class WorkspaceElement extends HTMLElement
@verticalAxis.appendChild(@paneContainer)
@addEventListener 'focus', @handleFocus.bind(this)
@addEventListener 'mousewheel', @handleMousewheel.bind(this), true
@panelContainers =
top: @views.getView(@model.panelContainers.top)
left: @views.getView(@model.panelContainers.left)
@@ -100,6 +102,15 @@ class WorkspaceElement extends HTMLElement
getModel: -> @model
handleMousewheel: (event) ->
if event.ctrlKey and @config.get('editor.zoomFontWhenCtrlScrolling') and event.target.matches('atom-text-editor')
if event.wheelDeltaY > 0
@model.increaseFontSize()
else if event.wheelDeltaY < 0
@model.decreaseFontSize()
event.preventDefault()
event.stopPropagation()
handleFocus: (event) ->
@model.getActivePane().activate()