File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * @author Richard Davey <rich@photonstorm.com>
3+ * @copyright 2018 Photon Storm Ltd.
4+ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
5+ */
6+
7+ var GetInnerHeight = function ( iOS )
8+ {
9+ // Based on code by @tylerjpeterson
10+
11+ if ( ! iOS )
12+ {
13+ return window . innerHeight ;
14+ }
15+
16+ var axis = Math . abs ( window . orientation ) ;
17+
18+ var size = { w : 0 , h : 0 } ;
19+
20+ var ruler = document . createElement ( 'div' ) ;
21+
22+ ruler . setAttribute ( 'style' , 'position: fixed; height: 100vh; width: 0; top: 0' ) ;
23+
24+ document . documentElement . appendChild ( ruler ) ;
25+
26+ size . w = ( axis === 90 ) ? ruler . offsetHeight : window . innerWidth ;
27+ size . h = ( axis === 90 ) ? window . innerWidth : ruler . offsetHeight ;
28+
29+ document . documentElement . removeChild ( ruler ) ;
30+
31+ ruler = null ;
32+
33+ if ( Math . abs ( window . orientation ) !== 90 )
34+ {
35+ return size . h ;
36+ }
37+ else
38+ {
39+ return size . w ;
40+ }
41+ } ;
42+
43+ module . exports = GetInnerHeight ;
You can’t perform that action at this time.
0 commit comments