aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronnoj <me@onnoj.net>2014-01-02 11:48:39 +0100
committeronnoj <me@onnoj.net>2014-01-02 11:48:39 +0100
commite132e7a2b54564ffb710c4fc5a8f29fc0431f847 (patch)
tree56404519b96b5ac140a816bc9545a237f3d002d9
parenta0e9770d4de49de26fbbe70927a35e479f091a8b (diff)
Added comments & assert to scrollX fix.
Added comments to fix as per @kripken's request. Added an assert too (guarded by ASSERTIONS define)
-rw-r--r--src/library_browser.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index f3363e51..bf8444bd 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -478,8 +478,17 @@ mergeInto(LibraryManager.library, {
// in the coordinates.
var rect = Module["canvas"].getBoundingClientRect();
var x, y;
+
+ //Neither .scrollX or .pageXOffset are defined in a spec, but
+ //we prefer .scrollX because it is currently in a spec draft.
+ //(see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
var scrollX = ((window.scrollX !== undefined) ? window.scrollX : window.pageXOffset);
var scrollY = ((window.scrollY !== undefined) ? window.scrollY : window.pageYOffset);
+ #if ASSERTIONS
+ //If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset
+ //and we have no viable fallback.
+ assert((scrollX !== undefined) && (scrollY !== undefined), 'Unable to retrieve scroll position, mouse positions likely broken.');
+ #endif
if (event.type == 'touchstart' ||
event.type == 'touchend' ||
event.type == 'touchmove') {