Spaces:
Runtime error
Runtime error
better drag target
Browse files
frontend/src/app.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ declare global {
|
|
| 17 |
transform: ZoomTransform;
|
| 18 |
x: number;
|
| 19 |
y: number;
|
|
|
|
| 20 |
}
|
| 21 |
}
|
|
|
|
| 17 |
transform: ZoomTransform;
|
| 18 |
x: number;
|
| 19 |
y: number;
|
| 20 |
+
sourceEvent: PointerEvent | MouseEvent | TouchEvent
|
| 21 |
}
|
| 22 |
}
|
frontend/src/lib/Cursor.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import type { ZoomTransform } from 'd3-zoom';
|
| 3 |
-
|
| 4 |
export let transform: ZoomTransform;
|
| 5 |
export let color = '';
|
| 6 |
export let emoji: string;
|
|
@@ -16,18 +16,8 @@
|
|
| 16 |
class="cursor"
|
| 17 |
style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k});`}
|
| 18 |
>
|
| 19 |
-
<
|
| 20 |
-
|
| 21 |
-
width="40"
|
| 22 |
-
viewBox="0 0 15 15"
|
| 23 |
-
fill="currentColor"
|
| 24 |
-
xmlns="http://www.w3.org/2000/svg"
|
| 25 |
-
>
|
| 26 |
-
<path
|
| 27 |
-
d="M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"
|
| 28 |
-
fill="#FFB800"
|
| 29 |
-
/>
|
| 30 |
-
</svg>
|
| 31 |
{#if emoji}
|
| 32 |
<div
|
| 33 |
class="absolute right-0 text-4xl col-start-2 row-start-2"
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import type { ZoomTransform } from 'd3-zoom';
|
| 3 |
+
import Cursor from '$lib/Icons/Cursor.svelte';
|
| 4 |
export let transform: ZoomTransform;
|
| 5 |
export let color = '';
|
| 6 |
export let emoji: string;
|
|
|
|
| 16 |
class="cursor"
|
| 17 |
style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k});`}
|
| 18 |
>
|
| 19 |
+
<Cursor classList={'block z-0 col-span-2 row-span-2'} />
|
| 20 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
{#if emoji}
|
| 22 |
<div
|
| 23 |
class="absolute right-0 text-4xl col-start-2 row-start-2"
|
frontend/src/lib/Icons/Cursor.svelte
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let classList = '';
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<svg
|
| 6 |
+
class={classList}
|
| 7 |
+
width="40"
|
| 8 |
+
viewBox="0 0 15 15"
|
| 9 |
+
fill="currentColor"
|
| 10 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 11 |
+
>
|
| 12 |
+
<path
|
| 13 |
+
d="M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"
|
| 14 |
+
fill="#FFB800"
|
| 15 |
+
/>
|
| 16 |
+
</svg>
|
frontend/src/lib/Icons/Move.svelte
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let classList = '';
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<svg
|
| 6 |
+
class={classList}
|
| 7 |
+
width="11"
|
| 8 |
+
height="11"
|
| 9 |
+
viewBox="0 0 11 11"
|
| 10 |
+
fill="none"
|
| 11 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 12 |
+
>
|
| 13 |
+
<path
|
| 14 |
+
d="M2.4 4.26667L1 5.66667L2.4 7.06667M4.26667 2.4L5.66667 1L7.06667 2.4M7.06667 8.93333L5.66667 10.3333L4.26667 8.93333M8.93333 4.26667L10.3333 5.66667L8.93333 7.06667M1 5.66667H10.3333M5.66667 1V10.3333"
|
| 15 |
+
stroke="#397DFF"
|
| 16 |
+
stroke-width="0.933333"
|
| 17 |
+
stroke-linecap="round"
|
| 18 |
+
stroke-linejoin="round"
|
| 19 |
+
/>
|
| 20 |
+
</svg>
|
frontend/src/lib/PaintFrame.svelte
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
<script lang="ts">
|
| 2 |
import Frame from '$lib/Frame.svelte';
|
|
|
|
| 3 |
import { drag } from 'd3-drag';
|
| 4 |
import { select } from 'd3-selection';
|
| 5 |
import { round } from '$lib/utils';
|
|
@@ -25,14 +26,24 @@
|
|
| 25 |
$: prompt = $myPresence?.currentPrompt;
|
| 26 |
$: isLoading = $myPresence?.isLoading || false;
|
| 27 |
|
|
|
|
|
|
|
| 28 |
onMount(() => {
|
| 29 |
-
function dragstarted() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
isDragging = true;
|
| 31 |
}
|
| 32 |
|
| 33 |
function dragged(event: Event) {
|
| 34 |
-
const x = round(transform.invertX(event.x
|
| 35 |
-
const y = round(transform.invertY(event.y
|
| 36 |
position = {
|
| 37 |
x,
|
| 38 |
y
|
|
@@ -48,8 +59,8 @@
|
|
| 48 |
function dragended(event: Event) {
|
| 49 |
isDragging = false;
|
| 50 |
|
| 51 |
-
const x = round(transform.invertX(event.x
|
| 52 |
-
const y = round(transform.invertY(event.y
|
| 53 |
|
| 54 |
myPresence.update({
|
| 55 |
frame: {
|
|
|
|
| 1 |
<script lang="ts">
|
| 2 |
import Frame from '$lib/Frame.svelte';
|
| 3 |
+
import Move from '$lib/Icons/Move.svelte';
|
| 4 |
import { drag } from 'd3-drag';
|
| 5 |
import { select } from 'd3-selection';
|
| 6 |
import { round } from '$lib/utils';
|
|
|
|
| 26 |
$: prompt = $myPresence?.currentPrompt;
|
| 27 |
$: isLoading = $myPresence?.isLoading || false;
|
| 28 |
|
| 29 |
+
let offsetX = 0;
|
| 30 |
+
let offsetY = 0;
|
| 31 |
onMount(() => {
|
| 32 |
+
function dragstarted(event: Event) {
|
| 33 |
+
const rect = (event.sourceEvent.target as HTMLElement).getBoundingClientRect();
|
| 34 |
+
if (event.sourceEvent instanceof TouchEvent) {
|
| 35 |
+
offsetX = event.sourceEvent.targetTouches[0].pageX - rect.left;
|
| 36 |
+
offsetY = event.sourceEvent.targetTouches[0].pageY - rect.top;
|
| 37 |
+
} else {
|
| 38 |
+
offsetX = event.sourceEvent.pageX - rect.left;
|
| 39 |
+
offsetY = event.sourceEvent.pageY - rect.top;
|
| 40 |
+
}
|
| 41 |
isDragging = true;
|
| 42 |
}
|
| 43 |
|
| 44 |
function dragged(event: Event) {
|
| 45 |
+
const x = round(transform.invertX(event.x - offsetX));
|
| 46 |
+
const y = round(transform.invertY(event.y - offsetY));
|
| 47 |
position = {
|
| 48 |
x,
|
| 49 |
y
|
|
|
|
| 59 |
function dragended(event: Event) {
|
| 60 |
isDragging = false;
|
| 61 |
|
| 62 |
+
const x = round(transform.invertX(event.x - offsetX));
|
| 63 |
+
const y = round(transform.invertY(event.y - offsetY));
|
| 64 |
|
| 65 |
myPresence.update({
|
| 66 |
frame: {
|