Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/polymer/v0_8/components/paper-drawer-panel/paper-drawer-panel.html

Issue 1162563004: Upgrade to 1.0 and switch clients to dom-repeat where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a layout import and remove the gzipped webanimation in reproduce.sh Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 --> 8 -->
9 9
10 <link rel="import" href="../polymer/polymer.html"> 10 <link rel="import" href="../polymer/polymer.html">
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 </paper-header-panel> 60 </paper-header-panel>
61 <paper-header-panel main> 61 <paper-header-panel main>
62 <paper-toolbar> 62 <paper-toolbar>
63 <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button > 63 <paper-icon-button icon="menu" paper-drawer-toggle></paper-icon-button >
64 <div>Title</div> 64 <div>Title</div>
65 </paper-toolbar> 65 </paper-toolbar>
66 <div> Main content... </div> 66 <div> Main content... </div>
67 </paper-header-panel> 67 </paper-header-panel>
68 </paper-drawer-panel> 68 </paper-drawer-panel>
69 69
70 To position the drawer to the right, add `rightDrawer` attribute. 70 To position the drawer to the right, add `right-drawer` attribute.
71 71
72 <paper-drawer-panel rightDrawer> 72 <paper-drawer-panel right-drawer>
73 <div drawer> Drawer panel... </div> 73 <div drawer> Drawer panel... </div>
74 <div main> Main panel... </div> 74 <div main> Main panel... </div>
75 </paper-drawer-panel> 75 </paper-drawer-panel>
76 76
77 @group Polymer Elements 77 Styling paper-drawer-panel:
78
79 To change the main container:
80 paper-drawer-panel {
81 --paper-drawer-panel-main-container: {
82 background-color: gray;
83 };
84 }
85
86 To change the drawer container when it's in the left side:
87 paper-drawer-panel {
88 --paper-drawer-panel-left-drawer-container: {
89 background-color: white;
90 };
91 }
92
93 To change the drawer container when it's in the right side:
94
95 paper-drawer-panel {
96 --paper-drawer-panel-right-drawer-container: {
97 background-color: white;
98 };
99 }
100
101 @group Paper elements
78 @element paper-drawer-panel 102 @element paper-drawer-panel
79 @homepage github.io 103 @demo demo/index.html
104 @hero hero.svg
80 --> 105 -->
81 106
82 <dom-module id="paper-drawer-panel"> 107 <dom-module id="paper-drawer-panel">
83 108 <link rel="import" type="css" href="paper-drawer-panel.css">
84 <style>
85 :host {
86 display: block;
87 position: absolute;
88 top: 0;
89 left: 0;
90 width: 100%;
91 height: 100%;
92 overflow: hidden;
93 }
94
95 iron-selector > #drawer {
96 position: absolute;
97 top: 0;
98 left: 0;
99 height: 100%;
100 will-change: transform;
101 box-sizing: border-box;
102 -moz-box-sizing: border-box;
103 }
104
105 .transition > #drawer {
106 transition: -webkit-transform ease-in-out 0.3s, width ease-in-out 0.3s;
107 transition: transform ease-in-out 0.3s, width ease-in-out 0.3s;
108 }
109
110 /*
111 right-drawer: make drawer on the right side
112 */
113 .right-drawer > #drawer {
114 left: auto;
115 right: 0;
116 }
117
118 paper-drawer-panel #drawer > * {
119 position: absolute;
120 top: 0;
121 left: 0;
122 width: 100%;
123 height: 100%;
124 box-sizing: border-box;
125 -moz-box-sizing: border-box;
126 }
127
128 iron-selector > #main {
129 position: absolute;
130 top: 0;
131 right: 0;
132 bottom: 0;
133 }
134
135 .transition > #main {
136 transition: left ease-in-out 0.3s, padding ease-in-out 0.3s;
137 }
138
139 .right-drawer > #main {
140 left: 0;
141 }
142
143 .right-drawer.transition > #main {
144 transition: right ease-in-out 0.3s, padding ease-in-out 0.3s;
145 }
146
147 #main > [main] {
148 height: 100%;
149 }
150
151 #scrim {
152 position: absolute;
153 top: 0;
154 right: 0;
155 bottom: 0;
156 left: 0;
157 background-color: rgba(0, 0, 0, 0.3);
158 visibility: hidden;
159 opacity: 0;
160 transition: opacity ease-in-out 0.38s, visibility ease-in-out 0.38s;
161 }
162
163 #edgeSwipeOverlay {
164 position: absolute;
165 top: 0;
166 bottom: 0;
167 left: 0;
168 width: 20px;
169 }
170
171 .right-drawer > #main > #edgeSwipeOverlay {
172 right: 0;
173 left: auto;
174 }
175
176 /*
177 narrow layout
178 */
179 .narrow-layout > #drawer.iron-selected {
180 box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.15);
181 }
182
183 .right-drawer.narrow-layout > #drawer.iron-selected {
184 box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.15);
185 }
186
187 .narrow-layout > #drawer > ::content[select="[drawer]"] > * {
188 border: 0;
189 }
190
191 .narrow-layout > #drawer:not(.iron-selected) {
192 -webkit-transform: translateX(-100%);
193 transform: translateX(-100%);
194 }
195
196 .right-drawer.narrow-layout > #drawer:not(.iron-selected) {
197 left: auto;
198 -webkit-transform: translateX(100%);
199 transform: translateX(100%);
200 }
201
202 .narrow-layout > #main {
203 left: 0 !important;
204 padding: 0;
205 }
206
207 .right-drawer.narrow-layout > #main {
208 left: 0;
209 right: 0;
210 padding: 0;
211 }
212
213 .narrow-layout > #main:not(.iron-selected) > #scrim,
214 .dragging #scrim {
215 visibility: visible;
216 opacity: 1;
217 }
218
219 .narrow-layout > #main > * {
220 margin: 0;
221 min-height: 100%;
222 left: 0;
223 right: 0;
224 box-sizing: border-box;
225 -moz-box-sizing: border-box;
226 }
227
228 iron-selector:not(.narrow-layout) #main ::content [paper-drawer-toggle] {
229 display: none;
230 }
231 </style>
232 109
233 <template> 110 <template>
234 <iron-media-query 111 <iron-media-query
235 on-query-matches-changed="onQueryMatchesChanged" 112 id="mq"
113 on-query-matches-changed="_onQueryMatchesChanged"
236 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]"> 114 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]">
237 </iron-media-query> 115 </iron-media-query>
238 116
239 <iron-selector 117 <iron-selector
240 attr-for-selected="id" 118 attr-for-selected="id"
241 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD rawer)]]" 119 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD rawer)]]"
242 activate-event="" 120 activate-event=""
243 selected="[[selected]]"> 121 selected="[[selected]]">
244 122
245 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt h)]]"> 123 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt h)]]">
246 <content select="[main]"></content> 124 <content select="[main]"></content>
247 <div id="scrim" on-tap="closeDrawer"></div> 125 <div id="scrim" on-tap="closeDrawer"></div>
248 <div id="edgeSwipeOverlay"
249 hidden$="[[_computeSwipeOverlayHidden(narrow, disableEdgeSwipe)]]">
250 </div>
251 </div> 126 </div>
252 127
253 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> 128 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]">
254 <content select="[drawer]"></content> 129 <content select="[drawer]"></content>
255 </div> 130 </div>
256 131
257 </iron-selector> 132 </iron-selector>
258 </template> 133 </template>
259 134
260 </dom-module> 135 </dom-module>
261 136
262 <script> 137 <script>
263 138
264 (function() { 139 (function() {
265 140
266 'use strict'; 141 'use strict';
267 142
143 // this would be the only `paper-drawer-panel` in
144 // the whole app that can be in `dragging` state
145 var sharedPanel = null;
146
268 function classNames(obj) { 147 function classNames(obj) {
269 var classNames = []; 148 var classes = [];
270 for (var key in obj) { 149 for (var key in obj) {
271 if (obj.hasOwnProperty(key) && obj[key]) { 150 if (obj.hasOwnProperty(key) && obj[key]) {
272 classNames.push(key); 151 classes.push(key);
273 } 152 }
274 } 153 }
275 154
276 return classNames.join(' '); 155 return classes.join(' ');
277 } 156 }
278 157
279 Polymer({ 158 Polymer({
280 159
281 is: 'paper-drawer-panel', 160 is: 'paper-drawer-panel',
282 161
283 /** 162 /**
284 * Fired when the narrow layout changes. 163 * Fired when the narrow layout changes.
285 * 164 *
286 * @event paper-responsive-change {{narrow: boolean}} detail - 165 * @event paper-responsive-change {{narrow: boolean}} detail -
(...skipping 10 matching lines...) Expand all
297 * @event paper-select {{isSelected: boolean, item: Object}} detail - 176 * @event paper-select {{isSelected: boolean, item: Object}} detail -
298 * isSelected: True for selection and false for deselection. 177 * isSelected: True for selection and false for deselection.
299 * item: The panel that the event refers to. 178 * item: The panel that the event refers to.
300 */ 179 */
301 180
302 properties: { 181 properties: {
303 182
304 /** 183 /**
305 * The panel to be selected when `paper-drawer-panel` changes to narrow 184 * The panel to be selected when `paper-drawer-panel` changes to narrow
306 * layout. 185 * layout.
307 *
308 * @attribute defaultSelected
309 * @type string
310 * @default 'main'
311 */ 186 */
312 defaultSelected: { 187 defaultSelected: {
313 type: String, 188 type: String,
314 value: 'main' 189 value: 'main'
315 }, 190 },
316 191
317 /** 192 /**
318 * If true, swipe from the edge is disable. 193 * If true, swipe from the edge is disable.
319 *
320 * @attribute disableEdgeSwipe
321 * @type boolean
322 * @default false
323 */ 194 */
324 disableEdgeSwipe: Boolean, 195 disableEdgeSwipe: {
196 type: Boolean,
197 value: false
198 },
325 199
326 /** 200 /**
327 * If true, swipe to open/close the drawer is disabled. 201 * If true, swipe to open/close the drawer is disabled.
328 *
329 * @attribute disableSwipe
330 * @type boolean
331 * @default false
332 */ 202 */
333 disableSwipe: Boolean, 203 disableSwipe: {
204 type: Boolean,
205 value: false
206 },
334 207
335 // Whether the user is dragging the drawer interactively. 208 /**
209 * Whether the user is dragging the drawer interactively.
210 */
336 dragging: { 211 dragging: {
337 type: Boolean, 212 type: Boolean,
338 value: false 213 value: false
339 }, 214 },
340 215
341 /** 216 /**
342 * Width of the drawer panel. 217 * Width of the drawer panel.
343 *
344 * @attribute drawerWidth
345 * @type string
346 * @default '256px'
347 */ 218 */
348 drawerWidth: { 219 drawerWidth: {
349 type: String, 220 type: String,
350 value: '256px' 221 value: '256px'
351 }, 222 },
352 223
353 // How many pixels on the side of the screen are sensitive to edge 224 /**
354 // swipes and peek. 225 * How many pixels on the side of the screen are sensitive to edge
226 * swipes and peek.
227 */
355 edgeSwipeSensitivity: { 228 edgeSwipeSensitivity: {
356 type: Number, 229 type: Number,
357 value: 30 230 value: 30
358 }, 231 },
359 232
360 /** 233 /**
361 * If true, ignore `responsiveWidth` setting and force the narrow layout . 234 * If true, ignore `responsiveWidth` setting and force the narrow layout .
362 *
363 * @attribute forceNarrow
364 * @type boolean
365 * @default false
366 */ 235 */
367 forceNarrow: { 236 forceNarrow: {
368 observer: 'forceNarrowChanged',
369 type: Boolean, 237 type: Boolean,
370 value: false 238 value: false
371 }, 239 },
372 240
373 // Whether the browser has support for the transform CSS property. 241 /**
242 * Whether the browser has support for the transform CSS property.
243 */
374 hasTransform: { 244 hasTransform: {
375 type: Boolean, 245 type: Boolean,
376 value: function() { 246 value: function() {
377 return 'transform' in this.style; 247 return 'transform' in this.style;
378 } 248 }
379 }, 249 },
380 250
381 // Whether the browser has support for the will-change CSS property. 251 /**
252 * Whether the browser has support for the will-change CSS property.
253 */
382 hasWillChange: { 254 hasWillChange: {
383 type: Boolean, 255 type: Boolean,
384 value: function() { 256 value: function() {
385 return 'willChange' in this.style; 257 return 'willChange' in this.style;
386 } 258 }
387 }, 259 },
388 260
389 /** 261 /**
390 * Returns true if the panel is in narrow layout. This is useful if you 262 * Returns true if the panel is in narrow layout. This is useful if you
391 * need to show/hide elements based on the layout. 263 * need to show/hide elements based on the layout.
392 *
393 * @attribute narrow
394 * @type boolean
395 * @default false
396 */ 264 */
397 narrow: { 265 narrow: {
398 reflectToAttribute: true, 266 reflectToAttribute: true,
399 type: Boolean, 267 type: Boolean,
400 value: false, 268 value: false,
401 notify: true 269 notify: true
402 }, 270 },
403 271
404 // Whether the drawer is peeking out from the edge. 272 /**
273 * Whether the drawer is peeking out from the edge.
274 */
405 peeking: { 275 peeking: {
406 type: Boolean, 276 type: Boolean,
407 value: false 277 value: false
408 }, 278 },
409 279
410 /** 280 /**
411 * Max-width when the panel changes to narrow layout. 281 * Max-width when the panel changes to narrow layout.
412 *
413 * @attribute responsiveWidth
414 * @type string
415 * @default '640px'
416 */ 282 */
417 responsiveWidth: { 283 responsiveWidth: {
418 type: String, 284 type: String,
419 value: '640px' 285 value: '640px'
420 }, 286 },
421 287
422 /** 288 /**
423 * If true, position the drawer to the right. 289 * If true, position the drawer to the right.
424 *
425 * @attribute rightDrawer
426 * @type boolean
427 * @default false
428 */ 290 */
429 rightDrawer: { 291 rightDrawer: {
430 type: Boolean, 292 type: Boolean,
431 value: false 293 value: false
432 }, 294 },
433 295
434 /** 296 /**
435 * The panel that is being selected. `drawer` for the drawer panel and 297 * The panel that is being selected. `drawer` for the drawer panel and
436 * `main` for the main panel. 298 * `main` for the main panel.
437 *
438 * @attribute selected
439 * @type string
440 * @default null
441 */ 299 */
442 selected: { 300 selected: {
443 reflectToAttribute: true, 301 reflectToAttribute: true,
444 type: String, 302 type: String,
445 value: null 303 value: null
446 }, 304 },
447 305
448 /** 306 /**
449 * The attribute on elements that should toggle the drawer on tap, also elements will 307 * The attribute on elements that should toggle the drawer on tap, also elements will
450 * automatically be hidden in wide layout. 308 * automatically be hidden in wide layout.
451 */ 309 */
452 drawerToggleAttribute: { 310 drawerToggleAttribute: {
453 type: String, 311 type: String,
454 value: 'paper-drawer-toggle' 312 value: 'paper-drawer-toggle'
455 }, 313 },
456 314
457 /** 315 /**
458 * Whether the transition is enabled. 316 * Whether the transition is enabled.
459 */ 317 */
460 transition: { 318 transition: {
461 type: Boolean, 319 type: Boolean,
462 value: false 320 value: false
463 }, 321 },
464 322
465 /**
466 * Starting X coordinate of a tracking gesture. It is non-null only betw een trackStart and
467 * trackEnd events.
468 * @type {?number}
469 */
470 _startX: {
471 type: Number,
472 value: null
473 }
474
475 }, 323 },
476 324
477 listeners: { 325 listeners: {
478 tap: '_onTap', 326 tap: '_onTap',
479 track: '_onTrack' 327 track: '_onTrack',
328 down: '_downHandler',
329 up: '_upHandler'
330 },
480 331
481 // TODO: Implement tap handlers when taps are supported. 332 observers: [
482 // 333 '_forceNarrowChanged(forceNarrow, defaultSelected)'
483 // down: 'downHandler', 334 ],
484 // up: 'upHandler' 335
336 /**
337 * Toggles the panel open and closed.
338 *
339 * @method togglePanel
340 */
341 togglePanel: function() {
342 if (this._isMainSelected()) {
343 this.openDrawer();
344 } else {
345 this.closeDrawer();
346 }
347 },
348
349 /**
350 * Opens the drawer.
351 *
352 * @method openDrawer
353 */
354 openDrawer: function() {
355 this.selected = 'drawer';
356 },
357
358 /**
359 * Closes the drawer.
360 *
361 * @method closeDrawer
362 */
363 closeDrawer: function() {
364 this.selected = 'main';
365 },
366
367 ready: function() {
368 // Avoid transition at the beginning e.g. page loads and enable
369 // transitions only after the element is rendered and ready.
370 this.transition = true;
485 }, 371 },
486 372
487 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra wer) { 373 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra wer) {
488 return classNames({ 374 return classNames({
489 dragging: dragging, 375 dragging: dragging,
490 'narrow-layout': narrow, 376 'narrow-layout': narrow,
491 'right-drawer': rightDrawer, 377 'right-drawer': rightDrawer,
378 'left-drawer': !rightDrawer,
492 transition: transition 379 transition: transition
493 }); 380 });
494 }, 381 },
495 382
496 _computeDrawerStyle: function(drawerWidth) { 383 _computeDrawerStyle: function(drawerWidth) {
497 return 'width:' + drawerWidth + ';'; 384 return 'width:' + drawerWidth + ';';
498 }, 385 },
499 386
500 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) { 387 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) {
501 var style = ''; 388 var style = '';
502 389
503 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';' 390 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';';
504 391
505 if (rightDrawer) { 392 if (rightDrawer) {
506 style += 'right:' + (narrow ? '' : drawerWidth) + ';'; 393 style += 'right:' + (narrow ? '' : drawerWidth) + ';';
507 } else { 394 } else {
508 style += 'right:;' 395 style += 'right:;';
509 } 396 }
510 397
511 return style; 398 return style;
512 }, 399 },
513 400
514 _computeMediaQuery: function(forceNarrow, responsiveWidth) { 401 _computeMediaQuery: function(forceNarrow, responsiveWidth) {
515 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; 402 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')';
516 }, 403 },
517 404
518 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { 405 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) {
519 return !narrow || disableEdgeSwipe; 406 return !narrow || disableEdgeSwipe;
520 }, 407 },
521 408
522 _onTrack: function(event) { 409 _onTrack: function(e) {
523 switch (event.detail.state) { 410 if (sharedPanel && this !== sharedPanel) {
411 return;
412 }
413 switch (e.detail.state) {
414 case 'start':
415 this._trackStart(e);
416 break;
417 case 'track':
418 this._trackX(e);
419 break;
524 case 'end': 420 case 'end':
525 this.trackEnd(event); 421 this._trackEnd(e);
526 break;
527 case 'move':
528 this.trackX(event);
529 break;
530 case 'start':
531 this.trackStart(event);
532 break; 422 break;
533 } 423 }
534 },
535 424
536 ready: function() {
537 // Avoid transition at the beginning e.g. page loads and enable
538 // transitions only after the element is rendered and ready.
539 this.transition = true;
540 },
541
542 /**
543 * Toggles the panel open and closed.
544 *
545 * @method togglePanel
546 */
547 togglePanel: function() {
548 if (this.isMainSelected()) {
549 this.openDrawer();
550 } else {
551 this.closeDrawer();
552 }
553 },
554
555 /**
556 * Opens the drawer.
557 *
558 * @method openDrawer
559 */
560 openDrawer: function() {
561 this.selected = 'drawer';
562 },
563
564 /**
565 * Closes the drawer.
566 *
567 * @method closeDrawer
568 */
569 closeDrawer: function() {
570 this.selected = 'main';
571 }, 425 },
572 426
573 _responsiveChange: function(narrow) { 427 _responsiveChange: function(narrow) {
574 this.narrow = narrow; 428 this.narrow = narrow;
575 429
576 if (this.narrow) { 430 if (this.narrow) {
577 this.selected = this.defaultSelected; 431 this.selected = this.defaultSelected;
578 } 432 }
579 433
580 this.setAttribute('touch-action', this.swipeAllowed() ? 'pan-y' : ''); 434 this.setScrollDirection(this._swipeAllowed() ? 'y' : 'all');
581 this.fire('paper-responsive-change', {narrow: this.narrow}); 435 this.fire('paper-responsive-change', {narrow: this.narrow});
582 }, 436 },
583 437
584 onQueryMatchesChanged: function(e) { 438 _onQueryMatchesChanged: function(e) {
585 this._responsiveChange(e.detail.value); 439 this._responsiveChange(e.detail.value);
586 }, 440 },
587 441
588 forceNarrowChanged: function() { 442 _forceNarrowChanged: function() {
589 this._responsiveChange(this.forceNarrow); 443 // set the narrow mode only if we reached the `responsiveWidth`
444 this._responsiveChange(this.forceNarrow || this.$.mq.queryMatches);
590 }, 445 },
591 446
592 swipeAllowed: function() { 447 _swipeAllowed: function() {
593 return this.narrow && !this.disableSwipe; 448 return this.narrow && !this.disableSwipe;
594 }, 449 },
595 450
596 isMainSelected: function() { 451 _isMainSelected: function() {
597 return this.selected === 'main'; 452 return this.selected === 'main';
598 }, 453 },
599 454
600 startEdgePeek: function() { 455 _startEdgePeek: function() {
601 this.width = this.$.drawer.offsetWidth; 456 this.width = this.$.drawer.offsetWidth;
602 this.moveDrawer(this.translateXForDeltaX(this.rightDrawer ? 457 this._moveDrawer(this._translateXForDeltaX(this.rightDrawer ?
603 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity)); 458 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity));
604 this.peeking = true; 459 this.peeking = true;
605 }, 460 },
606 461
607 stopEdgePeek: function() { 462 _stopEdgePeek: function() {
608 if (this.peeking) { 463 if (this.peeking) {
609 this.peeking = false; 464 this.peeking = false;
610 this.moveDrawer(null); 465 this._moveDrawer(null);
611 } 466 }
612 }, 467 },
613 468
614 _downHandler: function(e) { 469 _downHandler: function(e) {
615 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e)) { 470 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e) && !sharedPanel) {
616 this._startEdgePeek(); 471 this._startEdgePeek();
472 // grab this panel
473 sharedPanel = this;
617 } 474 }
618 }, 475 },
619 476
620 _upHandler: function(e) { 477 _upHandler: function() {
621 this._stopEdgePeek(); 478 this._stopEdgePeek();
479 // release the panel
480 sharedPanel = null;
622 }, 481 },
623 482
624 _onTap: function(e) { 483 _onTap: function(e) {
625 var targetElement = Polymer.dom(e).localTarget; 484 var targetElement = Polymer.dom(e).localTarget;
626 var isTargetToggleElement = targetElement && 485 var isTargetToggleElement = targetElement &&
627 this.drawerToggleAttribute && 486 this.drawerToggleAttribute &&
628 targetElement.hasAttribute(this.drawerToggleAttribute); 487 targetElement.hasAttribute(this.drawerToggleAttribute);
629 488
630 if (isTargetToggleElement) { 489 if (isTargetToggleElement) {
631 this.togglePanel(); 490 this.togglePanel();
632 } 491 }
633 }, 492 },
634 493
635 isEdgeTouch: function(event) { 494 _isEdgeTouch: function(e) {
636 var x = event.detail.x; 495 var x = e.detail.x;
637 496
638 return !this.disableEdgeSwipe && this.swipeAllowed() && 497 return !this.disableEdgeSwipe && this._swipeAllowed() &&
639 (this.rightDrawer ? 498 (this.rightDrawer ?
640 x >= this.offsetWidth - this.edgeSwipeSensitivity : 499 x >= this.offsetWidth - this.edgeSwipeSensitivity :
641 x <= this.edgeSwipeSensitivity); 500 x <= this.edgeSwipeSensitivity);
642 }, 501 },
643 502
644 trackStart: function(event) { 503 _trackStart: function() {
645 if (this.swipeAllowed()) { 504 if (this._swipeAllowed()) {
505 sharedPanel = this;
646 this.dragging = true; 506 this.dragging = true;
647 this._startX = event.detail.x;
648 507
649 if (this.isMainSelected()) { 508 if (this._isMainSelected()) {
650 this.dragging = this.peeking || this.isEdgeTouch(event); 509 this.dragging = this.peeking || this._isEdgeTouch(event);
651 } 510 }
652 511
653 if (this.dragging) { 512 if (this.dragging) {
654 this.width = this.$.drawer.offsetWidth; 513 this.width = this.$.drawer.offsetWidth;
655 this.transition = false; 514 this.transition = false;
656
657 // TODO: Re-enable when tap gestures are implemented.
658 //
659 // e.preventTap();
660 } 515 }
661 } 516 }
662 }, 517 },
663 518
664 translateXForDeltaX: function(deltaX) { 519 _translateXForDeltaX: function(deltaX) {
665 var isMain = this.isMainSelected(); 520 var isMain = this._isMainSelected();
666 521
667 if (this.rightDrawer) { 522 if (this.rightDrawer) {
668 return Math.max(0, isMain ? this.width + deltaX : deltaX); 523 return Math.max(0, isMain ? this.width + deltaX : deltaX);
669 } else { 524 } else {
670 return Math.min(0, isMain ? deltaX - this.width : deltaX); 525 return Math.min(0, isMain ? deltaX - this.width : deltaX);
671 } 526 }
672 }, 527 },
673 528
674 trackX: function(event) { 529 _trackX: function(e) {
675 var dx = event.detail.x - this._startX; 530 if (this.dragging) {
531 var dx = e.detail.dx;
676 532
677 if (this.dragging) {
678 if (this.peeking) { 533 if (this.peeking) {
679 if (Math.abs(dx) <= this.edgeSwipeSensitivity) { 534 if (Math.abs(dx) <= this.edgeSwipeSensitivity) {
680 // Ignore trackx until we move past the edge peek. 535 // Ignore trackx until we move past the edge peek.
681 return; 536 return;
682 } 537 }
683
684 this.peeking = false; 538 this.peeking = false;
685 } 539 }
686 540
687 this.moveDrawer(this.translateXForDeltaX(dx)); 541 this._moveDrawer(this._translateXForDeltaX(dx));
688 } 542 }
689 }, 543 },
690 544
691 trackEnd: function(event) { 545 _trackEnd: function(e) {
692 if (this.dragging) { 546 if (this.dragging) {
693 var xDirection = (event.detail.x - this._startX) > 0; 547 var xDirection = e.detail.dx > 0;
694 548
695 this.dragging = false; 549 this.dragging = false;
696 this._startX = null;
697 this.transition = true; 550 this.transition = true;
698 this.moveDrawer(null); 551 sharedPanel = null;
552 this._moveDrawer(null);
699 553
700 if (this.rightDrawer) { 554 if (this.rightDrawer) {
701 this[(xDirection > 0) ? 'closeDrawer' : 'openDrawer'](); 555 this[xDirection ? 'closeDrawer' : 'openDrawer']();
702 } else { 556 } else {
703 this[(xDirection > 0) ? 'openDrawer' : 'closeDrawer'](); 557 this[xDirection ? 'openDrawer' : 'closeDrawer']();
704 } 558 }
705 } 559 }
706 }, 560 },
707 561
708 transformForTranslateX: function(translateX) { 562 _transformForTranslateX: function(translateX) {
709 if (translateX === null) { 563 if (translateX === null) {
710 return ''; 564 return '';
711 } 565 }
712 566
713 return this.hasWillChange ? 'translateX(' + translateX + 'px)' : 567 return this.hasWillChange ? 'translateX(' + translateX + 'px)' :
714 'translate3d(' + translateX + 'px, 0, 0)'; 568 'translate3d(' + translateX + 'px, 0, 0)';
715 }, 569 },
716 570
717 moveDrawer: function(translateX) { 571 _moveDrawer: function(translateX) {
718 var s = this.$.drawer.style; 572 var s = this.$.drawer.style;
719 573
720 if (this.hasTransform) { 574 if (this.hasTransform) {
721 s.transform = this.transformForTranslateX(translateX); 575 s.transform = this._transformForTranslateX(translateX);
722 } else { 576 } else {
723 s.webkitTransform = this.transformForTranslateX(translateX); 577 s.webkitTransform = this._transformForTranslateX(translateX);
724 } 578 }
725 } 579 }
726 580
727 }); 581 });
728 582
729 }()); 583 }());
730 584
731 </script> 585 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698