-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction changeOrientation()
More file actions
99 lines (87 loc) · 3.85 KB
/
Copy pathfunction changeOrientation()
File metadata and controls
99 lines (87 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// code to be copied to EJSS source code under Custom and used in drawingPanel3D and plottingPanel2D
// address the problem is height difference is iOS app , epub, and Firefox
// user need to change only k and kepub
// copy %changeOrientation()% into the Height Field of drawingPanel3D and plottingPanel2D
// _view.plottingPanel.getGraphics().setHeight(changeOrientation(0.85));
function changeOrientation(kheight) {
var k =0.90 ; // k control height 1 is for full screen, 0.9 shorten etc
var kapple =kheight // control apple app height
var kepub =0.90 ;
// check platform for Apps
try { // allow code to run in Student Learning Space
var iOSapp = (typeof parent.device != 'undefined' && parent.device.platform == "iOS");
var Androidapp = (typeof parent.device != 'undefined' && parent.device.platform == "Android");
} catch(e) {
var iOSapp = false;
var Androidapp = false;
}
// check platform for web browsers
var iOS =/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var iPad =/iPad/.test(navigator.userAgent) && !window.MSStream;
var iPhone = /iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var Android= /Android|android/i.test(navigator.userAgent);
//navigator
var Firefox = navigator.userAgent.indexOf("Firefox") != -1;
switch (window.orientation) { // using window.orientation as deciding factor
case 0:
case 180:
this.screenOrientation = 'portrait';
if (iOSapp){ // does not seems to work
return window.screen.height*kapple; //0.1 for app and 0.1 for nonfullscreenapp
}
else if (_isEPub){ // does not seems to work
// return Math.max(window.screen.width,window.screen.height)*0.9;
return window.innerHeight*kepub; //0.1 for app and 0.1 for nonfullscreenapp
// return window.screen.height;
// return window.innerHeight;
// return document.documentElement.clientHeight;
}
else {
return window.innerHeight*kheight;
//return 100*k+"vh";
}
break;
case 90:
case -90:
this.screenOrientation = 'landscape';
if (iOSapp){ // App
return window.screen.width*kapple;
// return window.screen.height;
// return window.innerHeight;
// return document.documentElement.clientHeight;
}
else if (_isEPub){ // does not seems to work
// return Math.max(window.screen.width,window.screen.height)*0.9;
return window.innerHeight*kepub; //0.1 for app and 0.1 for nonfullscreenapp
// return window.screen.height;
// return window.innerHeight;
// return document.documentElement.clientHeight;
}
else {
return window.innerHeight*kheight;
//return 100*k+"vh"; // safari produce error
}
break;
default:
this.screenOrientation = 'unknown';
// return (iPad)?""+(window.screen.width+window.screen.height)*0.4:((iPhone)?""+window.screen.width:_view._format(window.innerHeight*0.9,"0"));
if (Firefox){
return window.innerHeight*k;// number as of 20180831 Firefox does not support vh yet so need a separate line to handle
}
// else if (iOS&&(window.orientation==0)||(window.orientation==180)){
// return window.screen.height*k;// number as of 20180831 Firefox does not support vh yet so need a separate line to handle
// }
// else if (iOS&&(window.orientation==90)||(window.orientation==-90)){
// return window.screen.width*k;// number as of 20180831 Firefox does not support vh yet so need a separate line to handle
// }
else {
//alert();
// return 100*k+"%"; // work on fullscreen works in EJSS6.0beta
// works in EjsS_5.3_180131
//return window.innerHeight*kheight; // work on panel
// take note the panel that contains the plottingPanel needs to be 100% in Height to maximize the view
return 100*k+"vh";
// 100% does not work on iOS after clicking reset it lengthens
}
}
}