Spaces:
Runtime error
Runtime error
close on click
Browse files
.github/workflows/sync.yml
CHANGED
|
@@ -17,4 +17,4 @@ jobs:
|
|
| 17 |
- name: Push to hub
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
-
run: git push https://radames:$HF_TOKEN@huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer main --force
|
|
|
|
| 17 |
- name: Push to hub
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
run: git push https://radames:$HF_TOKEN@huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer origin main --force
|
frontend/src/lib/PaintCanvas.svelte
CHANGED
|
@@ -39,7 +39,11 @@
|
|
| 39 |
|
| 40 |
onMount(() => {
|
| 41 |
const padding = 200;
|
| 42 |
-
const scale =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
const zoomHandler = zoom()
|
| 44 |
.scaleExtent([1 / scale / 2, 3])
|
| 45 |
.translateExtent([
|
|
@@ -58,7 +62,11 @@
|
|
| 58 |
|
| 59 |
canvasCtx = canvasEl.getContext('2d') as CanvasRenderingContext2D;
|
| 60 |
function zoomReset() {
|
| 61 |
-
const scale =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
selection.call(zoomHandler.transform as any, zoomIdentity);
|
| 63 |
selection.call(zoomHandler.scaleTo as any, 1 / scale);
|
| 64 |
}
|
|
|
|
| 39 |
|
| 40 |
onMount(() => {
|
| 41 |
const padding = 200;
|
| 42 |
+
const scale =
|
| 43 |
+
(width + padding * 2) /
|
| 44 |
+
(containerEl.clientHeight > containerEl.clientWidth
|
| 45 |
+
? containerEl.clientWidth
|
| 46 |
+
: containerEl.clientHeight);
|
| 47 |
const zoomHandler = zoom()
|
| 48 |
.scaleExtent([1 / scale / 2, 3])
|
| 49 |
.translateExtent([
|
|
|
|
| 62 |
|
| 63 |
canvasCtx = canvasEl.getContext('2d') as CanvasRenderingContext2D;
|
| 64 |
function zoomReset() {
|
| 65 |
+
const scale =
|
| 66 |
+
(width + padding * 2) /
|
| 67 |
+
(containerEl.clientHeight > containerEl.clientWidth
|
| 68 |
+
? containerEl.clientWidth
|
| 69 |
+
: containerEl.clientHeight);
|
| 70 |
selection.call(zoomHandler.transform as any, zoomIdentity);
|
| 71 |
selection.call(zoomHandler.scaleTo as any, 1 / scale);
|
| 72 |
}
|
frontend/src/lib/PaintFrame.svelte
CHANGED
|
@@ -57,7 +57,6 @@
|
|
| 57 |
}
|
| 58 |
});
|
| 59 |
}
|
| 60 |
-
// Update cursor presence to current pointer location
|
| 61 |
function handlePointerMove(event: PointerEvent) {
|
| 62 |
event.preventDefault();
|
| 63 |
const x = round(transform.invertX(event.clientX));
|
|
@@ -70,15 +69,16 @@
|
|
| 70 |
}
|
| 71 |
});
|
| 72 |
}
|
| 73 |
-
|
| 74 |
-
// When the pointer leaves the page, set cursor presence to null
|
| 75 |
function handlePointerLeave() {
|
| 76 |
myPresence.update({
|
| 77 |
cursor: null
|
| 78 |
});
|
| 79 |
}
|
| 80 |
const dragHandler = drag().on('start', dragstarted).on('drag', dragged).on('end', dragended);
|
| 81 |
-
select(frameElement)
|
|
|
|
|
|
|
|
|
|
| 82 |
});
|
| 83 |
</script>
|
| 84 |
|
|
|
|
| 57 |
}
|
| 58 |
});
|
| 59 |
}
|
|
|
|
| 60 |
function handlePointerMove(event: PointerEvent) {
|
| 61 |
event.preventDefault();
|
| 62 |
const x = round(transform.invertX(event.clientX));
|
|
|
|
| 69 |
}
|
| 70 |
});
|
| 71 |
}
|
|
|
|
|
|
|
| 72 |
function handlePointerLeave() {
|
| 73 |
myPresence.update({
|
| 74 |
cursor: null
|
| 75 |
});
|
| 76 |
}
|
| 77 |
const dragHandler = drag().on('start', dragstarted).on('drag', dragged).on('end', dragended);
|
| 78 |
+
select(frameElement)
|
| 79 |
+
.call(dragHandler as any)
|
| 80 |
+
.on('pointermove', handlePointerMove)
|
| 81 |
+
.on('pointerleave', handlePointerLeave);
|
| 82 |
});
|
| 83 |
</script>
|
| 84 |
|
frontend/src/lib/PromptModal.svelte
CHANGED
|
@@ -9,11 +9,7 @@
|
|
| 9 |
|
| 10 |
const onKeyup = (e: KeyboardEvent) => {
|
| 11 |
if (e.key === 'Escape') {
|
| 12 |
-
|
| 13 |
-
currentPrompt: '',
|
| 14 |
-
isPrompting: false
|
| 15 |
-
});
|
| 16 |
-
dispatch('close');
|
| 17 |
}
|
| 18 |
};
|
| 19 |
onMount(() => {
|
|
@@ -46,12 +42,19 @@
|
|
| 46 |
const target = event.target as HTMLInputElement;
|
| 47 |
debouce(target.value);
|
| 48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
</script>
|
| 50 |
|
| 51 |
<form
|
| 52 |
class="fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 flex items-center justify-center bg-black bg-opacity-80 px-3"
|
| 53 |
on:submit|preventDefault={onPrompt}
|
| 54 |
-
on:click={
|
| 55 |
>
|
| 56 |
<input
|
| 57 |
bind:this={inputEl}
|
|
|
|
| 9 |
|
| 10 |
const onKeyup = (e: KeyboardEvent) => {
|
| 11 |
if (e.key === 'Escape') {
|
| 12 |
+
cancel();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
};
|
| 15 |
onMount(() => {
|
|
|
|
| 42 |
const target = event.target as HTMLInputElement;
|
| 43 |
debouce(target.value);
|
| 44 |
}
|
| 45 |
+
function cancel() {
|
| 46 |
+
myPresence.update({
|
| 47 |
+
currentPrompt: '',
|
| 48 |
+
isPrompting: false
|
| 49 |
+
});
|
| 50 |
+
dispatch('close');
|
| 51 |
+
}
|
| 52 |
</script>
|
| 53 |
|
| 54 |
<form
|
| 55 |
class="fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 flex items-center justify-center bg-black bg-opacity-80 px-3"
|
| 56 |
on:submit|preventDefault={onPrompt}
|
| 57 |
+
on:click={cancel}
|
| 58 |
>
|
| 59 |
<input
|
| 60 |
bind:this={inputEl}
|