From f7adbc09d3ac073c76e9470696539f20dfaec674 Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Sun, 30 Mar 2025 10:01:03 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/1.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index a6fa41a..f15538e 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -246,10 +246,17 @@ window.addEventListener("scroll", () => { /*when the window is reloading or loading*/ window.addEventListener('load', function() { - const targetElement = document.getElementById('container_1'); - targetElement.scrollIntoView(); - const sidebarCheckbox = document.getElementById('sidebar-active'); - if (sidebarCheckbox.checked) {sidebarCheckbox.checked = false;} + requestAnimationFrame(() => { + const targetElement = document.getElementById('container_1'); + if (targetElement) { + targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + }); + + const sidebarCheckbox = document.getElementById('sidebar-active'); + if (sidebarCheckbox && sidebarCheckbox.checked) { + sidebarCheckbox.checked = false; + } });