aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorJames Gregory <james@james.id.au>2013-08-08 12:46:17 -0700
committerJames Gregory <james@james.id.au>2013-08-08 12:46:17 -0700
commit46c82708d50e839945fa24094fe352241be6a22e (patch)
tree2d07e805b86593ec629e5140803d6c375faa5f7b /src/library_browser.js
parente7759cd4b9a47d99e9948cb122f3b1a007f7eb1e (diff)
Basic touch event support in GLUT for mobile browsers.
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 0db2cc44..2b69e5d9 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -446,8 +446,21 @@ mergeInto(LibraryManager.library, {
// Otherwise, calculate the movement based on the changes
// in the coordinates.
var rect = Module["canvas"].getBoundingClientRect();
- var x = event.pageX - (window.scrollX + rect.left);
- var y = event.pageY - (window.scrollY + rect.top);
+ var x, y;
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (window.scrollX + rect.left);
+ y = t.pageY - (window.scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (window.scrollX + rect.left);
+ y = event.pageY - (window.scrollY + rect.top);
+ }
// the canvas might be CSS-scaled compared to its backbuffer;
// SDL-using content will want mouse coordinates in terms