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 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/reader') 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) -- cgit v1.2.3-70-g09d2