-
Notifications
You must be signed in to change notification settings - Fork 5
fix: svelte gesture dep usage #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,7 @@ | |
| import { CupertinoPane } from 'cupertino-pane'; | ||
| import type { HTMLAttributes } from 'svelte/elements'; | ||
| import { cn } from '$lib/utils'; | ||
| import { swipe } from 'svelte-gestures'; | ||
| import type { SwipeCustomEvent } from 'svelte-gestures'; | ||
| import { useSwipe, type GestureCustomEvent, type SwipeCustomEvent } from 'svelte-gestures'; | ||
|
|
||
| interface IDrawerProps extends HTMLAttributes<HTMLDivElement> { | ||
| drawer?: CupertinoPane; | ||
|
|
@@ -19,11 +18,9 @@ | |
| if (drawer) drawer.destroy({ animate: true }); | ||
| } | ||
|
|
||
| const handleDrawerSwipe = (event: SwipeCustomEvent) => { | ||
| if (event.detail.direction === ('down' as string)) { | ||
| drawer?.destroy({ animate: true }); | ||
| } | ||
| }; | ||
| function downSwipeHandler() { | ||
| drawer?.destroy({ animate: true }); | ||
| } | ||
|
|
||
| onMount(() => { | ||
| if (!drawerElement) return; | ||
|
|
@@ -48,11 +45,16 @@ | |
| <div | ||
| bind:this={drawerElement} | ||
| {...restProps} | ||
| use:swipe={() => ({ | ||
| timeframe: 300, | ||
| minSwipeDistance: 60 | ||
| })} | ||
| onswipe={handleDrawerSwipe} | ||
| {...useSwipe( | ||
| () => {}, | ||
| () => ({ | ||
| timeframe: 300, | ||
| minSwipeDistance: 60 | ||
| }), | ||
| { | ||
| onswipedown: downSwipeHandler | ||
| } | ||
| )} | ||
|
Comment on lines
+48
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the useSwipe API usage pattern. The Please search the web to verify the correct useSwipe API signature: 🌐 Web query: 💡 Result: Summary — useSwipe (svelte-gestures)
Minimal example <script lang="ts"> import { useSwipe, type SwipeCustomEvent } from 'svelte-gestures'; let dir: string | null = null; function handler(e: SwipeCustomEvent) { dir = e.detail.direction; // e.detail.pointerType, e.detail.target available } </script>swipe direction: {dir}
References
[1] svelte-gestures README / docs (usage example). Remove unsupported third argument from useSwipe 🤖 Prompt for AI Agents |
||
| class={cn(restProps.class)} | ||
| > | ||
| <div class="h-[100%] overflow-y-scroll"> | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused type imports.
GestureCustomEventandSwipeCustomEventare imported but not referenced anywhere in the code.Apply this diff to remove the unused imports:
📝 Committable suggestion
🤖 Prompt for AI Agents