We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1156fe8 commit 2bbb5beCopy full SHA for 2bbb5be
src/eventHandlers/mousedown.ts
@@ -12,12 +12,23 @@ export const selectNames = [
12
'user-select'
13
];
14
15
+function findParent(el: Element, sel: string): Element {
16
+ let result = el;
17
+ while (!result.matches(sel)) {
18
+ if (result.matches('html')) {
19
+ throw new Error('no parent element found');
20
+ }
21
+ result = result.parentElement;
22
23
+ return result;
24
+}
25
+
26
export function mousedownHandler(
27
node: VNode,
28
ev: MouseEvent,
29
opts: SortableOptions
30
): [VNode, undefined] {
- const item: Element = ev.currentTarget as Element;
31
+ const item: Element = findParent(ev.target as Element, opts.itemSelector);
32
const indexClicked = Array.prototype.slice
33
.call(item.parentElement.children)
34
.indexOf(item);
0 commit comments