Skip to content

Commit

Permalink
possivelmenta acabado detecção de gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed May 1, 2024
1 parent 8940d4a commit 723480a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions AnkiDroid/src/main/assets/scripts/ankidroid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
globalThis.ankidroid = globalThis.ankidroid || {};

globalThis.ankidroid.userAction = function(number) {
globalThis.ankidroid.userAction = function (number) {
try {
let userJs = globalThis[`userJs${number}`];
if (userJs != null) {
Expand All @@ -24,7 +24,6 @@ globalThis.ankidroid.scale = 1;
tapTimer = null,
isSingleTouch = false;


document.ontouchstart = function (event) {
if (event.touches.length > 1) {
isSingleTouch = false;
Expand All @@ -45,15 +44,15 @@ globalThis.ankidroid.scale = 1;
deltaX = Math.abs(endX - startX),
deltaY = Math.abs(endY - startY),
threshold = maxMovement / globalThis.ankidroid.scale;
console.log(threshold + " " + deltaX + " " + deltaY);

if (deltaX > threshold || deltaY > threshold) return;

if (tapTimer != null) {
window.location.href = "tap://double";
event.preventDefault();
clearTimeout(tapTimer);
tapTimer = null;
return
return;
}

tapTimer = setTimeout(() => {
Expand All @@ -68,22 +67,23 @@ globalThis.ankidroid.scale = 1;
row = rowLabels[row];
let target = row + column;

window.location.href = `tap://${target}`
window.location.href = `tap://${target}`;
event.preventDefault();
tapTimer = null;
}, 200);
}
};

function isLink(e) {
let node = e.target;
while (node && node !== document) {
const res = node.nodeName === "A"
|| node.onclick
|| node.nodeName === "BUTTON"
|| node.nodeName === "VIDEO"
|| node.nodeName === "SUMMARY"
|| node.nodeName === "INPUT"
|| node.getAttribute("contentEditable");
const res =
node.nodeName === "A" ||
node.onclick ||
node.nodeName === "BUTTON" ||
node.nodeName === "VIDEO" ||
node.nodeName === "SUMMARY" ||
node.nodeName === "INPUT" ||
node.getAttribute("contentEditable");
if (res) {
return true;
}
Expand All @@ -98,4 +98,4 @@ globalThis.ankidroid.scale = 1;
function isTextSelected() {
return !document.getSelection().isCollapsed;
}
})();
})();

0 comments on commit 723480a

Please sign in to comment.