mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 10:12:00 +08:00
fix(email-frame): Listening for mouse events not necessary?
This commit is contained in:
parent
21e8455ef6
commit
8cb70f9ce6
1 changed files with 1 additions and 12 deletions
|
@ -123,7 +123,6 @@ EmailFrame = React.createClass
|
|||
doc = @getDOMNode().contentDocument
|
||||
doc?.removeEventListener?("click")
|
||||
doc?.removeEventListener?("keydown")
|
||||
@_delegateMouseEvents(doc, "removeEventListener")
|
||||
|
||||
shouldComponentUpdate: (newProps, newState) ->
|
||||
# Turns out, React is not able to tell if props.children has changed,
|
||||
|
@ -141,7 +140,6 @@ EmailFrame = React.createClass
|
|||
doc.close()
|
||||
doc.addEventListener "click", @_onClick
|
||||
doc.addEventListener "keydown", @_onKeydown
|
||||
@_delegateMouseEvents(doc, "addEventListener")
|
||||
|
||||
_setFrameHeight: ->
|
||||
_.defer =>
|
||||
|
@ -186,14 +184,5 @@ EmailFrame = React.createClass
|
|||
target = target.parentElement
|
||||
|
||||
_onKeydown: (event) ->
|
||||
return if event.metaKey or event.altKey or event.ctrlKey
|
||||
@getDOMNode().dispatchEvent(new KeyboardEvent(event.type, event))
|
||||
|
||||
_delegateMouseEvents: (doc, method="addEventListener") ->
|
||||
for type in ["mouseup", "mousedown"]
|
||||
doc?[method]?(type, @_onMouseEvent)
|
||||
|
||||
_onMouseEvent: (event) ->
|
||||
{top, left} = @getDOMNode().getBoundingClientRect()
|
||||
new_coords = {clientX: event.clientX + left, clientY: event.clientY + top}
|
||||
new_event = _.extend {}, event, new_coords
|
||||
@getDOMNode().dispatchEvent(new MouseEvent(event.type, new_event))
|
||||
|
|
Loading…
Reference in a new issue