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 --> | 8 --> |
9 | 9 |
10 <link rel="import" href="../polymer/polymer.html"> | 10 <link rel="import" href="../polymer/polymer.html"> |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 <template> | 233 <template> |
234 <iron-media-query | 234 <iron-media-query |
235 on-query-matches-changed="onQueryMatchesChanged" | 235 on-query-matches-changed="onQueryMatchesChanged" |
236 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]"> | 236 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]"> |
237 </iron-media-query> | 237 </iron-media-query> |
238 | 238 |
239 <iron-selector | 239 <iron-selector |
240 attr-for-selected="id" | 240 attr-for-selected="id" |
241 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD
rawer)]]" | 241 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD
rawer)]]" |
242 on-iron-activate="onSelect" | 242 activate-event="" |
243 selected="[[selected]]"> | 243 selected="[[selected]]"> |
244 | 244 |
245 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt
h)]]"> | 245 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt
h)]]"> |
246 <content select="[main]"></content> | 246 <content select="[main]"></content> |
247 <div id="scrim"></div> | 247 <div id="scrim" on-tap="closeDrawer"></div> |
248 <div id="edgeSwipeOverlay" | 248 <div id="edgeSwipeOverlay" |
249 hidden$="[[_computeSwipeOverlayHidden(narrow, disableEdgeSwipe)]]"> | 249 hidden$="[[_computeSwipeOverlayHidden(narrow, disableEdgeSwipe)]]"> |
250 </div> | 250 </div> |
251 </div> | 251 </div> |
252 | 252 |
253 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> | 253 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> |
254 <content select="[drawer]"></content> | 254 <content select="[drawer]"></content> |
255 </div> | 255 </div> |
256 | 256 |
257 </iron-selector> | 257 </iron-selector> |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 * Returns true if the panel is in narrow layout. This is useful if you | 390 * Returns true if the panel is in narrow layout. This is useful if you |
391 * need to show/hide elements based on the layout. | 391 * need to show/hide elements based on the layout. |
392 * | 392 * |
393 * @attribute narrow | 393 * @attribute narrow |
394 * @type boolean | 394 * @type boolean |
395 * @default false | 395 * @default false |
396 */ | 396 */ |
397 narrow: { | 397 narrow: { |
398 reflectToAttribute: true, | 398 reflectToAttribute: true, |
399 type: Boolean, | 399 type: Boolean, |
400 value: false | 400 value: false, |
| 401 notify: true |
401 }, | 402 }, |
402 | 403 |
403 // Whether the drawer is peeking out from the edge. | 404 // Whether the drawer is peeking out from the edge. |
404 peeking: { | 405 peeking: { |
405 type: Boolean, | 406 type: Boolean, |
406 value: false | 407 value: false |
407 }, | 408 }, |
408 | 409 |
409 /** | 410 /** |
410 * Max-width when the panel changes to narrow layout. | 411 * Max-width when the panel changes to narrow layout. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 * @type {?number} | 468 * @type {?number} |
468 */ | 469 */ |
469 _startX: { | 470 _startX: { |
470 type: Number, | 471 type: Number, |
471 value: null | 472 value: null |
472 } | 473 } |
473 | 474 |
474 }, | 475 }, |
475 | 476 |
476 listeners: { | 477 listeners: { |
477 click: 'onClick', | 478 tap: '_onTap', |
478 track: 'onTrack' | 479 track: '_onTrack' |
479 | 480 |
480 // TODO: Implement tap handlers when taps are supported. | 481 // TODO: Implement tap handlers when taps are supported. |
481 // | 482 // |
482 // down: 'downHandler', | 483 // down: 'downHandler', |
483 // up: 'upHandler' | 484 // up: 'upHandler' |
484 }, | 485 }, |
485 | 486 |
486 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra
wer) { | 487 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra
wer) { |
487 return classNames({ | 488 return classNames({ |
488 dragging: dragging, | 489 dragging: dragging, |
(...skipping 22 matching lines...) Expand all Loading... |
511 }, | 512 }, |
512 | 513 |
513 _computeMediaQuery: function(forceNarrow, responsiveWidth) { | 514 _computeMediaQuery: function(forceNarrow, responsiveWidth) { |
514 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; | 515 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; |
515 }, | 516 }, |
516 | 517 |
517 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { | 518 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { |
518 return !narrow || disableEdgeSwipe; | 519 return !narrow || disableEdgeSwipe; |
519 }, | 520 }, |
520 | 521 |
521 onTrack: function(event) { | 522 _onTrack: function(event) { |
522 switch (event.detail.state) { | 523 switch (event.detail.state) { |
523 case 'end': | 524 case 'end': |
524 this.trackEnd(event); | 525 this.trackEnd(event); |
525 break; | 526 break; |
526 case 'move': | 527 case 'move': |
527 this.trackX(event); | 528 this.trackX(event); |
528 break; | 529 break; |
529 case 'start': | 530 case 'start': |
530 this.trackStart(event); | 531 this.trackStart(event); |
531 break; | 532 break; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 this.peeking = true; | 604 this.peeking = true; |
604 }, | 605 }, |
605 | 606 |
606 stopEdgePeek: function() { | 607 stopEdgePeek: function() { |
607 if (this.peeking) { | 608 if (this.peeking) { |
608 this.peeking = false; | 609 this.peeking = false; |
609 this.moveDrawer(null); | 610 this.moveDrawer(null); |
610 } | 611 } |
611 }, | 612 }, |
612 | 613 |
613 // TODO: Implement tap handlers when taps are supported. | 614 _downHandler: function(e) { |
614 // | 615 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e)) { |
615 // downHandler: function(e) { | 616 this._startEdgePeek(); |
616 // if (!this.dragging && this.isMainSelected() && this.isEdgeTouch(e)) { | 617 } |
617 // this.startEdgePeek(); | 618 }, |
618 // } | |
619 // }, | |
620 // | |
621 // upHandler: function(e) { | |
622 // this.stopEdgePeek(); | |
623 // }, | |
624 | 619 |
625 onClick: function(e) { | 620 _upHandler: function(e) { |
626 var isTargetToggleElement = e.target && | 621 this._stopEdgePeek(); |
| 622 }, |
| 623 |
| 624 _onTap: function(e) { |
| 625 var targetElement = Polymer.dom(e).localTarget; |
| 626 var isTargetToggleElement = targetElement && |
627 this.drawerToggleAttribute && | 627 this.drawerToggleAttribute && |
628 e.target.hasAttribute(this.drawerToggleAttribute); | 628 targetElement.hasAttribute(this.drawerToggleAttribute); |
629 | 629 |
630 if (isTargetToggleElement) { | 630 if (isTargetToggleElement) { |
631 this.togglePanel(); | 631 this.togglePanel(); |
632 } | 632 } |
633 }, | 633 }, |
634 | 634 |
635 isEdgeTouch: function(event) { | 635 isEdgeTouch: function(event) { |
636 var x = event.detail.x; | 636 var x = event.detail.x; |
637 | 637 |
638 return !this.disableEdgeSwipe && this.swipeAllowed() && | 638 return !this.disableEdgeSwipe && this.swipeAllowed() && |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 }, | 715 }, |
716 | 716 |
717 moveDrawer: function(translateX) { | 717 moveDrawer: function(translateX) { |
718 var s = this.$.drawer.style; | 718 var s = this.$.drawer.style; |
719 | 719 |
720 if (this.hasTransform) { | 720 if (this.hasTransform) { |
721 s.transform = this.transformForTranslateX(translateX); | 721 s.transform = this.transformForTranslateX(translateX); |
722 } else { | 722 } else { |
723 s.webkitTransform = this.transformForTranslateX(translateX); | 723 s.webkitTransform = this.transformForTranslateX(translateX); |
724 } | 724 } |
725 }, | |
726 | |
727 onSelect: function(e) { | |
728 e.preventDefault(); | |
729 this.selected = e.detail.selected; | |
730 } | 725 } |
731 | 726 |
732 }); | 727 }); |
733 | 728 |
734 }()); | 729 }()); |
735 | 730 |
736 </script> | 731 </script> |
OLD | NEW |