fix(angula): platform logic belongs to core

This commit is contained in:
Manu Mtz.-Almeida
2018-05-14 13:20:03 +02:00
parent d177087225
commit af5db2fb02
2 changed files with 49 additions and 48 deletions

View File

@ -70,3 +70,48 @@ export function matchMedia(win: Window, query: string, fallback = false): boolea
? 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));
}