Send tap event if swipe is not detected

This commit is contained in:
2021-11-23 12:00:54 +01:00
parent ded276b8a0
commit 43708399e4
2 changed files with 7 additions and 1 deletions

3
src/global.d.ts vendored
View File

@@ -6,6 +6,7 @@
// Swipe
declare namespace svelte.JSX {
interface HTMLAttributes<T> {
onswipe?: (event: CustomEvent<string> & { target: EventTarget & T }) => any
onswipe?: (event: CustomEvent<string> & { target: EventTarget & T }) => any,
ontap?: (event: CustomEvent<boolean> & { target: EventTarget & T }) => any,
}
}

View File

@@ -64,6 +64,11 @@ export const swipe = (
node.dispatchEvent(
new CustomEvent('swipe', { detail: direction })
)
} else {
// Dispatch tap event
node.dispatchEvent(
new CustomEvent('tap', { detail: true })
)
}
}
node.addEventListener('pointerup', onUp, false)