mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
chore(example): Add Haptics page (#2032)
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
import Scanner from './views/Scanner.svelte'
|
||||
import Biometric from './views/Biometric.svelte'
|
||||
import Geolocation from './views/Geolocation.svelte'
|
||||
import Haptics from './views/Haptics.svelte'
|
||||
|
||||
import { onMount, tick } from 'svelte'
|
||||
import { ask } from '@tauri-apps/plugin-dialog'
|
||||
@@ -130,6 +131,11 @@
|
||||
label: 'Geolocation',
|
||||
component: Geolocation,
|
||||
icon: 'i-ph-map-pin'
|
||||
},
|
||||
isMobile && {
|
||||
label: 'Haptics',
|
||||
component: Haptics,
|
||||
icon: 'i-ph-vibrate'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<script>
|
||||
import {
|
||||
vibrate,
|
||||
impactFeedback,
|
||||
notificationFeedback,
|
||||
selectionFeedback
|
||||
} from '@tauri-apps/plugin-haptics'
|
||||
|
||||
export let onMessage
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<button
|
||||
class="btn"
|
||||
on:click={() => vibrate(300).then(onMessage).catch(onMessage)}
|
||||
>vibrate short</button
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
on:click={() => vibrate(1500).then(onMessage).catch(onMessage)}
|
||||
>vibrate long</button
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
on:click={() => impactFeedback('medium').then(onMessage).catch(onMessage)}
|
||||
>impact medium</button
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
on:click={() =>
|
||||
notificationFeedback('warning').then(onMessage).catch(onMessage)}
|
||||
>notification warning</button
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
on:click={() => selectionFeedback().then(onMessage).catch(onMessage)}
|
||||
>selection</button
|
||||
>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<p>
|
||||
Depending on your device settings for haptic feedback some of the buttons may
|
||||
not work.
|
||||
</p>
|
||||
Reference in New Issue
Block a user