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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js

Issue 2314283002: Roll Polymer (Closed)
Patch Set: dep Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js
index af836e3b6de879af0091ad7a203df398323624e2..8ff13505f405514159cb8fb3fd06f542fb710617 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-collapse/iron-collapse-extracted.js
@@ -32,7 +32,7 @@ Polymer({
},
/**
- * Set noAnimation to true to disable animations
+ * Set noAnimation to true to disable animations.
*
* @attribute noAnimation
*/
@@ -40,6 +40,14 @@ Polymer({
type: Boolean
},
+ /**
+ * Stores the desired size of the collapse body.
+ * @private
+ */
+ _desiredSize: {
+ type: String,
+ value: ''
+ }
},
get dimension() {
@@ -100,20 +108,24 @@ Polymer({
* @param {boolean=} animated if `true` updates the size with an animation, otherwise without.
*/
updateSize: function(size, animated) {
+ // Consider 'auto' as '', to take full size.
+ size = size === 'auto' ? '' : size;
// No change!
- var curSize = this.style[this._dimensionMax];
- if (curSize === size || (size === 'auto' && !curSize)) {
+ if (this._desiredSize === size) {
return;
}
+ this._desiredSize = size;
+
this._updateTransition(false);
+ var willAnimate = animated && !this.noAnimation && this._isDisplayed;
// If we can animate, must do some prep work.
- if (animated && !this.noAnimation && this._isDisplayed) {
+ if (willAnimate) {
// Animation will start at the current size.
var startSize = this._calcSize();
// For `auto` we must calculate what is the final size for the animation.
// After the transition is done, _transitionEnd will set the size back to `auto`.
- if (size === 'auto') {
+ if (size === '') {
this.style[this._dimensionMax] = '';
size = this._calcSize();
}
@@ -124,12 +136,14 @@ Polymer({
this.scrollTop = this.scrollTop;
// Enable animation.
this._updateTransition(true);
+ // If final size is the same as startSize it will not animate.
+ willAnimate = (size !== startSize);
}
// Set the final size.
- if (size === 'auto') {
- this.style[this._dimensionMax] = '';
- } else {
- this.style[this._dimensionMax] = size;
+ this.style[this._dimensionMax] = size;
+ // If it won't animate, call transitionEnd to set correct classes.
+ if (!willAnimate) {
+ this._transitionEnd();
}
},
@@ -168,15 +182,10 @@ Polymer({
if (this.opened) {
this.focus();
}
- if (this.noAnimation) {
- this._transitionEnd();
- }
},
_transitionEnd: function() {
- if (this.opened) {
- this.style[this._dimensionMax] = '';
- }
+ this.style[this._dimensionMax] = this._desiredSize;
this.toggleClass('iron-collapse-closed', !this.opened);
this.toggleClass('iron-collapse-opened', this.opened);
this._updateTransition(false);

Powered by Google App Engine
This is Rietveld 408576698