Implement scroll to settings submenu when it is opened

This commit is contained in:
Angelina Filippova 2021-02-11 02:02:44 +03:00
parent 51de129b54
commit 07bc03f2ef
2 changed files with 10 additions and 1 deletions

View file

@ -12,7 +12,7 @@
</el-menu-item>
</app-link>
</template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)">
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" :id="item.meta.title">
<template slot="title">
<item
v-if="item.meta"

View file

@ -71,6 +71,15 @@ export default {
const routes = this.getMergedRoutes()
this.$store.dispatch('GenerateRoutes', { roles: this.roles, _routesWithSettings: routes })
}
let isRequesting = true
const step = () => {
document.querySelector('#settings').scrollIntoView({ block: 'start', behavior: 'smooth' })
if (isRequesting) requestAnimationFrame(step)
}
requestAnimationFrame(step)
setTimeout(() => {
isRequesting = false
}, 300) // this equals to the hide-timeout of the el-submenu
}
}
}