aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronnoj <me@onnoj.net>2013-12-23 12:15:09 +0100
committeronnoj <me@onnoj.net>2013-12-23 12:15:09 +0100
commita0e9770d4de49de26fbbe70927a35e479f091a8b (patch)
tree4bcf3e1a38f251c111aa5710781f6ef5016f4965
parent8825277bf323c15f8354e0429af85868b919cf9a (diff)
Added workaround for window.scrollX compat.
window.scrollX/Y is not available in IE11. As far as specifications go, is currently only specified in draft (http://dev.w3.org/csswg/cssom-view/#refsCSSOM). Falling back to window.pageXOffset seems like a good workaround. On a related note; my Emscriptified project runs on IE11 although performance is very poor (mostly due to Internet Explorer itself, I think). It's pretty finicky about the shaders, as they introduced an extra set of requirements. (inout/in/out keywords not supported, can't construct mat3 from mat4, etc).
-rw-r--r--src/library_browser.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index b368c6ac..f3363e51 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -478,19 +478,21 @@ mergeInto(LibraryManager.library, {
// in the coordinates.
var rect = Module["canvas"].getBoundingClientRect();
var x, y;
+ var scrollX = ((window.scrollX !== undefined) ? window.scrollX : window.pageXOffset);
+ var scrollY = ((window.scrollY !== undefined) ? window.scrollY : window.pageYOffset);
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);
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
} else {
return;
}
} else {
- x = event.pageX - (window.scrollX + rect.left);
- y = event.pageY - (window.scrollY + rect.top);
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
}
// the canvas might be CSS-scaled compared to its backbuffer;