Merge branch 'develop' into feature/remove-svg-rect
This commit is contained in:
commit
5213e0b8b1
6 changed files with 49 additions and 53 deletions
|
@ -17,6 +17,11 @@
|
||||||
</figure>
|
</figure>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
v-if="!progress"
|
||||||
|
class="modal-close is-large has-background-primary"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
|
<span>Eingabemodus: </span>
|
||||||
<BulmaButton
|
<BulmaButton
|
||||||
|
v-bind="$attrs"
|
||||||
:icon="
|
:icon="
|
||||||
'fa-solid fa-' +
|
'fa-solid fa-' +
|
||||||
(store.is_touch_device ? 'hand-pointer' : 'arrow-pointer')
|
(store.is_touch_device ? 'hand-pointer' : 'arrow-pointer')
|
||||||
"
|
"
|
||||||
text="Eingabemodus"
|
:text="store.is_touch_device ? 'Touch' : 'Desktop'"
|
||||||
@click.left="store.toggle_touch_device"
|
@click.left="store.toggle_touch_device"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
style="cursor: pointer"
|
style="cursor: pointer"
|
||||||
:variant="visible || hovered ? 'primary' : undefined"
|
:variant="visible || hovered ? 'primary' : undefined"
|
||||||
:rectangle="door.position"
|
:rectangle="door.position"
|
||||||
@mouseover="hovered = true"
|
@mouseenter="hovered = true"
|
||||||
@mouseout="hovered = false"
|
@mouseleave="hovered = false"
|
||||||
>
|
>
|
||||||
<div class="has-text-danger">{{ door.day }}</div>
|
<div class="has-text-danger">{{ door.day }}</div>
|
||||||
</SVGRect>
|
</SVGRect>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<foreignObject
|
<foreignObject
|
||||||
ref="foreign_object"
|
ref="foreign_object"
|
||||||
:x="Math.round(parent_aspect_ratio * rectangle.left)"
|
:x="Math.round(store.calendar_aspect_ratio * rectangle.left)"
|
||||||
:y="rectangle.top"
|
:y="rectangle.top"
|
||||||
:width="Math.round(parent_aspect_ratio * rectangle.width)"
|
:width="Math.round(store.calendar_aspect_ratio * rectangle.width)"
|
||||||
:height="rectangle.height"
|
:height="rectangle.height"
|
||||||
:style="`transform: scaleX(${1 / parent_aspect_ratio})`"
|
:style="`transform: scaleX(${1 / store.calendar_aspect_ratio})`"
|
||||||
>
|
>
|
||||||
<!-- v-if="variant !== undefined" -->
|
<!-- v-if="variant !== undefined" -->
|
||||||
<div
|
<div
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Rectangle } from "@/lib/rectangle";
|
import { Rectangle } from "@/lib/rectangle";
|
||||||
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
type BulmaVariant =
|
type BulmaVariant =
|
||||||
|
@ -51,43 +52,7 @@ export default class extends Vue {
|
||||||
public variant?: BulmaVariant;
|
public variant?: BulmaVariant;
|
||||||
public rectangle!: Rectangle;
|
public rectangle!: Rectangle;
|
||||||
|
|
||||||
private refreshKey = 0;
|
public readonly store = advent22Store();
|
||||||
|
|
||||||
declare $refs: {
|
|
||||||
foreign_object: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
private refresh() {
|
|
||||||
window.setTimeout(() => {
|
|
||||||
// don't loop endlessly
|
|
||||||
if (this.refreshKey < 10000) {
|
|
||||||
this.refreshKey++;
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get parent_aspect_ratio(): number {
|
|
||||||
this.refreshKey; // read it just to force recompute on change
|
|
||||||
|
|
||||||
if (
|
|
||||||
!(this.$refs.foreign_object instanceof SVGForeignObjectElement) ||
|
|
||||||
this.$refs.foreign_object.parentElement === null
|
|
||||||
) {
|
|
||||||
this.refresh();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const parent = this.$refs.foreign_object.parentElement;
|
|
||||||
const result = parent.clientWidth / parent.clientHeight;
|
|
||||||
|
|
||||||
// force recompute for suspicious results
|
|
||||||
if (result === 0 || result === Infinity) {
|
|
||||||
this.refresh();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Vector2D } from "@/lib/vector2d";
|
import { Vector2D } from "@/lib/vector2d";
|
||||||
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
function get_event_thous(event: MouseEvent): Vector2D {
|
function get_event_thous(event: MouseEvent): Vector2D {
|
||||||
|
@ -56,6 +57,17 @@ function mouse_event_validator(event: object, point: object): boolean {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
|
public readonly store = advent22Store();
|
||||||
|
|
||||||
|
public mounted(): void {
|
||||||
|
new ResizeObserver(([first, ...rest]) => {
|
||||||
|
if (rest.length > 0)
|
||||||
|
console.warn(`Unexpected ${rest.length} extra entries!`);
|
||||||
|
|
||||||
|
this.store.set_calendar_aspect_ratio(first.contentRect);
|
||||||
|
}).observe(this.$el);
|
||||||
|
}
|
||||||
|
|
||||||
public transform_mouse_event(event: MouseEvent) {
|
public transform_mouse_event(event: MouseEvent) {
|
||||||
const point = get_event_thous(event);
|
const point = get_event_thous(event);
|
||||||
this.$emit(event.type, event, point);
|
this.$emit(event.type, event, point);
|
||||||
|
|
|
@ -3,16 +3,23 @@ import { Advent22 } from "@/plugins/advent22";
|
||||||
import { AxiosBasicCredentials } from "axios";
|
import { AxiosBasicCredentials } from "axios";
|
||||||
import { acceptHMRUpdate, defineStore } from "pinia";
|
import { acceptHMRUpdate, defineStore } from "pinia";
|
||||||
|
|
||||||
const check_touch_device = () => window.matchMedia("(any-hover: none)").matches;
|
declare global {
|
||||||
const empty_creds = () => ["", ""] as Credentials;
|
interface Navigator {
|
||||||
|
readonly msMaxTouchPoints: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const advent22Store = defineStore({
|
export const advent22Store = defineStore({
|
||||||
id: "advent22",
|
id: "advent22",
|
||||||
|
|
||||||
state: () => ({
|
state: () => ({
|
||||||
advent22: {} as Advent22,
|
advent22: {} as Advent22,
|
||||||
api_creds: empty_creds(),
|
api_creds: ["", ""] as Credentials,
|
||||||
is_touch_device: check_touch_device(),
|
is_touch_device:
|
||||||
|
window.matchMedia("(any-hover: none)").matches ||
|
||||||
|
"ontouchstart" in window ||
|
||||||
|
navigator.maxTouchPoints > 0 ||
|
||||||
|
navigator.msMaxTouchPoints > 0,
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
site_config: {
|
site_config: {
|
||||||
title: document.title,
|
title: document.title,
|
||||||
|
@ -20,6 +27,7 @@ export const advent22Store = defineStore({
|
||||||
content: "",
|
content: "",
|
||||||
footer: "",
|
footer: "",
|
||||||
} as SiteConfigModel,
|
} as SiteConfigModel,
|
||||||
|
calendar_aspect_ratio: 1,
|
||||||
user_doors: [] as DoorsSaved,
|
user_doors: [] as DoorsSaved,
|
||||||
next_door_target: null as number | null,
|
next_door_target: null as number | null,
|
||||||
}),
|
}),
|
||||||
|
@ -70,7 +78,7 @@ export const advent22Store = defineStore({
|
||||||
.catch(advent22.alert_user_error);
|
.catch(advent22.alert_user_error);
|
||||||
},
|
},
|
||||||
|
|
||||||
login(creds: Credentials = empty_creds()): Promise<boolean> {
|
login(creds: Credentials): Promise<boolean> {
|
||||||
this.api_creds = creds;
|
this.api_creds = creds;
|
||||||
|
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
|
@ -85,16 +93,20 @@ export const advent22Store = defineStore({
|
||||||
},
|
},
|
||||||
|
|
||||||
logout(): Promise<boolean> {
|
logout(): Promise<boolean> {
|
||||||
return this.login();
|
return this.login(["", ""]);
|
||||||
},
|
|
||||||
|
|
||||||
set_touch_device(state: boolean = check_touch_device()): void {
|
|
||||||
this.is_touch_device = state;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle_touch_device(): void {
|
toggle_touch_device(): void {
|
||||||
this.is_touch_device = !this.is_touch_device;
|
this.is_touch_device = !this.is_touch_device;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set_calendar_aspect_ratio(rect: DOMRectReadOnly): void {
|
||||||
|
const result = rect.width / rect.height;
|
||||||
|
|
||||||
|
// filter suspicious results
|
||||||
|
if (result !== 0 && isFinite(result) && !isNaN(result))
|
||||||
|
this.calendar_aspect_ratio = result;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue