Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix error when attaching touch handlers to nodes

ammarahm-ede8bbf1ec80d5
diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.html
index 74b85ef82..df5bfe6f3 100644
--- a/apps/mobile/html/Web.bundle/site/index.html
+++ b/apps/mobile/html/Web.bundle/site/index.html
@@ -55,17 +55,19 @@
</script>
<script>
- function pressHandler(tag, action) {
+ function pressHandler(tag, action, node) {
let time = 0;
- document.querySelector(tag).ontouchstart = function (event) {
+ let _node = node || document.querySelector(tag);
+
+ _node.ontouchstart = function (event) {
event.preventDefault();
time = Date.now();
}
- document.querySelector(tag).ontouchmove = function (event) {
+ _node.ontouchmove = function (event) {
event.preventDefault();
}
- document.querySelector(tag).ontouchend = function (event) {
+ _node.ontouchend = function (event) {
event.preventDefault();
let diff = Date.now() - time;
if (diff < 300) {
@@ -110,9 +112,9 @@
for (var i = 0; i < classes.length; i++) {
childNode.classList.add(classes[i]);
}
- pressHandler(".tag", function () {
+ pressHandler(null, function () {
reactNativeEventHandler("notetag", event.target.dataset.tag);
- })
+ }, childNode);
parentNode.appendChild(childNode);
})
}