1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 13:26:08 +03:00

Added anchors for category items

This commit is contained in:
zeot 2019-02-15 15:52:31 +04:00
parent c5c9629ecb
commit c2dd7f23dc
3 changed files with 20 additions and 4 deletions

View File

@ -13,13 +13,19 @@
@click.stop="" @click.stop=""
> >
<v-toolbar-title class="headline"> <v-toolbar-title class="headline">
<!-- TODO change markup formatting after resolving issue with extra spaces
(if closing tag on another line vue-template-compiler adds extra space) -->
<router-link
:to="{path: $route.path, hash:`item-${itemUid}`}"
:id="`item-${itemUid}`"
class="category-item-anchor"
>#</router-link>
<a-link <a-link
v-if="itemLink" v-if="itemLink"
:url="itemLink" :url="itemLink"
openInNewTab openInNewTab
> >
{{ itemName }} {{ itemName }}</a-link>
</a-link>
<span v-else> {{ itemName }} </span> <span v-else> {{ itemName }} </span>
</v-toolbar-title> </v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
@ -162,6 +168,9 @@ export default class CategoryItemToolbar extends Vue {
</script> </script>
<style scoped> <style scoped>
.category-item-anchor {
color: rgb(151, 151, 151);
}
.edit-item-info-changed-icon { .edit-item-info-changed-icon {
position: absolute; position: absolute;
bottom: 0; bottom: 0;

View File

@ -20,6 +20,12 @@ router.onReady(() => {
function registerBeforeResolve () { function registerBeforeResolve () {
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
// This case handles navigation to anchors on same page
if (to.path === from.path) {
next()
return
}
store.commit('tooglePageLoading') store.commit('tooglePageLoading')
if (!to.matched.length) { if (!to.matched.length) {
store.commit('tooglePageLoading') store.commit('tooglePageLoading')

View File

@ -6,11 +6,12 @@ function createRouter () {
fallback: false, fallback: false,
// TODO update vue-router when scroll issue will be fixed // TODO update vue-router when scroll issue will be fixed
// https://github.com/vuejs/vue-router/issues/2095 // https://github.com/vuejs/vue-router/issues/2095
scrollBehavior: (to, from, savedPosition) => { // https://github.com/vuejs/vue-router/issues/1668
scrollBehavior (to, from, savedPosition) {
if (savedPosition) { if (savedPosition) {
return savedPosition return savedPosition
} else if (to.hash) { } else if (to.hash) {
return { selector: to.hash } return { selector: to.hash, offset: { y: 96, x: 0 } }
} else { } else {
return { x: 0, y: 0 } return { x: 0, y: 0 }
} }