0

today my problem is that I couldn't hide my offcanvas when used with a setTimeout function.

/* Main scripts */
window.addEventListener("DOMContentLoaded", () => {
        const offcanvas = document.getElementById('offcanvasMenu')
        setTimeout(() => {
            offcanvas.classList.toggle('show')
        }, 500)
    }
);```

I've allready set up my offcanvas and it works. But when the close button is clicked the first time, nothing happen :

[Bug Offcanvas](https://i.stack.imgur.com/JWBhg.gif)

My set up is good. But I think I'm misunderstanding the events passed because I'm still a bit noob at JS.
I tried to put the showing event before the show event, but I think I'm wrong. Could someone had to face this problem ? I would be glad if somebody asks for this, because i'm stuck since two hours...

(sorry for my English, i'm french)

0 Answers0