-
-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathZoomGestureWrapper.svelte
More file actions
44 lines (40 loc) · 1.12 KB
/
ZoomGestureWrapper.svelte
File metadata and controls
44 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script lang="ts">
import { useZoomGesture } from '../hooks';
import type { Snippet } from 'svelte';
import type { HTMLAttributes } from 'svelte/elements';
type ZoomGestureWrapperProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
documentId: string;
children: Snippet;
class?: string;
/** Enable pinch-to-zoom gesture (default: true) */
enablePinch?: boolean;
/** Enable wheel zoom with ctrl/cmd key (default: true) */
enableWheel?: boolean;
/** Override wheel zoom step; 0.1 = 10% (default: 0.1) */
zoomStep?: number;
};
let {
documentId,
children,
class: propsClass,
enablePinch = true,
enableWheel = true,
zoomStep = 0.1,
...restProps
}: ZoomGestureWrapperProps = $props();
const zoomGesture = useZoomGesture(() => documentId, {
enablePinch: () => enablePinch,
enableWheel: () => enableWheel,
zoomStep: () => zoomStep,
});
</script>
<div
bind:this={zoomGesture.elementRef}
{...restProps}
style:display="inline-block"
style:overflow="visible"
style:box-sizing="border-box"
class={propsClass}
>
{@render children()}
</div>