fix contacty
All checks were successful
ci/cd / Build (push) Successful in 6s

This commit is contained in:
Mariia Shabelnik 2025-05-05 20:57:53 +02:00
parent 11a432a2c1
commit 8e241cc6e9

View File

@ -9,10 +9,17 @@ function ScrollToAnchor() {
// https://jasonwatmore.com/react-router-v6-listen-to-location-route-change-without-history-listen // https://jasonwatmore.com/react-router-v6-listen-to-location-route-change-without-history-listen
useEffect(() => { useEffect(() => {
if (location.hash) { if (location.hash) {
lastHash.current = location.hash.slice(1); // safe hash for further use after navigation lastHash.current = location.hash.slice(1);
} }
if (lastHash.current && document.getElementById(lastHash.current)) { if (lastHash.current === "contact") {
// Scroll to bottom of the page
window.scrollTo({
top: document.documentElement.scrollHeight,
behavior: "smooth"
});
lastHash.current = "";
} else if (lastHash.current && document.getElementById(lastHash.current)) {
setTimeout(() => { setTimeout(() => {
document document
.getElementById(lastHash.current) .getElementById(lastHash.current)