Navbar Scroll Fixed
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
<a
|
<a
|
||||||
:href="item.href"
|
:href="item.href"
|
||||||
class="block text-white hover:text-primary ease-linear text-2xl md:text-lg"
|
class="block text-white hover:text-primary ease-linear text-2xl md:text-lg"
|
||||||
@click2="scrollToSection(item.href)"
|
@click="scrollToSection(item.href)"
|
||||||
>
|
>
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</a>
|
</a>
|
||||||
@@ -58,7 +58,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref, watch } from "vue";
|
||||||
|
|
||||||
|
const isMenuOpen = ref(false);
|
||||||
|
|
||||||
const Menu = ref([
|
const Menu = ref([
|
||||||
{ name: "Services", href: "#services" },
|
{ name: "Services", href: "#services" },
|
||||||
@@ -69,7 +71,16 @@ const Menu = ref([
|
|||||||
{ name: "Contact", href: "#contact" },
|
{ name: "Contact", href: "#contact" },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const isMenuOpen = ref(false);
|
watch(isMenuOpen, (open) => {
|
||||||
|
if (open) {
|
||||||
|
// Disable scrolling
|
||||||
|
document.body.style.overflow = "hidden";
|
||||||
|
} else {
|
||||||
|
// Re-enable scrolling
|
||||||
|
document.body.style.overflow = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const scrollToSection = (href) => {
|
const scrollToSection = (href) => {
|
||||||
isMenuOpen.value = false;
|
isMenuOpen.value = false;
|
||||||
const section = document.querySelector(href);
|
const section = document.querySelector(href);
|
||||||
|
|||||||
Reference in New Issue
Block a user