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

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

Issue 1221923003: Update bower.json for Polymer elements and add PRESUBMIT.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 `right-drawer` attribute. 70 To position the drawer to the right, add `right-drawer` attribute.
71 71
72 <paper-drawer-panel right-drawer> 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 Styling paper-drawer-panel: 77 Styling `paper-drawer-panel`
78 78
79 To change the main container: 79 To change the main container:
80 paper-drawer-panel { 80
81 --paper-drawer-panel-main-container: { 81 paper-drawer-panel {
82 background-color: gray; 82 --paper-drawer-panel-main-container: {
83 }; 83 background-color: gray;
84 } 84 };
85 }
85 86
86 To change the drawer container when it's in the left side: 87 To change the drawer container when it's in the left side:
87 paper-drawer-panel { 88
88 --paper-drawer-panel-left-drawer-container: { 89 paper-drawer-panel {
89 background-color: white; 90 --paper-drawer-panel-left-drawer-container: {
90 }; 91 background-color: white;
91 } 92 };
93 }
92 94
93 To change the drawer container when it's in the right side: 95 To change the drawer container when it's in the right side:
94 96
95 paper-drawer-panel { 97 paper-drawer-panel {
96 --paper-drawer-panel-right-drawer-container: { 98 --paper-drawer-panel-right-drawer-container: {
97 background-color: white; 99 background-color: white;
98 }; 100 };
99 } 101 }
100 102
101 @group Paper elements 103 @group Paper elements
102 @element paper-drawer-panel 104 @element paper-drawer-panel
103 @demo demo/index.html 105 @demo demo/index.html
104 @hero hero.svg 106 @hero hero.svg
105 --> 107 -->
106 108
107 <dom-module id="paper-drawer-panel"> 109 <dom-module id="paper-drawer-panel">
108 <link rel="import" type="css" href="paper-drawer-panel.css"> 110 <link rel="import" type="css" href="paper-drawer-panel.css">
109 111
110 <template> 112 <template>
111 <iron-media-query 113 <iron-media-query
112 id="mq" 114 id="mq"
113 on-query-matches-changed="_onQueryMatchesChanged" 115 on-query-matches-changed="_onQueryMatchesChanged"
114 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]"> 116 query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]">
115 </iron-media-query> 117 </iron-media-query>
116 118
117 <iron-selector 119 <iron-selector
118 attr-for-selected="id" 120 attr-for-selected="id"
119 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD rawer)]]" 121 class$="[[_computeIronSelectorClass(narrow, transition, dragging, rightD rawer, peeking)]]"
120 activate-event="" 122 activate-event=""
121 selected="[[selected]]"> 123 selected="[[selected]]">
122 124
123 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt h)]]"> 125 <div id="main" style$="[[_computeMainStyle(narrow, rightDrawer, drawerWidt h)]]">
124 <content select="[main]"></content> 126 <content select="[main]"></content>
125 <div id="scrim" on-tap="closeDrawer"></div> 127 <div id="scrim" on-tap="closeDrawer"></div>
126 </div> 128 </div>
127 129
128 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]"> 130 <div id="drawer" style$="[[_computeDrawerStyle(drawerWidth)]]">
129 <content select="[drawer]"></content> 131 <content select="[drawer]"></content>
(...skipping 30 matching lines...) Expand all
160 is: 'paper-drawer-panel', 162 is: 'paper-drawer-panel',
161 163
162 /** 164 /**
163 * Fired when the narrow layout changes. 165 * Fired when the narrow layout changes.
164 * 166 *
165 * @event paper-responsive-change {{narrow: boolean}} detail - 167 * @event paper-responsive-change {{narrow: boolean}} detail -
166 * narrow: true if the panel is in narrow layout. 168 * narrow: true if the panel is in narrow layout.
167 */ 169 */
168 170
169 /** 171 /**
170 * Fired when the selected panel changes. 172 * Fired when the a panel is selected.
171 * 173 *
172 * Listening for this event is an alternative to observing changes in the `selected` attribute. 174 * Listening for this event is an alternative to observing changes in the `selected` attribute.
173 * This event is fired both when a panel is selected and deselected. 175 * This event is fired both when a panel is selected.
174 * The `isSelected` detail property contains the selection state.
175 * 176 *
176 * @event paper-select {{isSelected: boolean, item: Object}} detail - 177 * @event iron-select {{item: Object}} detail -
177 * isSelected: True for selection and false for deselection.
178 * item: The panel that the event refers to. 178 * item: The panel that the event refers to.
179 */ 179 */
180 180
181 /**
182 * Fired when a panel is deselected.
183 *
184 * Listening for this event is an alternative to observing changes in the `selected` attribute.
185 * This event is fired both when a panel is deselected.
186 *
187 * @event iron-deselect {{item: Object}} detail -
188 * item: The panel that the event refers to.
189 */
181 properties: { 190 properties: {
182 191
183 /** 192 /**
184 * The panel to be selected when `paper-drawer-panel` changes to narrow 193 * The panel to be selected when `paper-drawer-panel` changes to narrow
185 * layout. 194 * layout.
186 */ 195 */
187 defaultSelected: { 196 defaultSelected: {
188 type: String, 197 type: String,
189 value: 'main' 198 value: 'main'
190 }, 199 },
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 closeDrawer: function() { 378 closeDrawer: function() {
370 this.selected = 'main'; 379 this.selected = 'main';
371 }, 380 },
372 381
373 ready: function() { 382 ready: function() {
374 // Avoid transition at the beginning e.g. page loads and enable 383 // Avoid transition at the beginning e.g. page loads and enable
375 // transitions only after the element is rendered and ready. 384 // transitions only after the element is rendered and ready.
376 this.transition = true; 385 this.transition = true;
377 }, 386 },
378 387
379 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra wer) { 388 _computeIronSelectorClass: function(narrow, transition, dragging, rightDra wer, peeking) {
380 return classNames({ 389 return classNames({
381 dragging: dragging, 390 dragging: dragging,
382 'narrow-layout': narrow, 391 'narrow-layout': narrow,
383 'right-drawer': rightDrawer, 392 'right-drawer': rightDrawer,
384 'left-drawer': !rightDrawer, 393 'left-drawer': !rightDrawer,
385 transition: transition 394 transition: transition,
395 peeking: peeking
386 }); 396 });
387 }, 397 },
388 398
389 _computeDrawerStyle: function(drawerWidth) { 399 _computeDrawerStyle: function(drawerWidth) {
390 return 'width:' + drawerWidth + ';'; 400 return 'width:' + drawerWidth + ';';
391 }, 401 },
392 402
393 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) { 403 _computeMainStyle: function(narrow, rightDrawer, drawerWidth) {
394 var style = ''; 404 var style = '';
395 405
396 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';'; 406 style += 'left:' + ((narrow || rightDrawer) ? '0' : drawerWidth) + ';';
397 407
398 if (rightDrawer) { 408 if (rightDrawer) {
399 style += 'right:' + (narrow ? '' : drawerWidth) + ';'; 409 style += 'right:' + (narrow ? '' : drawerWidth) + ';';
400 } else {
401 style += 'right:;';
402 } 410 }
403 411
404 return style; 412 return style;
405 }, 413 },
406 414
407 _computeMediaQuery: function(forceNarrow, responsiveWidth) { 415 _computeMediaQuery: function(forceNarrow, responsiveWidth) {
408 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')'; 416 return forceNarrow ? '' : '(max-width: ' + responsiveWidth + ')';
409 }, 417 },
410 418
411 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) { 419 _computeSwipeOverlayHidden: function(narrow, disableEdgeSwipe) {
412 return !narrow || disableEdgeSwipe; 420 return !narrow || disableEdgeSwipe;
413 }, 421 },
414 422
415 _onTrack: function(e) { 423 _onTrack: function(event) {
416 if (sharedPanel && this !== sharedPanel) { 424 if (sharedPanel && this !== sharedPanel) {
417 return; 425 return;
418 } 426 }
419 switch (e.detail.state) { 427 switch (event.detail.state) {
420 case 'start': 428 case 'start':
421 this._trackStart(e); 429 this._trackStart(event);
422 break; 430 break;
423 case 'track': 431 case 'track':
424 this._trackX(e); 432 this._trackX(event);
425 break; 433 break;
426 case 'end': 434 case 'end':
427 this._trackEnd(e); 435 this._trackEnd(event);
428 break; 436 break;
429 } 437 }
430 438
431 }, 439 },
432 440
433 _responsiveChange: function(narrow) { 441 _responsiveChange: function(narrow) {
434 this._setNarrow(narrow); 442 this._setNarrow(narrow);
435 443
436 if (this.narrow) { 444 if (this.narrow) {
437 this.selected = this.defaultSelected; 445 this.selected = this.defaultSelected;
438 } 446 }
439 447
440 this.setScrollDirection(this._swipeAllowed() ? 'y' : 'all'); 448 this.setScrollDirection(this._swipeAllowed() ? 'y' : 'all');
441 this.fire('paper-responsive-change', {narrow: this.narrow}); 449 this.fire('paper-responsive-change', {narrow: this.narrow});
442 }, 450 },
443 451
444 _onQueryMatchesChanged: function(e) { 452 _onQueryMatchesChanged: function(event) {
445 this._responsiveChange(e.detail.value); 453 this._responsiveChange(event.detail.value);
446 }, 454 },
447 455
448 _forceNarrowChanged: function() { 456 _forceNarrowChanged: function() {
449 // set the narrow mode only if we reached the `responsiveWidth` 457 // set the narrow mode only if we reached the `responsiveWidth`
450 this._responsiveChange(this.forceNarrow || this.$.mq.queryMatches); 458 this._responsiveChange(this.forceNarrow || this.$.mq.queryMatches);
451 }, 459 },
452 460
453 _swipeAllowed: function() { 461 _swipeAllowed: function() {
454 return this.narrow && !this.disableSwipe; 462 return this.narrow && !this.disableSwipe;
455 }, 463 },
456 464
457 _isMainSelected: function() { 465 _isMainSelected: function() {
458 return this.selected === 'main'; 466 return this.selected === 'main';
459 }, 467 },
460 468
461 _startEdgePeek: function() { 469 _startEdgePeek: function() {
462 this.width = this.$.drawer.offsetWidth; 470 this.width = this.$.drawer.offsetWidth;
463 this._moveDrawer(this._translateXForDeltaX(this.rightDrawer ? 471 this._moveDrawer(this._translateXForDeltaX(this.rightDrawer ?
464 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity)); 472 -this.edgeSwipeSensitivity : this.edgeSwipeSensitivity));
465 this._setPeeking(true); 473 this._setPeeking(true);
466 }, 474 },
467 475
468 _stopEdgePeek: function() { 476 _stopEdgePeek: function() {
469 if (this.peeking) { 477 if (this.peeking) {
470 this._setPeeking(false); 478 this._setPeeking(false);
471 this._moveDrawer(null); 479 this._moveDrawer(null);
472 } 480 }
473 }, 481 },
474 482
475 _downHandler: function(e) { 483 _downHandler: function(event) {
476 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(e) && !sharedPanel) { 484 if (!this.dragging && this._isMainSelected() && this._isEdgeTouch(event) && !sharedPanel) {
477 this._startEdgePeek(); 485 this._startEdgePeek();
486 // cancel selection
487 event.preventDefault();
478 // grab this panel 488 // grab this panel
479 sharedPanel = this; 489 sharedPanel = this;
480 } 490 }
481 }, 491 },
482 492
483 _upHandler: function() { 493 _upHandler: function() {
484 this._stopEdgePeek(); 494 this._stopEdgePeek();
485 // release the panel 495 // release the panel
486 sharedPanel = null; 496 sharedPanel = null;
487 }, 497 },
488 498
489 _onTap: function(e) { 499 _onTap: function(event) {
490 var targetElement = Polymer.dom(e).localTarget; 500 var targetElement = Polymer.dom(event).localTarget;
491 var isTargetToggleElement = targetElement && 501 var isTargetToggleElement = targetElement &&
492 this.drawerToggleAttribute && 502 this.drawerToggleAttribute &&
493 targetElement.hasAttribute(this.drawerToggleAttribute); 503 targetElement.hasAttribute(this.drawerToggleAttribute);
494 504
495 if (isTargetToggleElement) { 505 if (isTargetToggleElement) {
496 this.togglePanel(); 506 this.togglePanel();
497 } 507 }
498 }, 508 },
499 509
500 _isEdgeTouch: function(e) { 510 _isEdgeTouch: function(event) {
501 var x = e.detail.x; 511 var x = event.detail.x;
502 512
503 return !this.disableEdgeSwipe && this._swipeAllowed() && 513 return !this.disableEdgeSwipe && this._swipeAllowed() &&
504 (this.rightDrawer ? 514 (this.rightDrawer ?
505 x >= this.offsetWidth - this.edgeSwipeSensitivity : 515 x >= this.offsetWidth - this.edgeSwipeSensitivity :
506 x <= this.edgeSwipeSensitivity); 516 x <= this.edgeSwipeSensitivity);
507 }, 517 },
508 518
509 _trackStart: function(event) { 519 _trackStart: function(event) {
510 if (this._swipeAllowed()) { 520 if (this._swipeAllowed()) {
511 sharedPanel = this; 521 sharedPanel = this;
(...skipping 13 matching lines...) Expand all
525 _translateXForDeltaX: function(deltaX) { 535 _translateXForDeltaX: function(deltaX) {
526 var isMain = this._isMainSelected(); 536 var isMain = this._isMainSelected();
527 537
528 if (this.rightDrawer) { 538 if (this.rightDrawer) {
529 return Math.max(0, isMain ? this.width + deltaX : deltaX); 539 return Math.max(0, isMain ? this.width + deltaX : deltaX);
530 } else { 540 } else {
531 return Math.min(0, isMain ? deltaX - this.width : deltaX); 541 return Math.min(0, isMain ? deltaX - this.width : deltaX);
532 } 542 }
533 }, 543 },
534 544
535 _trackX: function(e) { 545 _trackX: function(event) {
536 if (this.dragging) { 546 if (this.dragging) {
537 var dx = e.detail.dx; 547 var dx = event.detail.dx;
538 548
539 if (this.peeking) { 549 if (this.peeking) {
540 if (Math.abs(dx) <= this.edgeSwipeSensitivity) { 550 if (Math.abs(dx) <= this.edgeSwipeSensitivity) {
541 // Ignore trackx until we move past the edge peek. 551 // Ignore trackx until we move past the edge peek.
542 return; 552 return;
543 } 553 }
544 this._setPeeking(false); 554 this._setPeeking(false);
545 } 555 }
546 556
547 this._moveDrawer(this._translateXForDeltaX(dx)); 557 this._moveDrawer(this._translateXForDeltaX(dx));
548 } 558 }
549 }, 559 },
550 560
551 _trackEnd: function(e) { 561 _trackEnd: function(event) {
552 if (this.dragging) { 562 if (this.dragging) {
553 var xDirection = e.detail.dx > 0; 563 var xDirection = event.detail.dx > 0;
554 564
555 this._setDragging(false); 565 this._setDragging(false);
556 this.transition = true; 566 this.transition = true;
557 sharedPanel = null; 567 sharedPanel = null;
558 this._moveDrawer(null); 568 this._moveDrawer(null);
559 569
560 if (this.rightDrawer) { 570 if (this.rightDrawer) {
561 this[xDirection ? 'closeDrawer' : 'openDrawer'](); 571 this[xDirection ? 'closeDrawer' : 'openDrawer']();
562 } else { 572 } else {
563 this[xDirection ? 'openDrawer' : 'closeDrawer'](); 573 this[xDirection ? 'openDrawer' : 'closeDrawer']();
564 } 574 }
565 } 575 }
566 }, 576 },
567 577
568 _transformForTranslateX: function(translateX) { 578 _transformForTranslateX: function(translateX) {
569 if (translateX === null) { 579 if (translateX === null) {
570 return ''; 580 return '';
571 } 581 }
572 582
573 return this.hasWillChange ? 'translateX(' + translateX + 'px)' : 583 return this.hasWillChange ? 'translateX(' + translateX + 'px)' :
574 'translate3d(' + translateX + 'px, 0, 0)'; 584 'translate3d(' + translateX + 'px, 0, 0)';
575 }, 585 },
576 586
577 _moveDrawer: function(translateX) { 587 _moveDrawer: function(translateX) {
578 var s = this.$.drawer.style; 588 this.transform(this._transformForTranslateX(translateX), this.$.drawer);
579
580 if (this.hasTransform) {
581 s.transform = this._transformForTranslateX(translateX);
582 } else {
583 s.webkitTransform = this._transformForTranslateX(translateX);
584 }
585 } 589 }
586 590
587 }); 591 });
588 592
589 }()); 593 }());
590 594
591 </script> 595 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698