Skip to content

Commit

Permalink
Hook parent drag events
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Aug 24, 2018
1 parent 4e2aa6b commit 0e10f1e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/editor/src/components/block-list/block-draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,35 @@ import { Component } from '@wordpress/element';
import { withDraggable } from '@wordpress/components';

class BlockDraggable extends Component {
render() {
const { clientId, elementId, index, initDragging, layout, rootClientId } = this.props;
constructor( ) {
super( ...arguments );
this.onDragStart = this.onDragStart.bind( this );
this.onDragEnd = this.onDragEnd.bind( this );
}

onDragStart( event ) {
const { clientId, elementId, index, initDragging, onDragStart, layout, rootClientId } = this.props;
const transferData = {
type: 'block',
fromIndex: index,
rootClientId,
clientId,
layout,
};
initDragging( elementId, transferData )( event );
onDragStart( event );
}

onDragEnd( event ) {
this.props.onDragEnd( event );
}

render() {
return (
<div
className={ 'editor-block-list__block-draggable' }
onDragStart={ initDragging( elementId, transferData ) }
onDragStart={ this.onDragStart }
onDragEnd={ this.onDragEnd }
draggable
>
</div>
Expand Down

0 comments on commit 0e10f1e

Please sign in to comment.