Mobile improvements
This commit is contained in:
@@ -190,10 +190,12 @@
|
|||||||
|
|
||||||
let startX = 0;
|
let startX = 0;
|
||||||
let startY = 0;
|
let startY = 0;
|
||||||
|
let touchStart: Date;
|
||||||
|
|
||||||
function handleTouchStart(event: TouchEvent) {
|
function handleTouchStart(event: TouchEvent) {
|
||||||
if ($settings.mobile) {
|
if ($settings.mobile) {
|
||||||
const { clientX, clientY } = event.touches[0];
|
const { clientX, clientY } = event.touches[0];
|
||||||
|
touchStart = new Date();
|
||||||
|
|
||||||
startX = clientX;
|
startX = clientX;
|
||||||
startY = clientY;
|
startY = clientY;
|
||||||
@@ -211,7 +213,10 @@
|
|||||||
|
|
||||||
const isSwipe = distanceY < 200 && distanceY > 200 * -1;
|
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);
|
const swipeThreshold = Math.abs(($settings.swipeThreshold / 100) * window.innerWidth);
|
||||||
|
|
||||||
if (distanceX > swipeThreshold) {
|
if (distanceX > swipeThreshold) {
|
||||||
|
|||||||
@@ -52,6 +52,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onContextMenu(event: Event, lines: string[]) {
|
||||||
|
if ($settings.ankiConnectSettings.enabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
onUpdateCard(lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each textBoxes as { fontSize, height, left, lines, top, width, writingMode }, index (`text-box-${index}`)}
|
{#each textBoxes as { fontSize, height, left, lines, top, width, writingMode }, index (`text-box-${index}`)}
|
||||||
@@ -67,6 +74,7 @@
|
|||||||
style:border
|
style:border
|
||||||
style:writing-mode={writingMode}
|
style:writing-mode={writingMode}
|
||||||
role="none"
|
role="none"
|
||||||
|
on:contextmenu={(e) => onContextMenu(e, lines)}
|
||||||
on:dblclick={() => onUpdateCard(lines)}
|
on:dblclick={() => onUpdateCard(lines)}
|
||||||
{contenteditable}
|
{contenteditable}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user