forked from tleunen/react-mdl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout-patch.diff
More file actions
178 lines (157 loc) · 5.13 KB
/
layout-patch.diff
File metadata and controls
178 lines (157 loc) · 5.13 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
From 66e3be5dfe73119dbccd2e8d56969d214da2e1ca Mon Sep 17 00:00:00 2001
From: Tommy Leunen <tommy.leunen+github@gmail.com>
Date: Sat, 6 Feb 2016 11:59:55 -0500
Subject: [PATCH] updates Layout so mdl-layout is the root element (fixes
#1356)
---
src/layout/_layout.scss | 36 ++++++++++++++++++------------------
src/layout/layout.js | 17 +++++++++--------
2 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/src/layout/_layout.scss b/src/layout/_layout.scss
index de8fc0c..4ca5645 100644
--- a/src/layout/_layout.scss
+++ b/src/layout/_layout.scss
@@ -39,14 +39,9 @@
// Main layout class.
.mdl-layout {
+ position: absolute;
width: 100%;
height: 100%;
- display: flex;
- flex-direction: column;
- overflow-y: auto;
- overflow-x: hidden;
- position: relative;
- -webkit-overflow-scrolling: touch;
}
// Utility classes for screen sizes.
@@ -58,10 +53,15 @@
display: none;
}
-.mdl-layout__container {
- position: absolute;
+.mdl-layout__inner-container {
width: 100%;
height: 100%;
+ display: flex;
+ flex-direction: column;
+ overflow-y: auto;
+ overflow-x: hidden;
+ position: relative;
+ -webkit-overflow-scrolling: touch;
}
@@ -166,7 +166,7 @@
}
@media screen and (min-width: $layout-screen-size-threshold + 1px) {
- .mdl-layout--fixed-drawer > & {
+ .mdl-layout--fixed-drawer > .mdl-layout__inner-container > & {
transform: translateX(0);
}
}
@@ -214,7 +214,7 @@
}
@media screen and (min-width: $layout-screen-size-threshold + 1px) {
- .mdl-layout--fixed-drawer > & {
+ .mdl-layout--fixed-drawer > .mdl-layout__inner-container > & {
display: none;
}
@@ -255,13 +255,13 @@
min-height: $layout-mobile-header-height;
}
- .mdl-layout--fixed-drawer.is-upgraded:not(.is-small-screen) > & {
+ .mdl-layout--fixed-drawer.is-upgraded:not(.is-small-screen) > .mdl-layout__inner-container > & {
margin-left: $layout-drawer-width;
width: calc(100% - #{$layout-drawer-width});
}
@media screen and (min-width: $layout-screen-size-threshold + 1px) {
- .mdl-layout--fixed-drawer > & {
+ .mdl-layout--fixed-drawer > .mdl-layout__inner-container > & {
.mdl-layout__header-row {
padding-left: 40px;
}
@@ -309,7 +309,7 @@
display: none;
}
- .mdl-layout--fixed-header > & {
+ .mdl-layout--fixed-header > .mdl-layout__inner-container > & {
display: flex;
}
}
@@ -450,20 +450,20 @@
z-index: 1;
-webkit-overflow-scrolling: touch;
- .mdl-layout--fixed-drawer > & {
+ .mdl-layout--fixed-drawer > .mdl-layout__inner-container > & {
margin-left: $layout-drawer-width;
}
- .mdl-layout__container.has-scrolling-header & {
+ .mdl-layout.has-scrolling-header & {
overflow: visible;
}
@media screen and (max-width: $layout-screen-size-threshold) {
- .mdl-layout--fixed-drawer > & {
+ .mdl-layout--fixed-drawer > .mdl-layout__inner-container > & {
margin-left: 0;
}
- .mdl-layout__container.has-scrolling-header & {
+ .mdl-layout.has-scrolling-header & {
overflow-y: auto;
overflow-x: hidden;
}
@@ -532,7 +532,7 @@
flex-shrink: 0;
overflow: hidden;
- .mdl-layout__container > & {
+ .mdl-layout > .mdl-layout__inner-container > & {
position: absolute;
top: 0;
left: 0;
diff --git a/src/layout/layout.js b/src/layout/layout.js
index e3030a4..c31c8dd 100644
--- a/src/layout/layout.js
+++ b/src/layout/layout.js
@@ -83,7 +83,7 @@
* @private
*/
MaterialLayout.prototype.CssClasses_ = {
- CONTAINER: 'mdl-layout__container',
+ INNER_CONTAINER: 'mdl-layout__inner-container',
HEADER: 'mdl-layout__header',
DRAWER: 'mdl-layout__drawer',
CONTENT: 'mdl-layout__content',
@@ -278,12 +278,6 @@
*/
MaterialLayout.prototype.init = function() {
if (this.element_) {
- var container = document.createElement('div');
- container.classList.add(this.CssClasses_.CONTAINER);
- this.element_.parentElement.insertBefore(container, this.element_);
- this.element_.parentElement.removeChild(this.element_);
- container.appendChild(this.element_);
-
var directChildren = this.element_.childNodes;
var numChildren = directChildren.length;
for (var c = 0; c < numChildren; c++) {
@@ -333,7 +327,7 @@
} else if (this.header_.classList.contains(
this.CssClasses_.HEADER_SCROLL)) {
mode = this.Mode_.SCROLL;
- container.classList.add(this.CssClasses_.HAS_SCROLLING_HEADER);
+ this.element_.classList.add(this.CssClasses_.HAS_SCROLLING_HEADER);
}
if (mode === this.Mode_.STANDARD) {
@@ -486,6 +480,13 @@
}
}
+ var innerContainer = document.createElement('div');
+ innerContainer.classList.add(this.CssClasses_.INNER_CONTAINER);
+ while (this.element_.firstChild) {
+ innerContainer.appendChild(this.element_.firstChild);
+ }
+ this.element_.appendChild(innerContainer);
+
this.element_.classList.add(this.CssClasses_.IS_UPGRADED);
}
};
--
2.2.1