MainContentLayout.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ref="scrollablecenter" class="med-col-6 large-col-6" @scroll.passive="onScrollCenter">
  10. <slot />
  11. </section>
  12. <nav class="med-col-3 large-col-3" :class="{ opened: navopened }">
  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. navopened: { type: Boolean }
  27. },
  28. watch: {
  29. reftoscrollto: function (newref, oldref) {
  30. console.log('MainLayout reftoscrollto watcher', oldref, newref)
  31. this.scrollToRef()
  32. }
  33. },
  34. methods: {
  35. onScrollCenter (e) {
  36. // console.log('mainLayout onScrollCenter: e', e)
  37. this.$emit('onCenterScrolled', e)
  38. },
  39. scrollToRef () {
  40. console.log('scrollToRef', this.reftoscrollto, this.$refs)
  41. this.$scrollTo(this.reftoscrollto, 500, {
  42. container: this.$refs.scrollablecenter
  43. })
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="scss" scoped>
  49. </style>