Mailspring/src/components/draggable-img.cjsx
Ben Gotow a559e3f89f feat(drag-threads): Move threads to folders/labels from thread list
Summary:
Drag threads to the folders / labels in the sidebar
WIP

Drag and drop is styled!

Test Plan: Tests WIP

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1785
2015-07-23 11:10:51 -07:00

25 lines
778 B
CoffeeScript

React = require 'react'
###
Public: Images are supposed to by default show a ghost image when dragging and
dropping. Unfortunately this does not work in Electron. Since we're a
desktop app we don't want all images draggable, but we do want some (like
attachments) to be able to be dragged away with a preview image.
###
class DraggableImg extends React.Component
@displayName: 'DraggableImg'
constructor: (@props) ->
render: =>
<img ref="img" draggable="true" onDragStart={@_onDragStart} {...@props} />
_onDragStart: (event) =>
img = React.findDOMNode(@refs.img)
rect = img.getBoundingClientRect()
y = event.clientY - rect.top
x = event.clientX - rect.left
event.dataTransfer.setDragImage(img, x, y)
return
module.exports = DraggableImg