Skip to content

Commit fd39666

Browse files
committed
fix(QLayout): Containerized -- fixing scrollbar
1 parent 3cc189d commit fd39666

File tree

5 files changed

+60
-17
lines changed

5 files changed

+60
-17
lines changed

dev/components/components/layout-container.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<q-toolbar>
88
<q-btn flat @click="drawer = !drawer" round dense icon="menu" />
99
<q-toolbar-title>Header</q-toolbar-title>
10+
<q-btn flat @click="drawer = !drawer" round dense icon="menu" />
1011
</q-toolbar>
1112
</q-layout-header>
1213

@@ -21,7 +22,7 @@
2122
<div v-for="n in 50" :key="n">Drawer</div>
2223
</q-layout-drawer>
2324
<q-page-container>
24-
<q-page style="padding-top: 50px">
25+
<q-page style="padding-top: 50px" class="bg-yellow">
2526
<div v-for="n in 50" :key="n">My page My page My page My page My page My page My page My page My page</div>
2627

2728
<q-page-sticky position="top-left" :offset="[18, 58]">
@@ -69,7 +70,7 @@
6970
</q-layout-drawer>
7071

7172
<q-page-container>
72-
<q-page style="padding-top: 50px">
73+
<q-page style="padding-top: 50px" class="bg-yellow">
7374
<div v-for="n in 50" :key="n">My page</div>
7475

7576
<q-page-sticky position="top-left" :offset="[18, 58]">

src/components/layout/QLayout.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import QScrollObservable from '../observables/QScrollObservable.js'
22
import QResizeObservable from '../observables/QResizeObservable.js'
33
import { onSSR } from '../../plugins/platform.js'
4+
import { getScrollbarWidth } from 'utils/scroll.js'
45

56
export default {
67
name: 'QLayout',
@@ -19,6 +20,7 @@ export default {
1920
},
2021
data () {
2122
return {
23+
// page related
2224
height: onSSR ? 0 : window.innerHeight,
2325
width: onSSR ? 0 : window.innerWidth,
2426

@@ -60,6 +62,27 @@ export default {
6062
middle: rows[1].split(''),
6163
bottom: rows[2].split('')
6264
}
65+
},
66+
67+
// used by container only
68+
scrollbarWidth () {
69+
return this.height > this.containerHeight
70+
? getScrollbarWidth()
71+
: 0
72+
},
73+
targetStyle () {
74+
if (this.scrollbarWidth !== 0) {
75+
return { [this.$q.i18n.rtl ? 'left' : 'right']: `${this.scrollbarWidth}px` }
76+
}
77+
},
78+
targetChildStyle () {
79+
if (this.scrollbarWidth !== 0) {
80+
return {
81+
[this.$q.i18n.rtl ? 'right' : 'left']: 0,
82+
[this.$q.i18n.rtl ? 'left' : 'right']: `-${this.scrollbarWidth}px`,
83+
width: `calc(100% + ${this.scrollbarWidth}px)`
84+
}
85+
}
6386
}
6487
},
6588
created () {
@@ -76,22 +99,27 @@ export default {
7699
on: { scroll: this.__onPageScroll }
77100
}),
78101
h(QResizeObservable, {
79-
on: { resize: this.__onLayoutResize }
102+
on: { resize: this.__onPageResize }
80103
}),
81104
this.$slots.default
82105
])
83106

84107
return this.container
85108
? h('div', {
86-
staticClass: 'relative-position overflow-hidden q-layout-container'
109+
staticClass: 'q-layout-container relative-position overflow-hidden'
87110
}, [
88111
h(QResizeObservable, {
89112
on: { resize: this.__onContainerResize }
90113
}),
91114
h('div', {
92-
ref: 'content',
93-
staticClass: 'fullscreen overflow-auto z-inherit'
94-
}, [ layout ])
115+
staticClass: 'absolute-full',
116+
style: this.targetStyle
117+
}, [
118+
h('div', {
119+
staticClass: 'overflow-auto',
120+
style: this.targetChildStyle
121+
}, [ layout ])
122+
])
95123
])
96124
: layout
97125
},
@@ -112,7 +140,7 @@ export default {
112140
this.scroll = data
113141
this.$emit('scroll', data)
114142
},
115-
__onLayoutResize ({ height, width }) {
143+
__onPageResize ({ height, width }) {
116144
let resized = false
117145

118146
if (this.height !== height) {

src/components/layout/QPage.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ export default {
1818
(this.layout.header.space ? this.layout.header.size : 0) +
1919
(this.layout.footer.space ? this.layout.footer.size : 0)
2020

21-
return typeof this.styleFn === 'function'
22-
? this.styleFn(offset)
23-
: { minHeight: offset ? `calc(100vh - ${offset}px)` : '100vh' }
21+
if (typeof this.styleFn === 'function') {
22+
return this.styleFn(offset)
23+
}
24+
25+
const minHeight = this.layout.container
26+
? (this.layout.containerHeight - offset) + 'px'
27+
: (offset ? `calc(100vh - ${offset}px)` : `100vh`)
28+
29+
return { minHeight }
2430
},
2531
classes () {
2632
if (this.padding) {

src/components/layout/layout.ios.styl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ $layout-transition = all .12s ease-in
55
min-height 100vh
66

77
.q-layout-container
8-
transform translate3d(0, 0, 0)
98
.q-layout
10-
min-height 0
9+
min-height 100%
10+
> div
11+
transform translate3d(0, 0, 0)
12+
> div
13+
min-height 0
14+
max-height 100%
1115

1216
.q-layout-header
1317
border-bottom $layout-border
@@ -69,7 +73,7 @@ $layout-transition = all .12s ease-in
6973

7074
.q-layout-drawer-opener
7175
z-index ($z-marginals + 1)
72-
height 100vh
76+
height 100%
7377
width 15px
7478

7579
.q-page-sticky-shrink

src/components/layout/layout.mat.styl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ $layout-transition = all .12s ease-in
55
min-height 100vh
66

77
.q-layout-container
8-
transform translate3d(0, 0, 0)
98
.q-layout
10-
min-height 0
9+
min-height 100%
10+
> div
11+
transform translate3d(0, 0, 0)
12+
> div
13+
min-height 0
14+
max-height 100%
1115

1216
.q-layout-header
1317
box-shadow $layout-header-shadow
@@ -67,7 +71,7 @@ $layout-transition = all .12s ease-in
6771

6872
.q-layout-drawer-opener
6973
z-index ($z-marginals + 1)
70-
height 100vh
74+
height 100%
7175
width 15px
7276

7377
.q-page-sticky-shrink

0 commit comments

Comments
 (0)