Skip to content

Commit

Permalink
Fix example for canceling events with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusRich authored Jun 26, 2024
1 parent 863e3e1 commit f94bc21
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Draggable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ import {Draggable} from '@shopify/draggable';

const draggable = new Draggable(document.querySelectorAll('ul'), {
draggable: 'li',
classes: {
'draggable:over': ['draggable--over', 'bg-red-200', 'bg-opacity-25'],
},
});

draggable.on('drag:start', () => {
document.addEventListener('keyup', (evt) => {
if (evt.key === 'Escape') {
draggable.cancel();
}
});
});
```

0 comments on commit f94bc21

Please sign in to comment.