forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQLayout.js
More file actions
113 lines (110 loc) · 2.31 KB
/
QLayout.js
File metadata and controls
113 lines (110 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { QScrollObservable, QResizeObservable, QWindowResizeObservable } from '../observables'
export default {
name: 'QLayout',
provide () {
return {
layout: this
}
},
props: {
view: {
type: String,
default: 'hhh lpr fff',
validator: v => /^(h|l)h(h|r) lpr (f|l)f(f|r)$/.test(v.toLowerCase())
}
},
data () {
return {
height: window.innerHeight,
width: window.innerWidth,
header: {
size: 0,
offset: 0,
space: false
},
right: {
size: 300,
offset: 0,
space: false
},
footer: {
size: 0,
offset: 0,
space: false
},
left: {
size: 300,
offset: 0,
space: false
},
scrollHeight: 0,
scroll: {
position: 0,
direction: 'down'
}
}
},
computed: {
rows () {
const rows = this.view.toLowerCase().split(' ')
return {
top: rows[0].split(''),
middle: rows[1].split(''),
bottom: rows[2].split('')
}
}
},
created () {
this.instances = {
header: null,
right: null,
footer: null,
left: null
}
},
render (h) {
return h('div', { staticClass: 'q-layout' }, [
h(QScrollObservable, {
on: { scroll: this.__onPageScroll }
}),
h(QResizeObservable, {
on: { resize: this.__onLayoutResize }
}),
h(QWindowResizeObservable, {
on: { resize: this.__onWindowResize }
}),
this.$slots.default
])
},
methods: {
__animate () {
if (this.timer) {
clearTimeout(this.timer)
}
else {
document.body.classList.add('q-layout-animate')
}
this.timer = setTimeout(() => {
document.body.classList.remove('q-layout-animate')
this.timer = null
}, 150)
},
__onPageScroll (data) {
this.scroll = data
this.$emit('scroll', data)
},
__onLayoutResize () {
this.scrollHeight = this.$el.scrollHeight
this.$emit('scrollHeight', this.scrollHeight)
},
__onWindowResize ({ height, width }) {
if (this.height !== height) {
this.height = height
}
if (this.width !== width) {
this.width = width
}
this.$emit('resize', { height, width })
}
}
}