MainContentLayout.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div
  3. :id="id"
  4. class="full-width row main-content-layout"
  5. >
  6. <header class="col-3">
  7. <slot name="header" />
  8. </header>
  9. <section ref="scrollablecenter" class="col-6" @scroll.passive="onScrollCenter">
  10. <slot />
  11. </section>
  12. <nav class="col-3">
  13. <slot name="nav" />
  14. </nav>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'MainContentLayout',
  20. props: {
  21. id: {
  22. type: String,
  23. required: true
  24. },
  25. reftoscrollto: { type: String }
  26. },
  27. watch: {
  28. reftoscrollto: function (newref, oldref) {
  29. console.log('reftoscrollto watcher', oldref, newref)
  30. this.scrollToRef()
  31. }
  32. },
  33. methods: {
  34. onScrollCenter (e) {
  35. // console.log('mainLayout onScrollCenter: e', e)
  36. this.$emit('onCenterScrolled', e)
  37. },
  38. scrollToRef () {
  39. console.log('scrollToRef', this.reftoscrollto, this.$refs)
  40. this.$scrollTo(this.reftoscrollto, 500, {
  41. container: this.$refs.scrollablecenter
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. </style>