FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/core/src/utils/platform.ts at css-variable-docs-test · ModusCreateOrg/ionic · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ModusCreateOrg
/
ionic
Public
forked from
ionic-team/ionic-framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
core
/
src
/
utils
/
platform.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
117 lines (99 loc) · 2.55 KB
Breadcrumbs
ionic
/
core
/
src
/
utils
/
platform.ts
Copy path
File metadata and controls
117 lines (99 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
export
function
isIpad
(
win
:
Window
)
{
return
testUserAgent
(
win
,
/
i
P
a
d
/
i
)
;
}
export
function
isIphone
(
win
:
Window
)
{
return
testUserAgent
(
win
,
/
i
P
h
o
n
e
/
i
)
;
}
export
function
isIOS
(
win
:
Window
)
{
return
testUserAgent
(
win
,
/
i
P
a
d
|
i
P
h
o
n
e
|
i
P
o
d
/
i
)
;
}
export
function
isAndroid
(
win
:
Window
)
{
return
!
isIOS
(
win
)
;
}
export
function
isPhablet
(
win
:
Window
)
{
const
width
=
win
.
innerWidth
;
const
height
=
win
.
innerHeight
;
const
smallest
=
Math
.
min
(
width
,
height
)
;
const
largest
=
Math
.
max
(
width
,
height
)
;
return
(
smallest
>
390
&&
smallest
<
520
)
&&
(
largest
>
620
&&
largest
<
800
)
;
}
export
function
isTablet
(
win
:
Window
)
{
const
width
=
win
.
innerWidth
;
const
height
=
win
.
innerHeight
;
const
smallest
=
Math
.
min
(
width
,
height
)
;
const
largest
=
Math
.
max
(
width
,
height
)
;
return
(
smallest
>
460
&&
smallest
<
820
)
&&
(
largest
>
780
&&
largest
<
1400
)
;
}
export
function
isDevice
(
win
:
Window
)
{
return
matchMedia
(
win
,
'(any-pointer:coarse)'
)
;
}
export
function
isHybrid
(
win
:
Window
)
{
return
isCordova
(
win
)
||
isCapacitorNative
(
win
)
;
}
export
function
isCordova
(
window
:
Window
)
:
boolean
{
const
win
=
window
as
any
;
return
!
!
(
win
[
'cordova'
]
||
win
[
'phonegap'
]
||
win
[
'PhoneGap'
]
)
;
}
export
function
isCapacitorNative
(
window
:
Window
)
:
boolean
{
const
win
=
window
as
any
;
const
capacitor
=
win
[
'Capacitor'
]
;
return
!
!
(
capacitor
&&
capacitor
.
isNative
)
;
}
export
function
isElectron
(
win
:
Window
)
:
boolean
{
return
testUserAgent
(
win
,
/
e
l
e
c
t
r
o
n
/
)
;
}
export
function
needInputShims
(
win
:
Window
)
{
return
isIOS
(
win
)
&&
isDevice
(
win
)
;
}
export
function
testUserAgent
(
win
:
Window
,
expr
:
RegExp
)
{
return
expr
.
test
(
win
.
navigator
.
userAgent
)
;
}
export
function
matchMedia
(
win
:
Window
,
query
:
string
,
fallback
=
false
)
:
boolean
{
return
win
.
matchMedia
?
win
.
matchMedia
(
query
)
.
matches
:
fallback
;
}
export
interface
PlatformConfig
{
name
:
string
;
isMatch
:
(
win
:
Window
)
=>
boolean
;
}
export
const
PLATFORM_CONFIGS
:
PlatformConfig
[
]
=
[
{
name
:
'ipad'
,
isMatch
:
isIpad
}
,
{
name
:
'iphone'
,
isMatch
:
isIphone
}
,
{
name
:
'ios'
,
isMatch
:
isIOS
}
,
{
name
:
'android'
,
isMatch
:
isAndroid
}
,
{
name
:
'phablet'
,
isMatch
:
isPhablet
}
,
{
name
:
'tablet'
,
isMatch
:
isTablet
}
,
{
name
:
'cordova'
,
isMatch
:
isCordova
}
,
{
name
:
'electron'
,
isMatch
:
isElectron
}
]
;
export
function
detectPlatforms
(
win
:
Window
,
platforms
:
PlatformConfig
[
]
=
PLATFORM_CONFIGS
)
{
// bracket notation to ensure they're not property renamed
return
platforms
.
filter
(
p
=>
p
.
isMatch
(
win
)
)
;
}
Back
|
FazBrowse Home
|
New Git URL