OLD | NEW |
(Empty) | |
| 1 <!-- |
| 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 |
| 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 |
| 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 |
| 8 --><html><head><link rel="import" href="../polymer/polymer.html"> |
| 9 <link rel="import" href="../iron-media-query/iron-media-query.html"> |
| 10 <link rel="import" href="../iron-selector/iron-selector.html"> |
| 11 |
| 12 <!-- |
| 13 `paper-drawer-panel` contains a drawer panel and a main panel. The drawer |
| 14 and the main panel are side-by-side with drawer on the left. When the browser |
| 15 window size is smaller than the `responsiveWidth`, `paper-drawer-panel` |
| 16 changes to narrow layout. In narrow layout, the drawer will be stacked on top |
| 17 of the main panel. The drawer will slide in/out to hide/reveal the main |
| 18 panel. |
| 19 |
| 20 Use the attribute `drawer` to indicate that the element is the drawer panel and |
| 21 `main` to indicate that the element is the main panel. |
| 22 |
| 23 Example: |
| 24 |
| 25 <paper-drawer-panel> |
| 26 <div drawer> Drawer panel... </div> |
| 27 <div main> Main panel... </div> |
| 28 </paper-drawer-panel> |
| 29 |
| 30 The drawer and the main panels are not scrollable. You can set CSS overflow |
| 31 property on the elements to make them scrollable or use `paper-header-panel`. |
| 32 |
| 33 Example: |
| 34 |
| 35 <paper-drawer-panel> |
| 36 <paper-header-panel drawer> |
| 37 <paper-toolbar></paper-toolbar> |
| 38 <div> Drawer content... </div> |
| 39 </paper-header-panel> |
| 40 <paper-header-panel main> |
| 41 <paper-toolbar></paper-toolbar> |
| 42 <div> Main content... </div> |
| 43 </paper-header-panel> |
| 44 </paper-drawer-panel> |
| 45 |
| 46 An element that should toggle the drawer will automatically do so if it's |
| 47 given the `paper-drawer-toggle` attribute. Also this element will automatically |
| 48 be hidden in wide layout. |
| 49 |
| 50 Example: |
| 51 |
| 52 <paper-drawer-panel> |
| 53 <paper-header-panel drawer> |
| 54 <paper-toolbar> |
| 55 <div>Application</div> |
| 56 </paper-toolbar> |
| 57 <div> Drawer content... </div> |
| 58 </paper-header-panel> |
| 59 <paper-header-panel main> |
| 60 <paper-toolbar> |
| 61 <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button
> |
| 62 <div>Title</div> |
| 63 </paper-toolbar> |
| 64 <div> Main content... </div> |
| 65 </paper-header-panel> |
| 66 </paper-drawer-panel> |
| 67 |
| 68 To position the drawer to the right, add `rightDrawer` attribute. |
| 69 |
| 70 <paper-drawer-panel rightDrawer> |
| 71 <div drawer> Drawer panel... </div> |
| 72 <div main> Main panel... </div> |
| 73 </paper-drawer-panel> |
| 74 |
| 75 @group Polymer Elements |
| 76 @element paper-drawer-panel |
| 77 @homepage github.io |
| 78 --> |
| 79 |
| 80 </head><body><dom-module id="paper-drawer-panel"> |
| 81 |
| 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 |
| 231 <template> |
| 232 <iron-media-query on-query-matches-changed="onQueryMatchesChanged" query="[[
_computeMediaQuery(forceNarrow, responsiveWidth)]]"> |
| 233 </iron-media-query> |
| 234 |
| 235 <iron-selector attr-for-selected="id" class$="[[_computeIronSelectorClass(na
rrow, transition, dragging, rightDrawer)]]" on-iron-activate="onSelect" selected
="[[selected]]"> |
| 236 |
| 237 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt
h)]]"> |
| 238 <content select="[main]"></content> |
| 239 <div id="scrim"></div> |
| 240 <div id="edgeSwipeOverlay" hidden$="[[_computeSwipeOverlayHidden(narrow,
disableEdgeSwipe)]]"> |
| 241 </div> |
| 242 </div> |
| 243 |
| 244 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> |
| 245 <content select="[drawer]"></content> |
| 246 </div> |
| 247 |
| 248 </iron-selector> |
| 249 </template> |
| 250 |
| 251 </dom-module> |
| 252 |
| 253 <script src="paper-drawer-panel-extracted.js"></script></body></html> |
OLD | NEW |