Mobile improvements
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user