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 trackstart: 'trackStart',
59 transitionend: 'transitionEnd'
62 narrowModeChanged: function() {
63 this.classList.toggle('fit-bottom', this.narrowMode);
66 openedChanged: function() {
68 this.dismissJob = this.job(this.dismissJob, this.dismiss, this.duration);
70 this.dismissJob && this.dismissJob.stop();
76 * Toggle the opened state of the toast.
80 this.opened = !this.opened;
84 * Show the toast for the specified duration
89 currentToast.dismiss();
96 * Dismiss the toast and hide it.
101 this.shouldDismiss = true;
104 if (currentToast === this) {
110 trackStart: function(e) {
111 if (!this.swipeDisabled) {
113 this.vertical = e.yDirection;
114 this.w = this.offsetWidth;
115 this.h = this.offsetHeight;
116 this.dragging = true;
117 this.classList.add('dragging');
126 s.opacity = (this.h - Math.abs(y)) / this.h;
127 s.webkitTransform = s.transform = 'translate3d(0, ' + y + 'px, 0)';
130 s.opacity = (this.w - Math.abs(x)) / this.w;
131 s.webkitTransform = s.transform = 'translate3d(' + x + 'px, 0, 0)';
136 trackEnd: function(e) {
138 this.classList.remove('dragging');
139 this.style.opacity = null;
140 this.style.webkitTransform = this.style.transform = null;
141 var cl = this.classList;
143 cl.toggle('fade-out-down', e.yDirection === 1 && e.dy > 0);
144 cl.toggle('fade-out-up', e.yDirection === -1 && e.dy < 0);
146 cl.toggle('fade-out-right', e.xDirection === 1 && e.dx > 0);
147 cl.toggle('fade-out-left', e.xDirection === -1 && e.dx < 0);
149 this.dragging = false;
153 transitionEnd: function() {
154 var cl = this.classList;
155 if (cl.contains('fade-out-right') || cl.contains('fade-out-left') ||
156 cl.contains('fade-out-down') || cl.contains('fade-out-up')) {
158 cl.remove('fade-out-right', 'fade-out-left',
159 'fade-out-down', 'fade-out-up');
160 } else if (this.shouldDismiss) {
163 this.shouldDismiss = false;