Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
slight refactoring; remove timeout since it's not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiefu committed Sep 11, 2013
1 parent 03b7178 commit 7d794af
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions polymer-collapse/polymer-collapse.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
this.target.classList.toggle('polymer-collapse-closed', add);
},
updateSize: function(size, duration, forceEnd) {
if (duration) {
this.calcSize();
}
this.setTransitionDuration(duration);
var s = this.target.style;
var nochange = s[this.dimension] === size;
Expand All @@ -188,6 +191,9 @@
calcSize: function() {
return this.target.getBoundingClientRect()[this.dimension] + 'px';
},
getComputedSize: function() {
return getComputedStyle(this.target)[this.dimension];
},
show: function() {
this.toggleClosedClass(false);
// for initial update, skip the expanding animation to optimize
Expand All @@ -204,7 +210,7 @@
}
this.async(function() {
this.updateSize(this.size || s, this.duration, true);
}, null, 1);
});
},
hide: function() {
this.afterInitialUpdate = true;
Expand All @@ -214,13 +220,13 @@
}
if (this.fixedSize) {
// save the size before hiding it
this.size = getComputedStyle(this.target)[this.dimension];
this.size = this.getComputedSize();
} else {
this.updateSize(this.calcSize(), null);
}
this.async(function() {
this.updateSize(0, this.duration);
}, null, 1);
});
}
});
</script>
Expand Down

0 comments on commit 7d794af

Please sign in to comment.