MainContentLayout.vue 1.3 KB

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