mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
a559e3f89f
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
25 lines
778 B
CoffeeScript
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
|