mirror of
https://github.com/aljazceru/awesome-nostr.git
synced 2026-07-08 01:18:10 -07:00
Fix scrolling on desktop and mobile
- Fix desktop: use fixed height on .main-content so overflow-y: auto creates a proper scroll container (min-height prevented scrolling) - Fix mobile: override to height: auto and overflow: visible so the body handles scrolling naturally - Fix touch swipe handler blocking vertical scroll by restricting swipe detection to left edge zone and raising preventDefault threshold - Move @import out of :root block (invalid CSS, font may not load) - Add overflow-wrap/word-break to prevent long URLs causing horizontal scroll - Add overflow handling for markdown content (pre, code, table, img) - Add overflow: hidden on top-nav and max-width guard on mobile nav-content
This commit is contained in:
@@ -385,11 +385,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let touchEndX = 0;
|
||||
let touchEndY = 0;
|
||||
let isSwiping = false;
|
||||
const EDGE_ZONE = 30; // px from left edge to trigger swipe
|
||||
|
||||
const handleTouchStart = (e) => {
|
||||
touchStartX = e.touches[0].clientX;
|
||||
touchStartY = e.touches[0].clientY;
|
||||
isSwiping = true;
|
||||
// Only allow swipe gesture from the left edge or when sidebar is open
|
||||
isSwiping = touchStartX < EDGE_ZONE || sidebar.classList.contains('active');
|
||||
};
|
||||
|
||||
const handleTouchMove = (e) => {
|
||||
@@ -401,12 +403,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const deltaX = touchStartX - touchEndX;
|
||||
const deltaY = Math.abs(touchStartY - touchEndY);
|
||||
|
||||
// If vertical movement dominates, this is a scroll, not a swipe
|
||||
if (deltaY > Math.abs(deltaX)) {
|
||||
isSwiping = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.abs(deltaX) > 10) {
|
||||
// Only prevent default once we're confident this is a horizontal swipe
|
||||
if (Math.abs(deltaX) > 30 && Math.abs(deltaX) > deltaY * 2) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
+35
-4
@@ -1,6 +1,6 @@
|
||||
:root {
|
||||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap");
|
||||
|
||||
:root {
|
||||
--primary-color: #3a0ca3;;
|
||||
--background-color: #c8e7ff;
|
||||
--text-color: #1a090d;
|
||||
@@ -37,6 +37,8 @@ body {
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
line-height: 1.6;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.container {
|
||||
@@ -167,8 +169,9 @@ body {
|
||||
padding: 2rem;
|
||||
padding-top: 80px; /* Increased padding-top to account for fixed nav */
|
||||
flex: 1;
|
||||
min-height: 100vh;
|
||||
overflow: auto;
|
||||
height: 100vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
margin-top: 0;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior: contain;
|
||||
@@ -291,6 +294,9 @@ body {
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
padding-top: 100px; /* Increase padding-top for mobile to account for wrapped nav elements */
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
overscroll-behavior: auto;
|
||||
}
|
||||
|
||||
.menu-toggle {
|
||||
@@ -355,6 +361,8 @@ body {
|
||||
.markdown-content {
|
||||
padding: 10px;
|
||||
line-height: 1.5;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.markdown-content a {
|
||||
@@ -366,6 +374,27 @@ body {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.markdown-content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.markdown-content pre {
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.markdown-content code {
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.markdown-content table {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Update contributors grid styles */
|
||||
.contributors-grid {
|
||||
display: grid;
|
||||
@@ -598,6 +627,7 @@ button:focus {
|
||||
right: 0;
|
||||
z-index: 1001;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.nav-content {
|
||||
@@ -660,6 +690,7 @@ button:focus {
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem 1rem;
|
||||
margin-left: 2.5rem; /* Space for menu toggle */
|
||||
max-width: calc(100% - 2.5rem);
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
|
||||
Reference in New Issue
Block a user