I am looking to make a change in the Navbar position by moving it right: -500px (to close the navbar) when clicking anywhere on the window. In HTML and JS, I can achieve this by targeting the body tag. How can I accomplish this in Vue? I already have functions for opening and closing the navbar with buttons. However, I want to add an extra feature that allows hiding the Navbar by clicking anywhere on the screen. Below is my code snippet:
<div class="chatbot-whole-wrap">
<PopUpMsg class="pop-up-chat" />
<div class="chat-bot-wrapper">
<input id="open" type="checkbox" />
<img id="chat-btn" alt="chat-icon" src="@/assets/chat-bot-bee-icon.svg" @click="openWindow()" />
<div id="sidebar">
<img id="chat-close-btn" alt="chat-icon" src="@/assets/close-icon.svg" @click="closeWindow()" />
<iframe class="chat-bot-iframe" src="https://hggsbnjsggxvbxjkksb/" width="100%" height="100%"></iframe>
</div>
</div>
</div>
What I have done with two methods:
methods: {
openWindow() {
document.getElementById('sidebar').style.right = '0';
},
closeWindow() {
document.getElementById('sidebar').style.right = '-500px';
},
},