When i open my menu, and click on link, i scroll to down page with my menu, but when i close menu, I go back to the top of the page.
– Icon that open menu.
<a class="bi-list offcanvas-icon" data-bs-toggle="offcanvas" href="#offcanvasMenu" role="button" aria-controls="offcanvasMenu"></a>
-** Menu**
<div class="offcanvas offcanvas-end" data-bs-scroll="true" tabindex="-1" id="offcanvasMenu" aria-labelledby="offcanvasMenuLabel">
<div class="offcanvas-header">
<button type="button" class="btn-close ms-auto" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body d-flex flex-column justify-content-center align-items-center">
<nav>
<ul>
<li>
<a href="#contacts" >Контакти</a>
</li>
</ul>
</nav>
</div>
</div>
**- section **
`<section class="contact-widget spad" id="contacts">lala </section>`
i TRY this script
`<script type="text/javascript">
let y = window.scrollY;
let offcanvas = document.getElementById('offcanvasMenu');
offcanvas.addEventListener('hidden.bs.offcanvasMenu', (e) => {
window.scrollTo(0, y);
});
</script> `
i try this script
`var myOffcanvas = document.getElementById('offcanvasNav')
myOffcanvas.addEventListener('hide.bs.offcanvas', function (e) {
console.log(e)
//e.preventDefault()
//e.stopPropagation()
})
but nothing to help me.
this problem in `