Skip to content

Commit 9f4ac79

Browse files
committed
Anti scrolling added
1 parent 8ede78b commit 9f4ac79

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

main/index.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/* index.css */
22

33
/* Global styles */
4-
body, html {
4+
html, body, #root {
55
margin: 0;
66
padding: 0;
77
width: 100%;
88
height: 100%;
9-
background-color: black; /* Outside the monitor: black */
10-
overflow: hidden;
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 */
1113
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
1214
}
1315

@@ -16,19 +18,22 @@ body, html {
1618
display: none !important;
1719
}
1820

19-
/* App.css */
20-
2121
/* Hide any iframes that might be embedded inadvertently */
2222
body > iframe {
2323
display: none;
2424
}
2525

26-
/* Prevent scrolling on the global document.
27-
Note: The .desktop container is our new full-size "screen" */
28-
html, body {
29-
margin: 0;
30-
padding: 0;
31-
overflow: hidden;
26+
/* If you have a full-screen container like .desktop, lock it too */
27+
.desktop {
28+
width: 100%;
3229
height: 100%;
30+
overflow: hidden !important;
31+
touch-action: none !important;
32+
overscroll-behavior: none !important;
3333
}
3434

35+
/* Block any remaining overscroll on all elements */
36+
* {
37+
touch-action: none !important;
38+
overscroll-behavior: none !important;
39+
}

main/main.jsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
// main.jsx
2-
import React, { StrictMode } from 'react';
2+
3+
import React, { StrictMode, useEffect } from 'react';
34
import { createRoot } from 'react-dom/client';
45
import './index.css';
56
import BIOS from '../src/BIOS/BIOS';
67

7-
88
const Main = () => {
9+
useEffect(() => {
10+
// Prevent wheel-based scrolling
11+
const preventScroll = (e) => {
12+
e.preventDefault();
13+
};
14+
15+
// Add listeners for both mouse wheel and touch moves
16+
document.addEventListener('wheel', preventScroll, { passive: false });
17+
document.addEventListener('touchmove', preventScroll, { passive: false });
18+
19+
// Clean up on unmount
20+
return () => {
21+
document.removeEventListener('wheel', preventScroll);
22+
document.removeEventListener('touchmove', preventScroll);
23+
};
24+
}, []);
925

1026
return (
11-
<StrictMode>
12-
<BIOS/>
27+
<StrictMode>
28+
<BIOS />
1329
</StrictMode>
1430
);
1531
};

0 commit comments

Comments
 (0)