Skip to content

Commit

Permalink
Merge pull request PolymerElements#65 from lyio/master
Browse files Browse the repository at this point in the history
PolymerElements#64 paper-toast does not fire closed events
  • Loading branch information
valdrinkoshi committed Feb 5, 2016
2 parents 33c8ff5 + adfc662 commit 202b859
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 24 additions & 1 deletion paper-toast.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@
noCancelOnOutsideClick: {
type: Boolean,
value: true
},
}
},

listeners: {
'transitionend': '__onTransitionEnd'
},

/**
Expand Down Expand Up @@ -206,6 +210,25 @@
this.close();
},

/**
* Called on transitions of the toast, indicating a finished animation
*
* @private
*/
__onTransitionEnd: function(e) {
// there are at least three different transitions that are happening when opening and
// closing the toast. The last one so far is for `opacity`.
// This marks the end of the transition, so we check for this to determine if this
// is the correct event.
if (e && e.target === this && e.propertyName === 'opacity') {
if (this.opened) {
this._finishRenderOpened();
} else {
this._finishRenderClosed();
}
}
},

/**
* Overridden from `IronOverlayBehavior`.
* Called when the value of `opened` changes.
Expand Down
15 changes: 15 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@
done();
}, 12);
});

test('toast fires closed event', function(done) {
toast = fixture('show');
toast.addEventListener('iron-overlay-opened', toast.close.bind(toast));
toast.addEventListener('iron-overlay-closed', function() {
done();
});
});

test('toast fires opened event', function(done) {
toast = fixture('show');
toast.addEventListener('iron-overlay-opened', function() {
done();
});
});

test('show() accepts valid properties', function() {
toast = fixture('basic');
Expand Down

0 comments on commit 202b859

Please sign in to comment.