Commit cfceaf49 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Migrate user-agent to TS

parent 000f9cb3
...@@ -5,23 +5,20 @@ ...@@ -5,23 +5,20 @@
/** /**
* Returns true when the OS is Mac OS. * Returns true when the OS is Mac OS.
* *
* @param _userAgent {string} - Test seam * @param _userAgent - Test seam
*/ */
export const isMacOS = (_userAgent = window.navigator.userAgent) => { export const isMacOS = (_userAgent: string = window.navigator.userAgent) => {
return _userAgent.indexOf('Mac OS') >= 0; return _userAgent.indexOf('Mac OS') >= 0;
}; };
/** /**
* Returns true when device is iOS. * Returns true when device is iOS.
* https://stackoverflow.com/a/9039885/14463679 * https://stackoverflow.com/a/9039885/14463679
*
* @param _navigator {{platform: string, userAgent: string}}
* @param _ontouchend {boolean}
*/ */
export const isIOS = ( export const isIOS = (
_navigator = window.navigator, _navigator: { platform: string; userAgent: string } = window.navigator,
_ontouchend = 'ontouchend' in document _ontouchend: boolean = 'ontouchend' in document
) => { ): boolean => {
return ( return (
[ [
'iPad Simulator', 'iPad Simulator',
...@@ -40,9 +37,7 @@ export const isIOS = ( ...@@ -40,9 +37,7 @@ export const isIOS = (
* Returns true when the device is a touch device such * Returns true when the device is a touch device such
* as android or iOS. * as android or iOS.
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer#browser_compatibility * https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer#browser_compatibility
*
* @param _window {Window} - Test seam
*/ */
export const isTouchDevice = (_window = window) => { export const isTouchDevice = (_window: Window = window): boolean => {
return _window.matchMedia('(pointer: coarse)').matches; return _window.matchMedia('(pointer: coarse)').matches;
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment