Spaces:
Runtime error
Runtime error
dragging cursor
Browse files
frontend/src/lib/Frame.svelte
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
export let position = { x: 0, y: 0 };
|
9 |
export let prompt = '';
|
10 |
export let interactive = false;
|
11 |
-
|
12 |
$: coord = {
|
13 |
x: transform.applyX(position.x),
|
14 |
y: transform.applyY(position.y)
|
@@ -16,7 +16,9 @@
|
|
16 |
</script>
|
17 |
|
18 |
<div
|
19 |
-
class="frame z-0 flex relative
|
|
|
|
|
20 |
style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k});
|
21 |
background-image: linear-gradient(${color}, rgba(255,255,255,0));
|
22 |
color: ${color};
|
@@ -26,7 +28,7 @@
|
|
26 |
<LoadingIcon />
|
27 |
<h2 class="text-lg">Click to paint</h2>
|
28 |
|
29 |
-
<div class="absolute bottom-0 font-bold">{prompt}
|
30 |
</div>
|
31 |
|
32 |
<style lang="postcss" scoped>
|
|
|
8 |
export let position = { x: 0, y: 0 };
|
9 |
export let prompt = '';
|
10 |
export let interactive = false;
|
11 |
+
export let isDragging = false;
|
12 |
$: coord = {
|
13 |
x: transform.applyX(position.x),
|
14 |
y: transform.applyY(position.y)
|
|
|
16 |
</script>
|
17 |
|
18 |
<div
|
19 |
+
class="frame z-0 flex relative
|
20 |
+
{!interactive ? 'pointer-events-none touch-none' : ''}
|
21 |
+
{isDragging ? 'cursor-grabbing' : 'cursor-grab'}"
|
22 |
style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k});
|
23 |
background-image: linear-gradient(${color}, rgba(255,255,255,0));
|
24 |
color: ${color};
|
|
|
28 |
<LoadingIcon />
|
29 |
<h2 class="text-lg">Click to paint</h2>
|
30 |
|
31 |
+
<div class="absolute bottom-0 font-bold">{prompt}</div>
|
32 |
</div>
|
33 |
|
34 |
<style lang="postcss" scoped>
|
frontend/src/lib/PaintFrame.svelte
CHANGED
@@ -23,12 +23,12 @@
|
|
23 |
};
|
24 |
|
25 |
let frameElement: HTMLDivElement;
|
26 |
-
|
27 |
$: prompt = $myPresence?.currentPrompt;
|
28 |
|
29 |
onMount(() => {
|
30 |
function dragstarted(event: Event) {
|
31 |
-
|
32 |
}
|
33 |
|
34 |
function dragged(event: Event) {
|
@@ -41,6 +41,8 @@
|
|
41 |
}
|
42 |
|
43 |
function dragended(event: Event) {
|
|
|
|
|
44 |
const x = round(transform.invertX(event.x) - 512 / 2);
|
45 |
const y = round(transform.invertY(event.y) - 512 / 2);
|
46 |
|
@@ -57,5 +59,5 @@
|
|
57 |
</script>
|
58 |
|
59 |
<div bind:this={frameElement}>
|
60 |
-
<Frame {color} {position} {prompt} {transform} {interactive} />
|
61 |
</div>
|
|
|
23 |
};
|
24 |
|
25 |
let frameElement: HTMLDivElement;
|
26 |
+
let isDragging = false;
|
27 |
$: prompt = $myPresence?.currentPrompt;
|
28 |
|
29 |
onMount(() => {
|
30 |
function dragstarted(event: Event) {
|
31 |
+
isDragging = true;
|
32 |
}
|
33 |
|
34 |
function dragged(event: Event) {
|
|
|
41 |
}
|
42 |
|
43 |
function dragended(event: Event) {
|
44 |
+
isDragging = false;
|
45 |
+
|
46 |
const x = round(transform.invertX(event.x) - 512 / 2);
|
47 |
const y = round(transform.invertY(event.y) - 512 / 2);
|
48 |
|
|
|
59 |
</script>
|
60 |
|
61 |
<div bind:this={frameElement}>
|
62 |
+
<Frame {color} {position} {prompt} {transform} {isDragging} {interactive} />
|
63 |
</div>
|