Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions static/scripts/touch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var onlongtouch;
var timer;
var touchduration = 1500; //length of time we want the user to touch before we do something
var lastTouchEvent = null;


function touchstart(e) {
e.preventDefault();
lastTouchEvent = e;
if (!timer) {
timer = setTimeout(function() {
onlongtouch(lastTouchEvent);
timer = null;
lastTouchEvent = null;
}, touchduration);
}
}

function touchend(e) {
//stops short touches from firing the event
if (timer) {
clearTimeout(timer);
timer = null;
lastTouchEvent = null;
}
}

onlongtouch = function(e) {
console.log("long touch detected", e.touches[0].clientX, e.touches[0].clientY);
event = {
clientX: e.touches[0].clientX,
clientY: e.touches[0].clientY
}
var pos = cursorPosition();
x = pos.x;
x = x.toFixed(4);
pos.x = x;

y = pos.y;
y = y.toFixed(4);
pos.y = y;
requestPage("screenAction",pos)
};

document.addEventListener("DOMContentLoaded", function(event) {
$("#workarea")[0].addEventListener("touchstart", touchstart, false);
$("#workarea")[0].addEventListener("touchend", touchend, false);
});
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script src="{{ url_for('static',filename='scripts/bootstrap.bundle.min.js', version='11102018a') }}" crossorigin="anonymous"></script>
<script src="{{ url_for('static',filename='scripts/baseSocket.js', version='11102018t') }}" crossorigin="anonymous"></script>
<script src="{{ url_for('static',filename='scripts/base.js', version='11102018t') }}" crossorigin="anonymous"></script>
<script src="{{ url_for('static',filename='scripts/touch.js', version='11102018t') }}" crossorigin="anonymous"></script>

<script type="text/javascript" charset="utf-8">
</script>
Expand Down