Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit d0b00b5

Browse files
author
Yvonne Yip
committed
contacts-v2: complete the delete animation
1 parent 8972f18 commit d0b00b5

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

shiny/Contacts-v2/components/contacts-list.html

+23-4
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@
178178
</contacts-detail>
179179
</polymer-ui-overlay>
180180
<div class="addButton" on-tap="{{addAction}}">&#x2b;</div>
181+
<!-- scrubbing -->
182+
<polymer-scrub id="scrub" animation="{{$.slideAnimation.animation}}" snapThreshold="0.2" on-polymer-scrub-animation-end="{{scrubAnimationEndAction}}"></polymer-scrub>
181183
<polymer-animation-group id="slideAnimation" type="par" fillMode="forwards">
182184
<polymer-translate id="translateAnimation" fromX="0" toX="100%" duration="0.6" fillMode="forwards"></polymer-translate>
183185
<polymer-fadein id="fadeAnimation" duration="0.1" fillMode="forwards"></polymer-fadein>
184186
</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 -->
186190
<polymer-animation-group id="activateAnimation" type="par" duration="0.1">
187191
<polymer-translate target="{{$.toolbar}}" fromY="0" toY="-100%"></polymer-translate>
188192
<polymer-fadeout target="{{$.toolbar}}"></polymer-fadeout>
@@ -261,9 +265,24 @@
261265
this.$.slideAnimation.apply();
262266
},
263267
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);
267286
this.$.mock.withHeaders.splice(index, 1);
268287
this.$.list.forceUpdate();
269288
},

0 commit comments

Comments
 (0)