Files
headlessui/packages/@headlessui-vue/src/utils/platform.ts
T
Robin Malfait 25a4e7f721 Improve scroll lock on iOS (#1824)
* improve `Dialog` scroll lock on iOS

* add Dialog example to playground that's scrollable

* update changelog
2022-09-05 23:54:54 +02:00

15 lines
773 B
TypeScript

export function isIOS() {
// TODO: This is not a great way to detect iOS, but it's the best I can do for now.
// - `window.platform` is deprecated
// - `window.userAgentData.platform` is still experimental (https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/platform)
// - `window.userAgent` also doesn't contain the required information
return (
// Check if it is an iPhone
/iPhone/gi.test(window.navigator.platform) ||
// Check if it is an iPad. iPad reports itself as "MacIntel", but we can check if it is a touch
// screen. Let's hope that Apple doesn't release a touch screen Mac (or maybe this would then
// work as expected 🤔).
(/Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0)
)
}