3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11 <link rel=
"import" href=
"../polymer/polymer.html">
12 <link rel=
"import" href=
"../paper-styles/typography.html">
13 <link rel=
"import" href=
"../iron-a11y-announcer/iron-a11y-announcer.html">
16 `paper-toast` provides a subtle notification toast.
23 <dom-module id=
"paper-toast">
26 display: inline-block;
33 padding:
16px
24px
12px;
34 box-sizing: border-box;
35 box-shadow:
0 2px
5px
0 rgba(
0,
0,
0,
0.26);
42 -webkit-transition: visibility
0.3s, -webkit-transform
0.3s;
43 transition: visibility
0.3s, transform
0.3s;
45 -webkit-transform: translateY(
100px);
46 transform: translateY(
100px);
63 :host(.paper-toast-open){
66 -webkit-transform: translateY(
0px);
67 transform: translateY(
0px);
71 <span id=
"label">{{text}}
</span>
78 var PaperToast
= Polymer({
83 * The duration in milliseconds to show the toast.
91 * The text to display in the toast.
99 * True if the toast is currently visible.
105 observer
: '_visibleChanged'
109 created: function() {
110 Polymer
.IronA11yAnnouncer
.requestAvailability();
114 this.async(function() {
124 if (PaperToast
.currentToast
) {
125 PaperToast
.currentToast
.hide();
127 PaperToast
.currentToast
= this;
128 this.removeAttribute('aria-hidden');
129 this._setVisible(true);
130 this.fire('iron-announce', {
133 this.debounce('hide', this.hide
, this.duration
);
140 this.setAttribute('aria-hidden', 'true');
141 this._setVisible(false);
145 * Toggle the opened state of the toast.
156 _visibleChanged: function(visible
) {
157 this.toggleClass('paper-toast-open', visible
);
161 PaperToast
.currentToast
= null;