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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-tabs/paper-tabs-extracted.js

Issue 2074813002: Roll Polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromium.patch Created 4 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 Polymer({ 1 Polymer({
2 is: 'paper-tabs', 2 is: 'paper-tabs',
3 3
4 behaviors: [ 4 behaviors: [
5 Polymer.IronResizableBehavior, 5 Polymer.IronResizableBehavior,
6 Polymer.IronMenubarBehavior 6 Polymer.IronMenubarBehavior
7 ], 7 ],
8 8
9 properties: { 9 properties: {
10 /** 10 /**
(...skipping 25 matching lines...) Expand all
36 36
37 /** 37 /**
38 * If true, tabs are scrollable and the tab width is based on the label width. 38 * If true, tabs are scrollable and the tab width is based on the label width.
39 */ 39 */
40 scrollable: { 40 scrollable: {
41 type: Boolean, 41 type: Boolean,
42 value: false 42 value: false
43 }, 43 },
44 44
45 /** 45 /**
46 * If true, tabs expand to fit their container. This currently only appl ies when
47 * scrollable is true.
48 */
49 fitContainer: {
50 type: Boolean,
51 value: false
52 },
53
54 /**
46 * If true, dragging on the tabs to scroll is disabled. 55 * If true, dragging on the tabs to scroll is disabled.
47 */ 56 */
48 disableDrag: { 57 disableDrag: {
49 type: Boolean, 58 type: Boolean,
50 value: false 59 value: false
51 }, 60 },
52 61
53 /** 62 /**
54 * If true, scroll buttons (left/right arrow) will be hidden for scrolla ble tabs. 63 * If true, scroll buttons (left/right arrow) will be hidden for scrolla ble tabs.
55 */ 64 */
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return 'hidden'; 173 return 'hidden';
165 } 174 }
166 175
167 if (hideThisButton) { 176 if (hideThisButton) {
168 return 'not-visible'; 177 return 'not-visible';
169 } 178 }
170 179
171 return ''; 180 return '';
172 }, 181 },
173 182
174 _computeTabsContentClass: function(scrollable) { 183 _computeTabsContentClass: function(scrollable, fitContainer) {
175 return scrollable ? 'scrollable' : 'horizontal'; 184 return scrollable ? 'scrollable' + (fitContainer ? ' fit-container' : '' ) : ' fit-container';
176 }, 185 },
177 186
178 _computeSelectionBarClass: function(noBar, alignBottom) { 187 _computeSelectionBarClass: function(noBar, alignBottom) {
179 if (noBar) { 188 if (noBar) {
180 return 'hidden'; 189 return 'hidden';
181 } else if (alignBottom) { 190 } else if (alignBottom) {
182 return 'align-bottom'; 191 return 'align-bottom';
183 } 192 }
184 193
185 return ''; 194 return '';
(...skipping 10 matching lines...) Expand all
196 205
197 _onIronSelect: function(event) { 206 _onIronSelect: function(event) {
198 this._tabChanged(event.detail.item, this._previousTab); 207 this._tabChanged(event.detail.item, this._previousTab);
199 this._previousTab = event.detail.item; 208 this._previousTab = event.detail.item;
200 this.cancelDebouncer('tab-changed'); 209 this.cancelDebouncer('tab-changed');
201 }, 210 },
202 211
203 _onIronDeselect: function(event) { 212 _onIronDeselect: function(event) {
204 this.debounce('tab-changed', function() { 213 this.debounce('tab-changed', function() {
205 this._tabChanged(null, this._previousTab); 214 this._tabChanged(null, this._previousTab);
215 this._previousTab = null;
206 // See polymer/polymer#1305 216 // See polymer/polymer#1305
207 }, 1); 217 }, 1);
208 }, 218 },
209 219
210 _activateHandler: function() { 220 _activateHandler: function() {
211 // Cancel item activations scheduled by keyboard events when any other 221 // Cancel item activations scheduled by keyboard events when any other
212 // action causes an item to be activated (e.g. clicks). 222 // action causes an item to be activated (e.g. clicks).
213 this._cancelPendingActivation(); 223 this._cancelPendingActivation();
214 224
215 Polymer.IronMenuBehaviorImpl._activateHandler.apply(this, arguments); 225 Polymer.IronMenuBehaviorImpl._activateHandler.apply(this, arguments);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 _scrollToLeft: function() { 328 _scrollToLeft: function() {
319 this._affectScroll(-this._step); 329 this._affectScroll(-this._step);
320 }, 330 },
321 331
322 _scrollToRight: function() { 332 _scrollToRight: function() {
323 this._affectScroll(this._step); 333 this._affectScroll(this._step);
324 }, 334 },
325 335
326 _tabChanged: function(tab, old) { 336 _tabChanged: function(tab, old) {
327 if (!tab) { 337 if (!tab) {
338 // Remove the bar without animation.
339 this.$.selectionBar.classList.remove('expand');
340 this.$.selectionBar.classList.remove('contract');
328 this._positionBar(0, 0); 341 this._positionBar(0, 0);
329 return; 342 return;
330 } 343 }
331 344
332 var r = this.$.tabsContent.getBoundingClientRect(); 345 var r = this.$.tabsContent.getBoundingClientRect();
333 var w = r.width; 346 var w = r.width;
334 var tabRect = tab.getBoundingClientRect(); 347 var tabRect = tab.getBoundingClientRect();
335 var tabOffsetLeft = tabRect.left - r.left; 348 var tabOffsetLeft = tabRect.left - r.left;
336 349
337 this._pos = { 350 this._pos = {
338 width: this._calcPercent(tabRect.width, w), 351 width: this._calcPercent(tabRect.width, w),
339 left: this._calcPercent(tabOffsetLeft, w) 352 left: this._calcPercent(tabOffsetLeft, w)
340 }; 353 };
341 354
342 if (this.noSlide || old == null) { 355 if (this.noSlide || old == null) {
343 // position bar directly without animation 356 // Position the bar without animation.
357 this.$.selectionBar.classList.remove('expand');
358 this.$.selectionBar.classList.remove('contract');
344 this._positionBar(this._pos.width, this._pos.left); 359 this._positionBar(this._pos.width, this._pos.left);
345 return; 360 return;
346 } 361 }
347 362
348 var oldRect = old.getBoundingClientRect(); 363 var oldRect = old.getBoundingClientRect();
349 var oldIndex = this.items.indexOf(old); 364 var oldIndex = this.items.indexOf(old);
350 var index = this.items.indexOf(tab); 365 var index = this.items.indexOf(tab);
351 var m = 5; 366 var m = 5;
352 367
353 // bar animation: expand 368 // bar animation: expand
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return 100 * w / w0; 403 return 100 * w / w0;
389 }, 404 },
390 405
391 _positionBar: function(width, left) { 406 _positionBar: function(width, left) {
392 width = width || 0; 407 width = width || 0;
393 left = left || 0; 408 left = left || 0;
394 409
395 this._width = width; 410 this._width = width;
396 this._left = left; 411 this._left = left;
397 this.transform( 412 this.transform(
398 'translate3d(' + left + '%, 0, 0) scaleX(' + (width / 100) + ')', 413 'translateX(' + left + '%) scaleX(' + (width / 100) + ')',
399 this.$.selectionBar); 414 this.$.selectionBar);
400 }, 415 },
401 416
402 _onBarTransitionEnd: function(e) { 417 _onBarTransitionEnd: function(e) {
403 var cl = this.$.selectionBar.classList; 418 var cl = this.$.selectionBar.classList;
404 // bar animation: expand -> contract 419 // bar animation: expand -> contract
405 if (cl.contains('expand')) { 420 if (cl.contains('expand')) {
406 cl.remove('expand'); 421 cl.remove('expand');
407 cl.add('contract'); 422 cl.add('contract');
408 this._positionBar(this._pos.width, this._pos.left); 423 this._positionBar(this._pos.width, this._pos.left);
409 // bar animation done 424 // bar animation done
410 } else if (cl.contains('contract')) { 425 } else if (cl.contains('contract')) {
411 cl.remove('contract'); 426 cl.remove('contract');
412 } 427 }
413 } 428 }
414 }); 429 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698