From 00778a168b7314039e95e856f6d41e05d0dbc4e4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Nov 2014 14:44:02 -0500 Subject: fix resize undo --- public/assets/javascripts/vendor/polyfill.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'public/assets/javascripts/vendor/polyfill.js') diff --git a/public/assets/javascripts/vendor/polyfill.js b/public/assets/javascripts/vendor/polyfill.js index f97e438..8e4b9dc 100644 --- a/public/assets/javascripts/vendor/polyfill.js +++ b/public/assets/javascripts/vendor/polyfill.js @@ -52,6 +52,11 @@ function has3d(){ return browser; })( navigator.userAgent ); +// Naive useragent detection pattern +var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)); +var is_ipad = (navigator.userAgent.match(/iPad/i)); +var is_android = (navigator.userAgent.match(/Android/i)) +var is_mobile = is_iphone || is_ipad || is_android; // rAF shim (function() { -- cgit v1.2.3-70-g09d2 From 6613eafa8d5c3e323e464e56c523505928568844 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Nov 2014 17:49:41 -0500 Subject: don’t put things in the dom until you’re in landscape mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/javascripts/ui/reader/ReaderView.js | 21 ++++++++++++++++++++- public/assets/javascripts/vendor/polyfill.js | 8 +++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'public/assets/javascripts/vendor/polyfill.js') diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index db2ab2f..aea681a 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -50,8 +50,27 @@ var ReaderView = View.extend({ ready: function(data){ $("#map").hide() - this.data = data + var is_landscape = window.innerWidth > window.innerHeight + + if (is_desktop || (is_mobile && is_landscape)) { + this.build(data) + return + } + + // don't build anything until we're in landscape mode, otherwise ios might crash + var orientationFn = orientationchange.bind(this) + window.addEventListener('orientationchange', orientationFn) + function orientationchange (e) { + var is_landscape = window.innerWidth > window.innerHeight + if (is_landscape) { + window.removeEventListener('orientationchange', orientationFn) + this.build(data) + } + } + }, + + build: function(data){ data.rooms && Rooms.deserialize(data.rooms) data.walls && Walls.deserialize(data.walls) data.media && Scenery.deserialize(data.media) diff --git a/public/assets/javascripts/vendor/polyfill.js b/public/assets/javascripts/vendor/polyfill.js index 8e4b9dc..499cbc5 100644 --- a/public/assets/javascripts/vendor/polyfill.js +++ b/public/assets/javascripts/vendor/polyfill.js @@ -53,10 +53,12 @@ function has3d(){ })( navigator.userAgent ); // Naive useragent detection pattern -var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)); -var is_ipad = (navigator.userAgent.match(/iPad/i)); +var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +var is_ipad = (navigator.userAgent.match(/iPad/i)) var is_android = (navigator.userAgent.match(/Android/i)) -var is_mobile = is_iphone || is_ipad || is_android; +var is_mobile = is_iphone || is_ipad || is_android +var is_desktop = ! is_mobile; + // rAF shim (function() { -- cgit v1.2.3-70-g09d2 From d67ead4ebbe27dc66d89927ff3ab91662fabdae4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 3 Feb 2015 13:25:23 -0500 Subject: fix tests --- public/assets/javascripts/app.js | 2 -- public/assets/javascripts/mx/mx.js | 16 ++++++++-------- public/assets/javascripts/vendor/polyfill.js | 3 ++- public/assets/test/intersect2.html | 5 +++-- public/assets/test/intersect3.html | 5 +++-- public/assets/test/surface.html | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) (limited to 'public/assets/javascripts/vendor/polyfill.js') diff --git a/public/assets/javascripts/app.js b/public/assets/javascripts/app.js index a146325..6ff062e 100644 --- a/public/assets/javascripts/app.js +++ b/public/assets/javascripts/app.js @@ -23,8 +23,6 @@ app.launch = function () { var movements - app.devicePixelRatio = is_mobile ? devicePixelRatio : 1 - scene = new MX.Scene().addTo('#scene') scene.width = window.innerWidth scene.height = window.innerHeight diff --git a/public/assets/javascripts/mx/mx.js b/public/assets/javascripts/mx/mx.js index ab9a9a0..60651eb 100644 --- a/public/assets/javascripts/mx/mx.js +++ b/public/assets/javascripts/mx/mx.js @@ -25,7 +25,7 @@ var MX = MX || (function (undefined) { var MX = { version: '0.1.0', prefix: undefined, - rotationUnit: 'rad' + rotationUnit: 'rad', } var floatPrecision = 5 @@ -162,24 +162,24 @@ var MX = MX || (function (undefined) { Object.defineProperty(this, 'width', { get: function () { return width - || parseInt(self.el.style.width, 10) * app.devicePixelRatio + || parseInt(self.el.style.width, 10) * app_devicePixelRatio || 0 }, set: function (val) { width = val - this.el.style.width = (width/app.devicePixelRatio) + 'px' + this.el.style.width = (width/app_devicePixelRatio) + 'px' } }) Object.defineProperty(this, 'height', { get: function () { return height - || parseInt(self.el.style.height, 10) * app.devicePixelRatio + || parseInt(self.el.style.height, 10) * app_devicePixelRatio || 0 }, set: function (val) { height = val - this.el.style.height = (height/app.devicePixelRatio) + 'px' + this.el.style.height = (height/app_devicePixelRatio) + 'px' } }) } @@ -302,9 +302,9 @@ var MX = MX || (function (undefined) { + (-this.y).toFixed(floatPrecision) + 'px,' + (-this.z).toFixed(floatPrecision) + 'px) ' + 'scale3d(' - + (app.devicePixelRatio * this.scaleX).toFixed(floatPrecision) + ',' - + (app.devicePixelRatio * this.scaleY).toFixed(floatPrecision) + ',' - + (app.devicePixelRatio * this.scaleZ).toFixed(floatPrecision) + ') ' + + (app_devicePixelRatio * this.scaleX).toFixed(floatPrecision) + ',' + + (app_devicePixelRatio * this.scaleY).toFixed(floatPrecision) + ',' + + (app_devicePixelRatio * this.scaleZ).toFixed(floatPrecision) + ') ' if (rotationTranslation) { transformString += rotationTranslation.before diff --git a/public/assets/javascripts/vendor/polyfill.js b/public/assets/javascripts/vendor/polyfill.js index 499cbc5..2139618 100644 --- a/public/assets/javascripts/vendor/polyfill.js +++ b/public/assets/javascripts/vendor/polyfill.js @@ -48,7 +48,7 @@ function has3d(){ } else if ( browser.webkit ) { browser.safari = true; } - $.browser = browser; + if (window.$) $.browser = browser; return browser; })( navigator.userAgent ); @@ -58,6 +58,7 @@ var is_ipad = (navigator.userAgent.match(/iPad/i)) var is_android = (navigator.userAgent.match(/Android/i)) var is_mobile = is_iphone || is_ipad || is_android var is_desktop = ! is_mobile; +var app_devicePixelRatio = is_mobile ? devicePixelRatio : 1; // rAF shim diff --git a/public/assets/test/intersect2.html b/public/assets/test/intersect2.html index 3df9f30..9a6deb2 100644 --- a/public/assets/test/intersect2.html +++ b/public/assets/test/intersect2.html @@ -6,9 +6,10 @@ body,html{margin:0;padding:0;}
- - + + + diff --git a/public/assets/test/intersect3.html b/public/assets/test/intersect3.html index 5440a76..0db85f0 100644 --- a/public/assets/test/intersect3.html +++ b/public/assets/test/intersect3.html @@ -6,9 +6,10 @@ body,html{margin:0;padding:0;}
- - + + + diff --git a/public/assets/test/surface.html b/public/assets/test/surface.html index 85e3a7b..02be479 100644 --- a/public/assets/test/surface.html +++ b/public/assets/test/surface.html @@ -1,7 +1,7 @@ - + -- cgit v1.2.3-70-g09d2