2021-08-04 22:58:24 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2021-11-24 22:17:41 +01:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2022-02-04 09:36:34 +01:00
|
|
|
|
2021-11-24 22:17:41 +01:00
|
|
|
import { pageTheme } from "../sveltelib/theme";
|
2021-08-04 22:58:24 +02:00
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
export let offsetX = 0;
|
|
|
|
export let offsetY = 0;
|
|
|
|
|
|
|
|
export let active = false;
|
|
|
|
export let activeSize = 5;
|
2021-08-04 22:58:24 +02:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
const onPointerdown =
|
|
|
|
(north: boolean, west: boolean) =>
|
|
|
|
(event: PointerEvent): void => {
|
|
|
|
dispatch("pointerclick", { north, west, originalEvent: event });
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
2022-09-05 09:20:00 +02:00
|
|
|
class="handle-control"
|
2021-08-06 00:16:15 +02:00
|
|
|
style="--offsetX: {offsetX}px; --offsetY: {offsetY}px; --activeSize: {activeSize}px;"
|
|
|
|
>
|
|
|
|
<div
|
2021-11-24 22:17:41 +01:00
|
|
|
class:nightMode={$pageTheme.isDark}
|
|
|
|
class="bordered"
|
|
|
|
on:mousedown|preventDefault
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
class:nightMode={$pageTheme.isDark}
|
2021-08-06 00:16:15 +02:00
|
|
|
class:active
|
2021-08-31 22:52:23 +02:00
|
|
|
class="control nw"
|
2021-08-06 00:16:15 +02:00
|
|
|
on:mousedown|preventDefault
|
|
|
|
on:pointerdown={onPointerdown(true, true)}
|
|
|
|
on:pointermove
|
|
|
|
/>
|
|
|
|
<div
|
2021-11-24 22:17:41 +01:00
|
|
|
class:nightMode={$pageTheme.isDark}
|
2021-08-06 00:16:15 +02:00
|
|
|
class:active
|
2021-08-31 22:52:23 +02:00
|
|
|
class="control ne"
|
2021-08-06 00:16:15 +02:00
|
|
|
on:mousedown|preventDefault
|
|
|
|
on:pointerdown={onPointerdown(true, false)}
|
|
|
|
on:pointermove
|
|
|
|
/>
|
|
|
|
<div
|
2021-11-24 22:17:41 +01:00
|
|
|
class:nightMode={$pageTheme.isDark}
|
2021-08-06 00:16:15 +02:00
|
|
|
class:active
|
2021-08-31 22:52:23 +02:00
|
|
|
class="control sw"
|
2021-08-06 00:16:15 +02:00
|
|
|
on:mousedown|preventDefault
|
|
|
|
on:pointerdown={onPointerdown(false, true)}
|
|
|
|
on:pointermove
|
|
|
|
/>
|
|
|
|
<div
|
2021-11-24 22:17:41 +01:00
|
|
|
class:nightMode={$pageTheme.isDark}
|
2021-08-06 00:16:15 +02:00
|
|
|
class:active
|
2021-08-31 22:52:23 +02:00
|
|
|
class="control se"
|
2021-08-06 00:16:15 +02:00
|
|
|
on:mousedown|preventDefault
|
|
|
|
on:pointerdown={onPointerdown(false, false)}
|
|
|
|
on:pointermove
|
|
|
|
/>
|
|
|
|
</div>
|
2021-08-04 22:58:24 +02:00
|
|
|
|
|
|
|
<style lang="scss">
|
2022-09-05 09:20:00 +02:00
|
|
|
.handle-control {
|
2021-08-06 00:16:15 +02:00
|
|
|
display: contents;
|
|
|
|
}
|
|
|
|
|
2021-08-31 22:52:23 +02:00
|
|
|
.bordered {
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
top: calc(0px - var(--activeSize) + var(--offsetY));
|
|
|
|
bottom: calc(0px - var(--activeSize) + var(--offsetY));
|
|
|
|
left: calc(0px - var(--activeSize) + var(--offsetX));
|
|
|
|
right: calc(0px - var(--activeSize) + var(--offsetX));
|
|
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
border: 2px dashed black;
|
|
|
|
|
|
|
|
&.nightMode {
|
|
|
|
border-color: white;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.control {
|
2021-08-04 22:58:24 +02:00
|
|
|
position: absolute;
|
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
width: var(--activeSize);
|
|
|
|
height: var(--activeSize);
|
2021-08-04 22:58:24 +02:00
|
|
|
|
|
|
|
&.active {
|
|
|
|
background-color: black;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.nightMode {
|
|
|
|
border-color: white;
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
background-color: white;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.nw {
|
|
|
|
top: calc(0px - var(--offsetY));
|
|
|
|
left: calc(0px - var(--offsetX));
|
2021-08-04 22:58:24 +02:00
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.active {
|
|
|
|
cursor: nw-resize;
|
|
|
|
}
|
2021-08-04 22:58:24 +02:00
|
|
|
}
|
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.ne {
|
|
|
|
top: calc(0px - var(--offsetY));
|
|
|
|
right: calc(0px - var(--offsetX));
|
2021-08-04 22:58:24 +02:00
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.active {
|
|
|
|
cursor: ne-resize;
|
|
|
|
}
|
2021-08-04 22:58:24 +02:00
|
|
|
}
|
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.sw {
|
|
|
|
bottom: calc(0px - var(--offsetY));
|
|
|
|
left: calc(0px - var(--offsetX));
|
2021-08-04 22:58:24 +02:00
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.active {
|
|
|
|
cursor: sw-resize;
|
|
|
|
}
|
2021-08-04 22:58:24 +02:00
|
|
|
}
|
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.se {
|
|
|
|
bottom: calc(0px - var(--offsetY));
|
|
|
|
right: calc(0px - var(--offsetX));
|
2021-08-04 22:58:24 +02:00
|
|
|
|
2021-08-06 00:16:15 +02:00
|
|
|
&.active {
|
|
|
|
cursor: se-resize;
|
|
|
|
}
|
2021-08-04 22:58:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|