Mobile improvements

This commit is contained in:
ZXY101
2023-10-02 14:05:00 +02:00
parent 310febe53c
commit 23c446d7be
2 changed files with 14 additions and 1 deletions

View File

@@ -190,10 +190,12 @@
let startX = 0;
let startY = 0;
let touchStart: Date;
function handleTouchStart(event: TouchEvent) {
if ($settings.mobile) {
const { clientX, clientY } = event.touches[0];
touchStart = new Date();
startX = clientX;
startY = clientY;
@@ -211,7 +213,10 @@
const isSwipe = distanceY < 200 && distanceY > 200 * -1;
if (isSwipe) {
const end = new Date();
const touchDuration = end.getTime() - touchStart?.getTime();
if (isSwipe && touchDuration < 500) {
const swipeThreshold = Math.abs(($settings.swipeThreshold / 100) * window.innerWidth);
if (distanceX > swipeThreshold) {

View File

@@ -52,6 +52,13 @@
}
}
}
function onContextMenu(event: Event, lines: string[]) {
if ($settings.ankiConnectSettings.enabled) {
event.preventDefault();
onUpdateCard(lines);
}
}
</script>
{#each textBoxes as { fontSize, height, left, lines, top, width, writingMode }, index (`text-box-${index}`)}
@@ -67,6 +74,7 @@
style:border
style:writing-mode={writingMode}
role="none"
on:contextmenu={(e) => onContextMenu(e, lines)}
on:dblclick={() => onUpdateCard(lines)}
{contenteditable}
>