remove hover effect on touch screens
Mwebclient/src/index.tsx
@@ -11,6 +11,37 @@ if (!(root instanceof HTMLElement)) {
"Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
);
}
function hasTouch() {
return (
"ontouchstart" in document.documentElement ||
navigator.maxTouchPoints > 0 ||
("msMaxTouchPoints" in navigator &&
typeof navigator.msMaxTouchPoints === "number" &&
navigator.msMaxTouchPoints > 0)
);
}
if (hasTouch()) {
// remove all the :hover stylesheets
try {
// prevent exception on browsers not supporting DOM styleSheets properly
for (const si in document.styleSheets) {
const styleSheet = document.styleSheets[si];
if (!styleSheet.cssRules) continue;
for (let ri = styleSheet.cssRules.length - 1; ri >= 0; ri--) {
const rule = styleSheet.cssRules[ri];
if (!("selectorText" in rule) || typeof rule.selectorText !== "string" || !rule.selectorText) continue;
if (rule.selectorText.match(":hover")) {
styleSheet.deleteRule(ri);
}
}
}
} catch {}
}
loadDataFromDB()
.then(() => {
root.innerHTML = "";