Skip to content

Commit

Permalink
Add image drag preview example
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Apr 8, 2015
1 parent 30ec27a commit 0ef96a1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
Expand Up @@ -26,7 +26,7 @@ const propTypes = {
dragSourceRef: PropTypes.func.isRequired
};

class Box extends Component {
class BoxWithHandle extends Component {
render() {
const { isDragging, dragSourceRef, dragPreviewRef } = this.props;
const opacity = isDragging ? 0.4 : 1;
Expand All @@ -43,15 +43,15 @@ class Box extends Component {
);
}
}
Box.propTypes = propTypes;
BoxWithHandle.propTypes = propTypes;

const boxSource = {
beginDrag() {
return {};
}
};

export default configureDragDrop(Box, {
export default configureDragDrop(BoxWithHandle, {
configure: (register) =>
register.dragSource(ItemTypes.BOX, boxSource),

Expand Down
57 changes: 57 additions & 0 deletions examples/_customize-handles/BoxWithImage.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions examples/_customize-handles/Container.js
Expand Up @@ -2,15 +2,17 @@

import React, { PropTypes, Component } from 'react';
import { configureDragDropContext, DragDropContext, HTML5Backend } from 'react-dnd';
import Box from './Box';
import BoxWithImage from './BoxWithImage';
import BoxWithHandle from './BoxWithHandle';
import shuffle from 'lodash/collection/shuffle';

class Container extends Component {
render() {
return (
<div>
<div style={{ marginTop: '2rem' }}>
<Box />
<BoxWithHandle />
<BoxWithImage />
</div>
</div>
);
Expand Down

0 comments on commit 0ef96a1

Please sign in to comment.