EdToc.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <section ref="scrollabletoc">
  3. <ul>
  4. <li
  5. v-for="item in toc"
  6. :key="item.uuid"
  7. >
  8. <TocItem
  9. :item="item"
  10. :level="1"
  11. :editionid="$route.params.id"
  12. :loadedtextsuuids="loadedtextsuuids"
  13. :selectedindex="selectedindex"
  14. @onClickTocItem="onClickTocItem"
  15. @onScrollToRef="onScrollToRef"
  16. />
  17. </li>
  18. </ul>
  19. </section>
  20. </template>
  21. <script>
  22. import TocItem from './TocItem'
  23. export default {
  24. name: 'EdToc',
  25. components: {
  26. TocItem
  27. },
  28. props: {
  29. toc: Array,
  30. loadedtextsuuids: Array,
  31. selectedindex: Object
  32. },
  33. // watch: {
  34. // reftoscrollto: function (newref, oldref) {
  35. // console.log('TOC reftoscrollto watcher', oldref, newref)
  36. // this.scrollToRef()
  37. // }
  38. // },
  39. methods: {
  40. onScrollToRef (uuid) {
  41. // console.log('TOC scrollToRef', uuid, this.$refs)
  42. this.$scrollTo(`a[uuid="${uuid}"]`, 500, {
  43. container: this.$refs.scrollabletoc
  44. })
  45. },
  46. onClickTocItem (uuid) {
  47. this.$emit('onClickTocItem', uuid)
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. </style>