       maxWidth: parseInt(getDimensions(@element).width, 10)
       startX: event.clientX
 
-  drag: (event, element) =>
+  dragover: (event, element) =>
+    return unless @dragging
     width = @dragging.width + event.clientX - @dragging.startX
+
     unless width > @dragging.maxWidth
       width = "#{width}px"
       height = getDimensions(@dragging.image).height

{DOM} = Trix

class Trix.AttachmentController
  events = "dragstart drag dragend".split(" ")
  imageEditorSelector = "div.image-editor"
  imageResizeHandleSelector = "#{imageEditorSelector} div.resize-handle"

  constructor: (@element, @responder) ->
    DOM.on(@element, "click", "img", @didClickImage)

    for event in events
      DOM.on(@element, event, imageResizeHandleSelector, @[event])

  didClickImage: (event, image) =>


  dragstart: (event, element) =>
    event.dataTransfer.effectAllowed = "none"
    event.dataTransfer.setData("text/plain", "resize")

    @dragging =
      editor: editor = element.parentElement
      image: editor.firstChild
