You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
38 lines
1.0 KiB
38 lines
1.0 KiB
export default class Platform { |
|
static currentPlatform = ""; |
|
|
|
static asChanged() { |
|
let result = Platform.currentPlatform != Platform.detect(); |
|
Platform.currentPlatform = Platform.detect(); |
|
return result; |
|
} |
|
|
|
static detect() { |
|
if(window.innerWidth < 640) return "mobile"; |
|
else if (window.innerWidth < 1150) return "tablet"; |
|
else if(window.innerWidth < 1450) return "laptop"; |
|
else return "desktop"; |
|
} |
|
|
|
static getLower(platform) { |
|
switch(platform) { |
|
case "mobile": return "mobile"; |
|
case "tablet": return "mobile"; |
|
case "laptop": return "tablet"; |
|
case "desktop": return "laptop"; |
|
} |
|
} |
|
|
|
static superiorTo(platform) { |
|
let pf = Platform.detect(); |
|
while(Platform.asLower(pf)) { |
|
pf = Platform.getLower(pf); |
|
if(platform == pf) return true; |
|
} |
|
return false; |
|
} |
|
|
|
static asLower(platform) { |
|
return platform != "mobile"; |
|
} |
|
}
|
|
|