Skip to content

Conversation

@SamyPesse
Copy link
Contributor

@SamyPesse SamyPesse commented Sep 21, 2017

This PR adds a prop onSortOver. The goal of this prop is for the parent component to be notified when the user is dragging over another item before it drops it.

It follows the convention of the other props: named as onSortX with same named arguments.

Example:

Let's say we want to show an alert message at the bottom of the page if we are hovering a specific item:

onSortOver = ({ newIndex, oldIndex }) => {
  const { items } = this.state;
  const item = newIndex != null ? items[newIndex] : null;

  this.setState({
    showAlert: item && item.someProperty
  });
});

render() {
   return (
       <div>
           <SortableList
               items={this.state.items}
               onSortEnd={this.onSortEnd}
               onSortOver={this.onSortOver}
           />
           {this.state.showAlert && <div>Some message !</div>}
       </div>
   );
}

Copy link
Owner

@clauderic clauderic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks for contributing 🙏

Sorry for the late review 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants