OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 | 9 |
10 <!-- | 10 <!-- |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 Positioning toast: | 37 Positioning toast: |
38 | 38 |
39 A standard toast appears near the lower left of the screen. You can change the | 39 A standard toast appears near the lower left of the screen. You can change the |
40 position by overriding bottom and left positions. | 40 position by overriding bottom and left positions. |
41 | 41 |
42 paper-toast { | 42 paper-toast { |
43 bottom: 40px; | 43 bottom: 40px; |
44 left: 10px; | 44 left: 10px; |
45 } | 45 } |
| 46 |
| 47 To position the toast to the right: |
| 48 |
| 49 paper-toast { |
| 50 right: 10px; |
| 51 left: auto; |
| 52 } |
46 | 53 |
47 To make it fit at the bottom of the screen: | 54 To make it fit at the bottom of the screen: |
48 | 55 |
49 paper-toast { | 56 paper-toast { |
50 bottom: 0; | 57 bottom: 0; |
51 left: 0; | 58 left: 0; |
52 width: 100%; | 59 width: 100%; |
53 } | 60 } |
54 | 61 |
55 When the screen size is smaller than the `responsiveWidth` (default to 480px), | 62 When the screen size is smaller than the `responsiveWidth` (default to 480px), |
56 the toast will automatically fits at the bottom of the screen. | 63 the toast will automatically fits at the bottom of the screen. |
57 | 64 |
58 @group Paper Elements | 65 @group Paper Elements |
59 @element paper-toast | 66 @element paper-toast |
60 @homepage github.io | 67 @homepage github.io |
61 --> | 68 --> |
| 69 <!-- |
| 70 Fired when the `paper-toast`'s `opened` property changes. |
62 | 71 |
| 72 @event core-overlay-open |
| 73 @param {boolean} detail the opened state |
| 74 --> |
| 75 <!-- |
| 76 Fired when the `paper-toast` has completely opened. |
| 77 |
| 78 @event core-overlay-open-completed |
| 79 --> |
| 80 <!-- |
| 81 Fired when the `paper-toast` has completely closed. |
| 82 |
| 83 @event core-overlay-close-completed |
| 84 --> |
63 <link rel="import" href="../core-overlay/core-overlay.html"> | 85 <link rel="import" href="../core-overlay/core-overlay.html"> |
64 <link rel="import" href="../core-transition/core-transition-css.html"> | 86 <link rel="import" href="../core-transition/core-transition-css.html"> |
65 <link rel="import" href="../core-media-query/core-media-query.html"> | 87 <link rel="import" href="../core-media-query/core-media-query.html"> |
66 | 88 |
67 <polymer-element name="paper-toast" attributes="text duration opened responsiveW
idth swipeDisabled" role="status"> | 89 <polymer-element name="paper-toast" attributes="text duration opened responsiveW
idth swipeDisabled autoCloseDisabled" role="status"> |
68 | 90 |
69 <template> | 91 <template> |
70 | 92 |
71 <link rel="stylesheet" href="paper-toast.css" > | 93 <link rel="stylesheet" href="paper-toast.css" > |
72 | 94 |
73 <core-overlay autoFocusDisabled opened="{{opened}}" target="{{}}" sizingTarget
="{{$.container}}" transition="core-transition-bottom"></core-overlay> | 95 <core-overlay id="overlay" autoFocusDisabled autoCloseDisabled="{{autoCloseDis
abled}}" opened="{{opened}}" target="{{}}" transition="core-transition-bottom"><
/core-overlay> |
74 | 96 |
75 <div class="toast-container" horizontal layout> | 97 <div class="toast-container" horizontal layout> |
76 | 98 |
77 <div class="toast-text" flex>{{text}}</div> | 99 <div class="toast-text" flex>{{text}}</div> |
78 | 100 |
79 <div class="toast-text toast-action" on-tap="{{dismiss}}"> | 101 <div class="toast-text toast-action" on-tap="{{dismiss}}"> |
80 <content></content> | 102 <content></content> |
81 </div> | 103 </div> |
82 | 104 |
83 </div> | 105 </div> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 154 |
133 /** | 155 /** |
134 * If true, the toast can't be swiped. | 156 * If true, the toast can't be swiped. |
135 * | 157 * |
136 * @attribute swipeDisabled | 158 * @attribute swipeDisabled |
137 * @type boolean | 159 * @type boolean |
138 * @default false | 160 * @default false |
139 */ | 161 */ |
140 swipeDisabled: false, | 162 swipeDisabled: false, |
141 | 163 |
| 164 /** |
| 165 * By default, the toast will close automatically if the user taps |
| 166 * outside it or presses the escape key. Disable this behavior by setting |
| 167 * the `autoCloseDisabled` property to true. |
| 168 * |
| 169 * @attribute autoCloseDisabled |
| 170 * @type boolean |
| 171 * @default false |
| 172 */ |
| 173 autoCloseDisabled: false, |
| 174 |
| 175 narrowMode: false, |
| 176 |
142 eventDelegates: { | 177 eventDelegates: { |
143 trackstart: 'trackStart', | 178 trackstart: 'trackStart', |
144 track: 'track', | 179 track: 'track', |
145 trackend: 'trackEnd', | 180 trackend: 'trackEnd', |
146 transitionend: 'transitionEnd' | 181 transitionend: 'transitionEnd' |
147 }, | 182 }, |
148 | 183 |
149 narrowModeChanged: function() { | 184 narrowModeChanged: function() { |
150 this.classList.toggle('fit-bottom', this.narrowMode); | 185 this.classList.toggle('fit-bottom', this.narrowMode); |
| 186 if (this.opened) { |
| 187 this.$.overlay.resizeHandler(); |
| 188 } |
151 }, | 189 }, |
152 | 190 |
153 openedChanged: function() { | 191 openedChanged: function() { |
154 if (this.opened) { | 192 if (this.opened) { |
155 this.dismissJob = this.job(this.dismissJob, this.dismiss, this.duratio
n); | 193 this.dismissJob = this.job(this.dismissJob, this.dismiss, this.duratio
n); |
156 } else { | 194 } else { |
157 this.dismissJob && this.dismissJob.stop(); | 195 this.dismissJob && this.dismissJob.stop(); |
158 this.dismiss(); | 196 this.dismiss(); |
159 } | 197 } |
160 }, | 198 }, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 this.classList.add('dragging'); | 242 this.classList.add('dragging'); |
205 } | 243 } |
206 }, | 244 }, |
207 | 245 |
208 track: function(e) { | 246 track: function(e) { |
209 if (this.dragging) { | 247 if (this.dragging) { |
210 var s = this.style; | 248 var s = this.style; |
211 if (this.vertical) { | 249 if (this.vertical) { |
212 var y = e.dy; | 250 var y = e.dy; |
213 s.opacity = (this.h - Math.abs(y)) / this.h; | 251 s.opacity = (this.h - Math.abs(y)) / this.h; |
214 s.webkitTransform = s.transform = 'translate3d(0, ' + y + 'px, 0)'; | 252 s.transform = s.webkitTransform = 'translate3d(0, ' + y + 'px, 0)'; |
215 } else { | 253 } else { |
216 var x = e.dx; | 254 var x = e.dx; |
217 s.opacity = (this.w - Math.abs(x)) / this.w; | 255 s.opacity = (this.w - Math.abs(x)) / this.w; |
218 s.webkitTransform = s.transform = 'translate3d(' + x + 'px, 0, 0)'; | 256 s.transform = s.webkitTransform = 'translate3d(' + x + 'px, 0, 0)'; |
219 } | 257 } |
220 } | 258 } |
221 }, | 259 }, |
222 | 260 |
223 trackEnd: function(e) { | 261 trackEnd: function(e) { |
224 if (this.dragging) { | 262 if (this.dragging) { |
225 this.classList.remove('dragging'); | 263 this.classList.remove('dragging'); |
226 this.style.opacity = null; | 264 this.style.opacity = ''; |
227 this.style.webkitTransform = this.style.transform = null; | 265 this.style.transform = this.style.webkitTransform = ''; |
228 var cl = this.classList; | 266 var cl = this.classList; |
229 if (this.vertical) { | 267 if (this.vertical) { |
230 cl.toggle('fade-out-down', e.yDirection === 1 && e.dy > 0); | 268 cl.toggle('fade-out-down', e.yDirection === 1 && e.dy > 0); |
231 cl.toggle('fade-out-up', e.yDirection === -1 && e.dy < 0); | 269 cl.toggle('fade-out-up', e.yDirection === -1 && e.dy < 0); |
232 } else { | 270 } else { |
233 cl.toggle('fade-out-right', e.xDirection === 1 && e.dx > 0); | 271 cl.toggle('fade-out-right', e.xDirection === 1 && e.dx > 0); |
234 cl.toggle('fade-out-left', e.xDirection === -1 && e.dx < 0); | 272 cl.toggle('fade-out-left', e.xDirection === -1 && e.dx < 0); |
235 } | 273 } |
236 this.dragging = false; | 274 this.dragging = false; |
237 } | 275 } |
(...skipping 11 matching lines...) Expand all Loading... |
249 } | 287 } |
250 this.shouldDismiss = false; | 288 this.shouldDismiss = false; |
251 } | 289 } |
252 | 290 |
253 }); | 291 }); |
254 | 292 |
255 })(); | 293 })(); |
256 | 294 |
257 </script> | 295 </script> |
258 </polymer-element> | 296 </polymer-element> |
OLD | NEW |