|
1 | | -import {Screen} from "@nativescript/core"; |
2 | | -import {Application} from "@nativescript/core"; |
| 1 | +import { Screen } from '@nativescript/core'; |
| 2 | +import { Application } from '@nativescript/core'; |
3 | 3 | /* |
4 | 4 | Window Resize Stub |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | const scale = Screen.mainScreen.scale; |
8 | 8 |
|
9 | 9 | (global as any).window.devicePixelRatio = (global as any).devicePixelRatio = 1; |
10 | | -(global as any).window.innerWidth = (global as any).innerWidth = |
11 | | - Screen.mainScreen.widthPixels; |
12 | | -(global as any).window.clientWidth = (global as any).clientWidth = |
13 | | - Screen.mainScreen.widthPixels; |
14 | | -(global as any).window.innerHeight = (global as any).innerHeight = |
15 | | - Screen.mainScreen.heightPixels; |
16 | | -(global as any).window.clientHeight = (global as any).clientHeight = |
17 | | - Screen.mainScreen.heightPixels; |
18 | | -(global as any).window.screen = (global as any).screen = |
19 | | - (global as any).screen || {}; |
20 | | -(global as any).window.screen.orientation = (global as any).screen.orientation = |
21 | | - (global as any).screen.orientation || |
22 | | - (global as any).clientWidth < (global as any).clientHeight |
23 | | - ? 0 |
24 | | - : 90; |
| 10 | +(global as any).window.innerWidth = (global as any).innerWidth = Screen.mainScreen.widthPixels; |
| 11 | +(global as any).window.clientWidth = (global as any).clientWidth = Screen.mainScreen.widthPixels; |
| 12 | +(global as any).window.innerHeight = (global as any).innerHeight = Screen.mainScreen.heightPixels; |
| 13 | +(global as any).window.clientHeight = (global as any).clientHeight = Screen.mainScreen.heightPixels; |
| 14 | +(global as any).window.screen = (global as any).screen = (global as any).screen || {}; |
| 15 | +(global as any).window.screen.orientation = (global as any).screen.orientation = (global as any).screen.orientation || (global as any).clientWidth < (global as any).clientHeight ? 0 : 90; |
25 | 16 |
|
26 | 17 | if (!(global as any).__TNS_BROWSER_POLYFILL_RESIZE) { |
27 | | - (global as any).__TNS_BROWSER_POLYFILL_RESIZE = true; |
28 | | - Application.on("orientationChanged", (args) => { |
29 | | - let width = 0; |
30 | | - let height = 0; |
31 | | - switch (args.newValue) { |
32 | | - case "portrait": |
33 | | - width = Screen.mainScreen.widthPixels; |
34 | | - height = Screen.mainScreen.heightPixels; |
35 | | - break; |
36 | | - default: |
37 | | - width = Screen.mainScreen.heightPixels; |
38 | | - height = Screen.mainScreen.widthPixels; |
39 | | - break; |
40 | | - } |
| 18 | + (global as any).__TNS_BROWSER_POLYFILL_RESIZE = true; |
| 19 | + Application.on(Application.orientationChangedEvent, (args) => { |
| 20 | + let width = Screen.mainScreen.widthPixels; |
| 21 | + let height = Screen.mainScreen.heightPixels; |
41 | 22 |
|
42 | | - (global as any).window.devicePixelRatio = (global as any).devicePixelRatio = scale; |
43 | | - (global as any).window.innerWidth = (global as any).innerWidth = width; |
44 | | - (global as any).window.clientWidth = (global as any).clientWidth = width; |
45 | | - (global as any).window.innerHeight = (global as any).innerHeight = height; |
46 | | - (global as any).window.clientHeight = (global as any).clientHeight = height; |
47 | | - (global as any).window.orientation = (global as any).orientation = |
48 | | - args.newValue === "portrait" ? 0 : 90; |
49 | | - (global as any).window.screen.orientation = (global as any).screen.orientation = (global as any).orientation; |
50 | | - if ((global as any).emitter && (global as any).emitter.emit) { |
51 | | - (global as any).emitter.emit("resize"); |
52 | | - } |
53 | | - }); |
| 23 | + (global as any).window.devicePixelRatio = (global as any).devicePixelRatio = scale; |
| 24 | + (global as any).window.innerWidth = (global as any).innerWidth = width; |
| 25 | + (global as any).window.clientWidth = (global as any).clientWidth = width; |
| 26 | + (global as any).window.innerHeight = (global as any).innerHeight = height; |
| 27 | + (global as any).window.clientHeight = (global as any).clientHeight = height; |
| 28 | + (global as any).window.orientation = (global as any).orientation = args.newValue === 'portrait' ? 0 : 90; |
| 29 | + (global as any).window.screen.orientation = (global as any).screen.orientation = (global as any).orientation; |
| 30 | + if ((global as any).emitter && (global as any).emitter.emit) { |
| 31 | + (global as any).emitter.emit('resize'); |
| 32 | + } |
| 33 | + }); |
54 | 34 | } |
0 commit comments