|
178 | 178 | </contacts-detail>
|
179 | 179 | </polymer-ui-overlay>
|
180 | 180 | <div class="addButton" on-tap="{{addAction}}">+</div>
|
| 181 | + <!-- scrubbing --> |
| 182 | + <polymer-scrub id="scrub" animation="{{$.slideAnimation.animation}}" snapThreshold="0.2" on-polymer-scrub-animation-end="{{scrubAnimationEndAction}}"></polymer-scrub> |
181 | 183 | <polymer-animation-group id="slideAnimation" type="par" fillMode="forwards">
|
182 | 184 | <polymer-translate id="translateAnimation" fromX="0" toX="100%" duration="0.6" fillMode="forwards"></polymer-translate>
|
183 | 185 | <polymer-fadein id="fadeAnimation" duration="0.1" fillMode="forwards"></polymer-fadein>
|
184 | 186 | </polymer-animation-group>
|
185 |
| - <polymer-scrub id="scrub" animation="{{$.slideAnimation.animation}}" snapThreshold="0.2" on-polymer-scrub-animation-end="{{scrubAnimationEndAction}}"></polymer-scrub> |
| 187 | + <!-- item delete animation --> |
| 188 | + <polymer-translate id="deleteAnimation" duration="0.1" fromY="0" toY="-100%" fillMode="forwards" easing="ease-in" on-polymer-animation-end="{{deleteAnimationEndAction}}"></polymer-translate> |
| 189 | + <!-- transition --> |
186 | 190 | <polymer-animation-group id="activateAnimation" type="par" duration="0.1">
|
187 | 191 | <polymer-translate target="{{$.toolbar}}" fromY="0" toY="-100%"></polymer-translate>
|
188 | 192 | <polymer-fadeout target="{{$.toolbar}}"></polymer-fadeout>
|
|
261 | 265 | this.$.slideAnimation.apply();
|
262 | 266 | },
|
263 | 267 | scrubAnimationEndAction: function(e, detail, sender) {
|
264 |
| - sender.target.remove(); |
265 |
| - var index = this.$.mock.withHeaders.indexOf(sender.target.templateInstance.model.contact.__proto__); |
266 |
| - console.log('index', index, sender.target.templateInstance.model.contact); |
| 268 | + this.deletedContact = sender.target.templateInstance.model.contact.__proto__; |
| 269 | + var listRect = this.$.list.getBoundingClientRect(); |
| 270 | + var itemRect = sender.target.getBoundingClientRect(); |
| 271 | + var height = listRect.bottom - itemRect.top; |
| 272 | + var item = sender.target; |
| 273 | + var targets = []; |
| 274 | + do { |
| 275 | + item = item.nextElementSibling; |
| 276 | + if (item.classList.contains('contactItem')) { |
| 277 | + targets.push(item); |
| 278 | + height -= itemRect.height; |
| 279 | + } |
| 280 | + } while (height > 0); |
| 281 | + this.$.deleteAnimation.target = targets; |
| 282 | + this.$.deleteAnimation.play(); |
| 283 | + }, |
| 284 | + deleteAnimationEndAction: function(e, detail, sender) { |
| 285 | + var index = this.$.mock.withHeaders.indexOf(this.deletedContact); |
267 | 286 | this.$.mock.withHeaders.splice(index, 1);
|
268 | 287 | this.$.list.forceUpdate();
|
269 | 288 | },
|
|
0 commit comments