In component demo1/src/layouts/main-layout/sidebar/SidebarLogo.vue.
ref="toggleRef"
props: {
sidebarRef: {
type: Object as PropType<HTMLElement | null>,
required: true,
},
},
const toggleRef = ref<HTMLFormElement | null>(null);
onMounted(() => {
setTimeout(() => {
const toggleObj = ToggleComponent.getInstance(
toggleRef.value!
) as ToggleComponent | null;
if (toggleObj === null) {
return;
}
// Add a class to prevent sidebar hover effect after toggle click
toggleObj.on("kt.toggle.change", function () {
// Set animation state
props.sidebarRef?.classList.add("animating");
// Wait till animation finishes
setTimeout(function () {
// Remove animation state
props.sidebarRef?.classList.remove("animating");
}, 300);
});
}, 1);
});
return {
toggleRef,
...
};
ref="sidebarRef"
on sidebar element (element with id kt_app_sidebar).const sidebarRef = ref<HTMLFormElement | null>(null);
return {
sidebarRef
...
}
<KTSidebarLogo :sidebar-ref="sidebarRef"></KTSidebarLogo>