Skip to content

Commit b2b5db7

Browse files
adding svelte-gestures and implementing log press for action button (first first sub-action, or null)
1 parent 283bfde commit b2b5db7

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"vite": "^3.0.7"
3434
},
3535
"dependencies": {
36-
"i18next": "^21.9.1"
36+
"i18next": "^21.9.1",
37+
"svelte-gestures": "^1.4.1"
3738
}
3839
}

src/components/util/Action.svelte

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script>
2-
import Icon from './Icon.svelte';
32
import { onDestroy } from 'svelte';
3+
import Icon from './Icon.svelte';
44
import { createEventDispatcher } from 'svelte';
55
import { fly } from 'svelte/transition';
66
import * as shortcuts from '@/util/shortcuts';
77
import { shortcut_context as page_to_context } from '@/models/pages';
8+
import { press } from 'svelte-gestures';
89
910
export let actions = [];
1011
export let page_id = null;
@@ -34,6 +35,10 @@
3435
dispatch('action', {action});
3536
}
3637
38+
function default_action(e) {
39+
process_action(e, actions ? actions[0].id : null);
40+
}
41+
3742
if(page_id && !shortcut_context) {
3843
shortcut_context = page_to_context(page_id);
3944
}
@@ -64,7 +69,12 @@
6469
</script>
6570

6671
<div class="absolute bottom-2.5 right-2.5 p-2.5 flex flex-col-reverse">
67-
<a class="flex w-16 h-16 justify-center items-center {drop_shadow_class} rounded-full bg-primary transition-[drop-shadow,filter]" on:click={toggle_actions} href="#action" title="{title}">
72+
<a on:click={toggle_actions}
73+
use:press={{ timeframe: 750, triggerBeforeFinished: true }}
74+
on:press={default_action}
75+
class="flex w-16 h-16 justify-center items-center {drop_shadow_class} rounded-full bg-primary transition-[drop-shadow,filter]"
76+
href="#action"
77+
title="{title}">
6878
<Icon
6979
class="inline-block text-white text-2xl w-8 h-8 text-center align-top transition-transform {extra_classes} {open ? open_class : ''}"
7080
name={icon} />

0 commit comments

Comments
 (0)