MainContentLayout.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. methods: {
  43. onScrollCenter (e) {
  44. // console.log('mainLayout onScrollCenter: e', e)
  45. this.$emit('onCenterScrolled', e)
  46. },
  47. scrollToRef () {
  48. console.log('scrollToRef', this.reftoscrollto, this.$refs)
  49. this.$scrollTo(this.reftoscrollto, 500, {
  50. container: this.$refs.scrollablecenter
  51. })
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. </style>