OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --><html><head><link rel="import" href="../polymer/polymer.html"> | 8 --><html><head><link rel="import" href="../polymer/polymer.html"> |
9 <link rel="import" href="../iron-media-query/iron-media-query.html"> | 9 <link rel="import" href="../iron-media-query/iron-media-query.html"> |
10 <link rel="import" href="../iron-selector/iron-selector.html"> | 10 <link rel="import" href="../iron-selector/iron-selector.html"> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 </paper-header-panel> | 58 </paper-header-panel> |
59 <paper-header-panel main> | 59 <paper-header-panel main> |
60 <paper-toolbar> | 60 <paper-toolbar> |
61 <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button
> | 61 <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button
> |
62 <div>Title</div> | 62 <div>Title</div> |
63 </paper-toolbar> | 63 </paper-toolbar> |
64 <div> Main content... </div> | 64 <div> Main content... </div> |
65 </paper-header-panel> | 65 </paper-header-panel> |
66 </paper-drawer-panel> | 66 </paper-drawer-panel> |
67 | 67 |
68 To position the drawer to the right, add `rightDrawer` attribute. | 68 To position the drawer to the right, add `right-drawer` attribute. |
69 | 69 |
70 <paper-drawer-panel rightDrawer> | 70 <paper-drawer-panel right-drawer> |
71 <div drawer> Drawer panel... </div> | 71 <div drawer> Drawer panel... </div> |
72 <div main> Main panel... </div> | 72 <div main> Main panel... </div> |
73 </paper-drawer-panel> | 73 </paper-drawer-panel> |
74 | 74 |
75 @group Polymer Elements | 75 Styling paper-drawer-panel: |
| 76 |
| 77 To change the main container: |
| 78 paper-drawer-panel { |
| 79 --paper-drawer-panel-main-container: { |
| 80 background-color: gray; |
| 81 }; |
| 82 } |
| 83 |
| 84 To change the drawer container when it's in the left side: |
| 85 paper-drawer-panel { |
| 86 --paper-drawer-panel-left-drawer-container: { |
| 87 background-color: white; |
| 88 }; |
| 89 } |
| 90 |
| 91 To change the drawer container when it's in the right side: |
| 92 |
| 93 paper-drawer-panel { |
| 94 --paper-drawer-panel-right-drawer-container: { |
| 95 background-color: white; |
| 96 }; |
| 97 } |
| 98 |
| 99 @group Paper elements |
76 @element paper-drawer-panel | 100 @element paper-drawer-panel |
77 @homepage github.io | 101 @demo demo/index.html |
| 102 @hero hero.svg |
78 --> | 103 --> |
79 | 104 |
80 </head><body><dom-module id="paper-drawer-panel"> | 105 </head><body><dom-module id="paper-drawer-panel"> |
81 | 106 <link rel="import" type="css" href="paper-drawer-panel.css"> |
82 <style> | |
83 :host { | |
84 display: block; | |
85 position: absolute; | |
86 top: 0; | |
87 left: 0; | |
88 width: 100%; | |
89 height: 100%; | |
90 overflow: hidden; | |
91 } | |
92 | |
93 iron-selector > #drawer { | |
94 position: absolute; | |
95 top: 0; | |
96 left: 0; | |
97 height: 100%; | |
98 will-change: transform; | |
99 box-sizing: border-box; | |
100 -moz-box-sizing: border-box; | |
101 } | |
102 | |
103 .transition > #drawer { | |
104 transition: -webkit-transform ease-in-out 0.3s, width ease-in-out 0.3s; | |
105 transition: transform ease-in-out 0.3s, width ease-in-out 0.3s; | |
106 } | |
107 | |
108 /* | |
109 right-drawer: make drawer on the right side | |
110 */ | |
111 .right-drawer > #drawer { | |
112 left: auto; | |
113 right: 0; | |
114 } | |
115 | |
116 paper-drawer-panel #drawer > * { | |
117 position: absolute; | |
118 top: 0; | |
119 left: 0; | |
120 width: 100%; | |
121 height: 100%; | |
122 box-sizing: border-box; | |
123 -moz-box-sizing: border-box; | |
124 } | |
125 | |
126 iron-selector > #main { | |
127 position: absolute; | |
128 top: 0; | |
129 right: 0; | |
130 bottom: 0; | |
131 } | |
132 | |
133 .transition > #main { | |
134 transition: left ease-in-out 0.3s, padding ease-in-out 0.3s; | |
135 } | |
136 | |
137 .right-drawer > #main { | |
138 left: 0; | |
139 } | |
140 | |
141 .right-drawer.transition > #main { | |
142 transition: right ease-in-out 0.3s, padding ease-in-out 0.3s; | |
143 } | |
144 | |
145 #main > [main] { | |
146 height: 100%; | |
147 } | |
148 | |
149 #scrim { | |
150 position: absolute; | |
151 top: 0; | |
152 right: 0; | |
153 bottom: 0; | |
154 left: 0; | |
155 background-color: rgba(0, 0, 0, 0.3); | |
156 visibility: hidden; | |
157 opacity: 0; | |
158 transition: opacity ease-in-out 0.38s, visibility ease-in-out 0.38s; | |
159 } | |
160 | |
161 #edgeSwipeOverlay { | |
162 position: absolute; | |
163 top: 0; | |
164 bottom: 0; | |
165 left: 0; | |
166 width: 20px; | |
167 } | |
168 | |
169 .right-drawer > #main > #edgeSwipeOverlay { | |
170 right: 0; | |
171 left: auto; | |
172 } | |
173 | |
174 /* | |
175 narrow layout | |
176 */ | |
177 .narrow-layout > #drawer.iron-selected { | |
178 box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.15); | |
179 } | |
180 | |
181 .right-drawer.narrow-layout > #drawer.iron-selected { | |
182 box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.15); | |
183 } | |
184 | |
185 .narrow-layout > #drawer > ::content[select="[drawer]"] > * { | |
186 border: 0; | |
187 } | |
188 | |
189 .narrow-layout > #drawer:not(.iron-selected) { | |
190 -webkit-transform: translateX(-100%); | |
191 transform: translateX(-100%); | |
192 } | |
193 | |
194 .right-drawer.narrow-layout > #drawer:not(.iron-selected) { | |
195 left: auto; | |
196 -webkit-transform: translateX(100%); | |
197 transform: translateX(100%); | |
198 } | |
199 | |
200 .narrow-layout > #main { | |
201 left: 0 !important; | |
202 padding: 0; | |
203 } | |
204 | |
205 .right-drawer.narrow-layout > #main { | |
206 left: 0; | |
207 right: 0; | |
208 padding: 0; | |
209 } | |
210 | |
211 .narrow-layout > #main:not(.iron-selected) > #scrim, | |
212 .dragging #scrim { | |
213 visibility: visible; | |
214 opacity: 1; | |
215 } | |
216 | |
217 .narrow-layout > #main > * { | |
218 margin: 0; | |
219 min-height: 100%; | |
220 left: 0; | |
221 right: 0; | |
222 box-sizing: border-box; | |
223 -moz-box-sizing: border-box; | |
224 } | |
225 | |
226 iron-selector:not(.narrow-layout) #main ::content [paper-drawer-toggle] { | |
227 display: none; | |
228 } | |
229 </style> | |
230 | 107 |
231 <template> | 108 <template> |
232 <iron-media-query on-query-matches-changed="onQueryMatchesChanged" query="[[
_computeMediaQuery(forceNarrow, responsiveWidth)]]"> | 109 <iron-media-query id="mq" on-query-matches-changed="_onQueryMatchesChanged"
query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]"> |
233 </iron-media-query> | 110 </iron-media-query> |
234 | 111 |
235 <iron-selector attr-for-selected="id" class$="[[_computeIronSelectorClass(na
rrow, transition, dragging, rightDrawer)]]" activate-event="" selected="[[select
ed]]"> | 112 <iron-selector attr-for-selected="id" class$="[[_computeIronSelectorClass(na
rrow, transition, dragging, rightDrawer)]]" activate-event="" selected="[[select
ed]]"> |
236 | 113 |
237 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt
h)]]"> | 114 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt
h)]]"> |
238 <content select="[main]"></content> | 115 <content select="[main]"></content> |
239 <div id="scrim" on-tap="closeDrawer"></div> | 116 <div id="scrim" on-tap="closeDrawer"></div> |
240 <div id="edgeSwipeOverlay" hidden$="[[_computeSwipeOverlayHidden(narrow,
disableEdgeSwipe)]]"> | |
241 </div> | |
242 </div> | 117 </div> |
243 | 118 |
244 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> | 119 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> |
245 <content select="[drawer]"></content> | 120 <content select="[drawer]"></content> |
246 </div> | 121 </div> |
247 | 122 |
248 </iron-selector> | 123 </iron-selector> |
249 </template> | 124 </template> |
250 | 125 |
251 </dom-module> | 126 </dom-module> |
252 | 127 |
253 <script src="paper-drawer-panel-extracted.js"></script></body></html> | 128 <script src="paper-drawer-panel-extracted.js"></script></body></html> |
OLD | NEW |