mobile hackery
This commit is contained in:
@@ -46,7 +46,7 @@ function setVHvar() {
|
||||
}
|
||||
function mobileVHhack() {
|
||||
setVHvar();
|
||||
window.addEventListener("orientationchange", setVHvar);
|
||||
// window.addEventListener("orientationchange", setVHvar);
|
||||
}
|
||||
|
||||
function isAndroidMobile() {
|
||||
@@ -55,4 +55,33 @@ function isAndroidMobile() {
|
||||
return isAndroid;
|
||||
}
|
||||
|
||||
// Trying to determine if browser is mobile/tablet.
|
||||
// Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
|
||||
function hasTouchScreen() {
|
||||
var hasTouchScreen = false;
|
||||
if ("maxTouchPoints" in navigator) {
|
||||
hasTouchScreen = navigator.maxTouchPoints > 0;
|
||||
} else if ("msMaxTouchPoints" in navigator) {
|
||||
hasTouchScreen = navigator.msMaxTouchPoints > 0;
|
||||
} else {
|
||||
var mQ = window.matchMedia && matchMedia("(pointer:coarse)");
|
||||
if (mQ && mQ.media === "(pointer:coarse)") {
|
||||
hasTouchScreen = !!mQ.matches;
|
||||
} else if ('orientation' in window) {
|
||||
hasTouchScreen = true; // deprecated, but good fallback
|
||||
} else {
|
||||
// Only as a last resort, fall back to user agent sniffing
|
||||
var UA = navigator.userAgent;
|
||||
hasTouchScreen = (
|
||||
/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) ||
|
||||
/\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA)
|
||||
);
|
||||
}
|
||||
}
|
||||
return hasTouchScreen;
|
||||
}
|
||||
|
||||
function handleOrientationChange(event) {
|
||||
console.log("====orientation change 123", event, window.screen.orientation, window.orientation)
|
||||
setVHvar();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user