7 Polymer('paper-toast', {
10 * The text shows in a toast.
19 * The duration in milliseconds to show the toast.
28 * Set opened to true to show the toast and to false to hide it.
37 * Min-width when the toast changes to narrow layout. In narrow layout,
38 * the toast fits at the bottom of the screen when opened.
40 * @attribute responsiveWidth
44 responsiveWidth: '480px',
47 * If true, the toast can't be swiped.
49 * @attribute swipeDisabled
56 * By default, the toast will close automatically if the user taps
57 * outside it or presses the escape key. Disable this behavior by setting
58 * the `autoCloseDisabled` property to true.
60 * @attribute autoCloseDisabled
64 autoCloseDisabled: false,
69 trackstart: 'trackStart',
72 transitionend: 'transitionEnd'
75 narrowModeChanged: function() {
76 this.classList.toggle('fit-bottom', this.narrowMode);
78 this.$.overlay.resizeHandler();
82 openedChanged: function() {
84 this.dismissJob = this.job(this.dismissJob, this.dismiss, this.duration);
86 this.dismissJob && this.dismissJob.stop();
92 * Toggle the opened state of the toast.
96 this.opened = !this.opened;
100 * Show the toast for the specified duration
105 currentToast.dismiss();
112 * Dismiss the toast and hide it.
115 dismiss: function() {
117 this.shouldDismiss = true;
120 if (currentToast === this) {
126 trackStart: function(e) {
127 if (!this.swipeDisabled) {
129 this.vertical = e.yDirection;
130 this.w = this.offsetWidth;
131 this.h = this.offsetHeight;
132 this.dragging = true;
133 this.classList.add('dragging');
142 s.opacity = (this.h - Math.abs(y)) / this.h;
143 s.transform = s.webkitTransform = 'translate3d(0, ' + y + 'px, 0)';
146 s.opacity = (this.w - Math.abs(x)) / this.w;
147 s.transform = s.webkitTransform = 'translate3d(' + x + 'px, 0, 0)';
152 trackEnd: function(e) {
154 this.classList.remove('dragging');
155 this.style.opacity = '';
156 this.style.transform = this.style.webkitTransform = '';
157 var cl = this.classList;
159 cl.toggle('fade-out-down', e.yDirection === 1 && e.dy > 0);
160 cl.toggle('fade-out-up', e.yDirection === -1 && e.dy < 0);
162 cl.toggle('fade-out-right', e.xDirection === 1 && e.dx > 0);
163 cl.toggle('fade-out-left', e.xDirection === -1 && e.dx < 0);
165 this.dragging = false;
169 transitionEnd: function() {
170 var cl = this.classList;
171 if (cl.contains('fade-out-right') || cl.contains('fade-out-left') ||
172 cl.contains('fade-out-down') || cl.contains('fade-out-up')) {
174 cl.remove('fade-out-right', 'fade-out-left',
175 'fade-out-down', 'fade-out-up');
176 } else if (this.shouldDismiss) {
179 this.shouldDismiss = false;