Skip to content

Commit

Permalink
style: set bottom when scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
theanishtar committed Oct 15, 2024
1 parent cde8913 commit f8dfc35
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
7 changes: 6 additions & 1 deletion app/menu/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ export default function Menu() {
const menu = document.querySelector("#menu ul");
const scrollPosition = document.body.scrollTop; // Lấy vị trí cuộn của body
console.log('scroll body', scrollPosition);
const modeDiv = document.querySelector('.mode-mobile');

if (!menu)
return;
if (scrollPosition > lastScrollY) {
// Cuộn xuống -> ẩn menu
menu.classList.add('hidden');
if (modeDiv)
modeDiv.classList.remove('mode');
} else {
// Cuộn lên -> hiện menu
menu.classList.remove('hidden');
if (modeDiv)
modeDiv.classList.add('mode');
}

// Cập nhật lastScrollY để so sánh trong lần cuộn tiếp theo
Expand Down Expand Up @@ -65,7 +70,7 @@ export default function Menu() {
</li>
{/* Add other links similarly */}
</ul>
<div className="mode">
<div className="mode-mobile">
<button onClick={toggleMode}>
<i className={`bx ${isDarkMode ? 'bx-moon' : 'bx-sun'} sun-moon`}></i>
</button>
Expand Down
15 changes: 2 additions & 13 deletions styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,14 @@ i {
}


.mode button i {
font-size: 20px;
}


.menu .mode {
position: fixed;
left: 22px;
bottom: 60px;
}

.main {
min-height: calc(100vh - 100px);
/* Adjust 100px to match your footer's height */
display: flex;
flex-direction: column;
}

.menu .mode button {
.menu .mode-mobile button {
width: 44px;
height: 44px;
display: flex;
Expand All @@ -48,7 +37,7 @@ i {
cursor: pointer;
}

.menu .mode ._icon_1plrx_24 {
.menu .mode-mobile ._icon_1plrx_24 {
position: relative;
width: 100%;
height: 100%;
Expand Down
20 changes: 19 additions & 1 deletion styles/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
}


.mode-mobile button i {
font-size: 20px;
}


.menu .mode-mobile {
position: fixed;
left: 22px;
bottom: 60px;
}






.menu ul {
list-style: none;
padding: 0;
Expand Down Expand Up @@ -101,8 +117,10 @@ svg:not(:host).svg-inline--fa {
justify-content: space-around;
align-items: center;
padding-bottom: 45px;
}


.menu .mode.mode-mobile {
bottom: 20px;
}

.hidden {
Expand Down
4 changes: 2 additions & 2 deletions styles/mode.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
color: rgb(250, 250, 250);
}

.dark-mode .mode:hover i {
.dark-mode .mode-mobile:hover i {
color: #009688;
}

Expand Down Expand Up @@ -88,7 +88,7 @@
color: rgb(255, 255, 255);
}

.dark-mode .mode {
.dark-mode .mode-mobile {
color: aliceblue
}

Expand Down

0 comments on commit f8dfc35

Please sign in to comment.