Skip to content

Commit f94bc21

Browse files
authored
Fix example for canceling events with keyboard
1 parent 863e3e1 commit f94bc21

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Draggable/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,13 @@ import {Draggable} from '@shopify/draggable';
229229

230230
const draggable = new Draggable(document.querySelectorAll('ul'), {
231231
draggable: 'li',
232-
classes: {
233-
'draggable:over': ['draggable--over', 'bg-red-200', 'bg-opacity-25'],
234-
},
232+
});
233+
234+
draggable.on('drag:start', () => {
235+
document.addEventListener('keyup', (evt) => {
236+
if (evt.key === 'Escape') {
237+
draggable.cancel();
238+
}
239+
});
235240
});
236241
```

0 commit comments

Comments
 (0)