Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
update display before removing animation class
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Mar 13, 2018
1 parent c005a2a commit f7fa41a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
25 changes: 10 additions & 15 deletions paper-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ <h2>Header</h2>
},

cancelAnimation: function() {
// Short-cut and cancel all animations and hide
this.classList.remove(this.entryAnimation);
this.classList.remove(this.exitAnimation);
},
Expand All @@ -203,34 +202,30 @@ <h2>Header</h2>
this.classList.add(animation);
if (this._willAnimate() === false) {
console.info(animation + ' animation was not played');
this.classList.remove(animation);
this._finishRender();
this._onAnimationEnd();
}
} else {
this._finishRender();
this._onAnimationEnd();
}
},

/**
* @param {!Event} event
* @param {Event=} event
* @private
*/
_onAnimationEnd: function(event) {
if (event.target !== this) {
if (event && event.target !== this) {
return;
}
// Remove the animation classes.
this.cancelAnimation();
this._finishRender();
},

/**
* @private
*/
_finishRender: function() {
if (this.opened) {
this.classList.remove(this.entryAnimation);
this._finishRenderOpened();
} else {
// Ensure to update display before removing the
// animation class, so that user doesn't see flickering
// e.g. dialog returning to its initial position/opacity.
this.style.display = 'none';
this.classList.remove(this.exitAnimation);
this._finishRenderClosed();
}
},
Expand Down
22 changes: 11 additions & 11 deletions test/paper-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@
dialog.addEventListener('animationend', spy);
dialog.open();
dialog.addEventListener('iron-overlay-opened', function() {
// Wait a RAF so that `animationend` can propagate up and be captured by `spy`.
// Wait for `animationend` to propagate up.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 0, 'no open animation');
dialog.close();
dialog.addEventListener('iron-overlay-closed', function() {
// Wait a RAF so that `animationend` can propagate up and be captured by `spy`.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 0, 'no close animation');
done();
});
});
});
});
dialog.addEventListener('iron-overlay-closed', function() {
// Wait for `animationend` to propagate up.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 0, 'no close animation');
done();
});
});
});
Expand All @@ -123,14 +123,14 @@
dialog.addEventListener('animationend', spy);
dialog.open();
dialog.addEventListener('iron-overlay-opened', function() {
// Wait a RAF so that `animationend` can propagate up and be captured by `spy`.
// Wait for `animationend` to propagate up.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 1, 'open animation ok');
dialog.close();
});
});
dialog.addEventListener('iron-overlay-closed', function() {
// Wait a RAF so that `animationend` can propagate up and be captured by `spy`.
// Wait for `animationend` to propagate up.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 2, 'close animation ok');
done();
Expand All @@ -144,7 +144,7 @@
dialog.addEventListener('animationend', spy);
dialog.open();
dialog.addEventListener('iron-overlay-opened', function() {
// Wait a RAF so that `animationend` can propagate up and be captured by `spy`.
// Wait for `animationend` to propagate up.
requestAnimationFrame(function() {
assert.equal(spy.callCount, 0, 'open animation ok');
done();
Expand Down

0 comments on commit f7fa41a

Please sign in to comment.