Skip to content

Commit 651c9c0

Browse files
committed
#40 touchscreen swithcing added
1 parent e5c7ee0 commit 651c9c0

File tree

3 files changed

+295
-176
lines changed

3 files changed

+295
-176
lines changed

main/index.css

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ html, body, #root {
66
padding: 0;
77
width: 100%;
88
height: 100%;
9-
background-color: black; /* Outside the monitor: black */
10-
overflow: hidden !important; /* Disable all scrolling */
11-
touch-action: none !important; /* Disable touch scrolling */
12-
overscroll-behavior: none !important; /* Prevent scroll chaining */
9+
background-color: black; /* Outside the monitor: black */
10+
overflow: hidden !important; /* Disable scrolling */
11+
touch-action: none !important; /* Disable touch gestures */
12+
overscroll-behavior: none !important; /* Prevent scroll chaining */
13+
-webkit-user-select: none !important; /* Disable text selection in WebKit */
14+
-moz-user-select: none !important; /* Disable text selection in Firefox */
15+
-ms-user-select: none !important; /* Disable text selection in IE10+ */
16+
user-select: none !important; /* Standard property */
17+
-webkit-tap-highlight-color: transparent !important; /* Remove tap highlight flash */
1318
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
1419
}
1520

@@ -30,10 +35,18 @@ body > iframe {
3035
overflow: hidden !important;
3136
touch-action: none !important;
3237
overscroll-behavior: none !important;
38+
-webkit-user-select: none !important;
39+
-moz-user-select: none !important;
40+
-ms-user-select: none !important;
41+
user-select: none !important;
3342
}
3443

35-
/* Block any remaining overscroll on all elements */
44+
/* Apply to all elements, to be sure no child can be selected */
3645
* {
46+
-webkit-user-select: none !important;
47+
-moz-user-select: none !important;
48+
-ms-user-select: none !important;
49+
user-select: none !important;
3750
touch-action: none !important;
3851
overscroll-behavior: none !important;
3952
}

main/main.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ import BIOS from '../src/BIOS/BIOS';
77

88
const Main = () => {
99
useEffect(() => {
10-
// Prevent wheel-based scrolling
11-
const preventScroll = (e) => {
10+
// Prevent all scrolling
11+
const preventDefault = (e) => {
1212
e.preventDefault();
1313
};
1414

15-
// Add listeners for both mouse wheel and touch moves
16-
document.addEventListener('wheel', preventScroll, { passive: false });
17-
document.addEventListener('touchmove', preventScroll, { passive: false });
15+
// Block wheel, touchmove, text selection start, and context menu (long-press)
16+
document.addEventListener('wheel', preventDefault, { passive: false });
17+
document.addEventListener('touchmove', preventDefault, { passive: false });
18+
document.addEventListener('selectstart', preventDefault);
19+
document.addEventListener('contextmenu', preventDefault);
1820

19-
// Clean up on unmount
2021
return () => {
21-
document.removeEventListener('wheel', preventScroll);
22-
document.removeEventListener('touchmove', preventScroll);
22+
document.removeEventListener('wheel', preventDefault);
23+
document.removeEventListener('touchmove', preventDefault);
24+
document.removeEventListener('selectstart', preventDefault);
25+
document.removeEventListener('contextmenu', preventDefault);
2326
};
2427
}, []);
2528

0 commit comments

Comments
 (0)