toc is scrolling relatively to infinite loading
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<section>
|
<section ref="scrollabletoc">
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="item in toc"
|
v-for="item in toc"
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
:editionid="$route.params.id"
|
:editionid="$route.params.id"
|
||||||
:loadedtextsuuids="loadedtextsuuids"
|
:loadedtextsuuids="loadedtextsuuids"
|
||||||
@onClickTocItem="onClickTocItem"
|
@onClickTocItem="onClickTocItem"
|
||||||
|
@onScrollToRef="onScrollToRef"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -31,11 +32,18 @@ export default {
|
|||||||
loadedtextsuuids: Array
|
loadedtextsuuids: Array
|
||||||
},
|
},
|
||||||
// watch: {
|
// watch: {
|
||||||
// loadedtextsuuids (n, o) {
|
// reftoscrollto: function (newref, oldref) {
|
||||||
// console.log('EdToc watch loadedtxtsuuids', o, n)
|
// console.log('TOC reftoscrollto watcher', oldref, newref)
|
||||||
|
// this.scrollToRef()
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
|
onScrollToRef (uuid) {
|
||||||
|
// console.log('TOC scrollToRef', uuid, this.$refs)
|
||||||
|
this.$scrollTo(`a[uuid="${uuid}"]`, 500, {
|
||||||
|
container: this.$refs.scrollabletoc
|
||||||
|
})
|
||||||
|
},
|
||||||
onClickTocItem (uuid) {
|
onClickTocItem (uuid) {
|
||||||
this.$emit('onClickTocItem', uuid)
|
this.$emit('onClickTocItem', uuid)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
:editionid="editionid"
|
:editionid="editionid"
|
||||||
:loadedtextsuuids="loadedtextsuuids"
|
:loadedtextsuuids="loadedtextsuuids"
|
||||||
@onClickTocItem="onClickTocItem"
|
@onClickTocItem="onClickTocItem"
|
||||||
|
@onScrollToRef="onScrollToRef"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -94,11 +95,15 @@ export default {
|
|||||||
loadedtextsuuids (n, o) {
|
loadedtextsuuids (n, o) {
|
||||||
// console.log('EdTocItem watch loadedtxtsuuids', o, n)
|
// console.log('EdTocItem watch loadedtxtsuuids', o, n)
|
||||||
this.isOpened = this.loadedtextsuuids.some(e => e.indexOf(this.item.uuid) >= 0)
|
this.isOpened = this.loadedtextsuuids.some(e => e.indexOf(this.item.uuid) >= 0)
|
||||||
|
},
|
||||||
|
isOpened (n, o) {
|
||||||
|
// console.log('TocItem watch isOpened', o, n)
|
||||||
|
// if was closed and is opened
|
||||||
|
if (!o && n) {
|
||||||
|
this.onOpened()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// beforeCreate () {
|
|
||||||
// console.log('editionid', this.editionid)
|
|
||||||
// },
|
|
||||||
beforeMount () {
|
beforeMount () {
|
||||||
if (typeof this.$route.params.textid !== 'undefined') {
|
if (typeof this.$route.params.textid !== 'undefined') {
|
||||||
this.isOpened = this.$route.params.textid.indexOf(this.item.uuid) >= 0
|
this.isOpened = this.$route.params.textid.indexOf(this.item.uuid) >= 0
|
||||||
@@ -106,21 +111,19 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onclick (e) {
|
onclick (e) {
|
||||||
console.log('clicked on toc text', this.editionid, e)
|
// console.log('clicked on toc text', this.editionid, e)
|
||||||
// if (this.$route.params.textid !== e.target.getAttribute('uuid')) {
|
|
||||||
// this.$router.push({
|
|
||||||
// name: `editiontext`,
|
|
||||||
// params: {
|
|
||||||
// id: this.editionid,
|
|
||||||
// textid: e.target.getAttribute('uuid')
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
this.$emit('onClickTocItem', e.target.getAttribute('uuid'))
|
this.$emit('onClickTocItem', e.target.getAttribute('uuid'))
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
onClickTocItem (uuid) {
|
onClickTocItem (uuid) {
|
||||||
|
// pass the event to parent
|
||||||
this.$emit('onClickTocItem', uuid)
|
this.$emit('onClickTocItem', uuid)
|
||||||
|
},
|
||||||
|
onOpened () {
|
||||||
|
this.$emit('onScrollToRef', this.item.uuid)
|
||||||
|
},
|
||||||
|
onScrollToRef (uuid) {
|
||||||
|
// pass the event to parent
|
||||||
|
this.$emit('onScrollToRef', uuid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
reftoscrollto: function (newref, oldref) {
|
reftoscrollto: function (newref, oldref) {
|
||||||
console.log('reftoscrollto watcher', oldref, newref)
|
console.log('MainLayout reftoscrollto watcher', oldref, newref)
|
||||||
this.scrollToRef()
|
this.scrollToRef()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user