Skip to content

Commit 044c59a

Browse files
authored
Merge pull request #259 from Alik532UA/alik/ui-improvements
feat: UI/UX Improvements and Optimizations
2 parents ceb27ea + e01f9b8 commit 044c59a

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
{% gtm head %}
55
<meta charset="utf-8">
6+
<meta name="color-scheme" content="dark">
67

78
{% if page.json-ld %}
89
{% for item in site.data.seo[page.json-ld] %}

_sass/base.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ ul, ol { margin-left: 0; }
202202
top: 0;
203203
height: 100%;
204204
width: 70vw;
205-
padding: 5vw 0 0 10vw;
205+
padding: 5vw 5vw 0 5vw;
206206
scroll-snap-align: start;
207207
scroll-snap-stop: always;
208208
z-index: 3;

assets/js/carousel.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ const setCarousel = (scroller) => {
8787
const offsetWidth = target.offsetWidth;
8888

8989
const checkPos = () => {
90-
[...target.children].map(e => {
91-
const toCenter = Math.abs(window.outerWidth / 2 - e.getBoundingClientRect().left - e.getBoundingClientRect().width / 2);
92-
const toCenter2 = window.outerWidth / 2 - e.getBoundingClientRect().left - e.getBoundingClientRect().width / 2;
90+
[...target.children].forEach(e => {
91+
const childRect = e.getBoundingClientRect();
92+
// Optimization: Only process elements currently visible on screen.
93+
if (childRect.right < 0 || childRect.left > window.innerWidth) {
94+
return; // Skip heavy calculations for off-screen elements
95+
}
96+
97+
const toCenter = Math.abs(window.innerWidth / 2 - childRect.left - childRect.width / 2);
98+
const toCenter2 = window.innerWidth / 2 - childRect.left - childRect.width / 2;
9399
const viewport = toCenter / offsetWidth * 100;
94100
const viewport2 = toCenter2 / offsetWidth * 100;
95101
e.style.setProperty('--viewport', viewport);

assets/js/navbar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ function innitMobileNavbar() {
66
const navButton = document.querySelector('.menu-icon');
77
const closeMobileNavButton = document.querySelector('.menu-close-ico')
88
const scroller = document.querySelector('.body-content')
9+
const mainContent = document.querySelector('.body-content__main-section');
10+
11+
mainContent.addEventListener('click', () => {
12+
if (scroller.scrollLeft > 0) {
13+
scroller.scroll({ left: 0, behavior: "smooth" });
14+
}
15+
});
916

1017
closeMobileNavButton.addEventListener('click', () => {
1118
scroller.scroll({ left: 0, behavior: "smooth", });

0 commit comments

Comments
 (0)