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

Commit

Permalink
contacts-v2: complete the delete animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Oct 30, 2013
1 parent 8972f18 commit d0b00b5
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions shiny/Contacts-v2/components/contacts-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,15 @@
</contacts-detail>
</polymer-ui-overlay>
<div class="addButton" on-tap="{{addAction}}">&#x2b;</div>
<!-- scrubbing -->
<polymer-scrub id="scrub" animation="{{$.slideAnimation.animation}}" snapThreshold="0.2" on-polymer-scrub-animation-end="{{scrubAnimationEndAction}}"></polymer-scrub>
<polymer-animation-group id="slideAnimation" type="par" fillMode="forwards">
<polymer-translate id="translateAnimation" fromX="0" toX="100%" duration="0.6" fillMode="forwards"></polymer-translate>
<polymer-fadein id="fadeAnimation" duration="0.1" fillMode="forwards"></polymer-fadein>
</polymer-animation-group>
<polymer-scrub id="scrub" animation="{{$.slideAnimation.animation}}" snapThreshold="0.2" on-polymer-scrub-animation-end="{{scrubAnimationEndAction}}"></polymer-scrub>
<!-- item delete animation -->
<polymer-translate id="deleteAnimation" duration="0.1" fromY="0" toY="-100%" fillMode="forwards" easing="ease-in" on-polymer-animation-end="{{deleteAnimationEndAction}}"></polymer-translate>
<!-- transition -->
<polymer-animation-group id="activateAnimation" type="par" duration="0.1">
<polymer-translate target="{{$.toolbar}}" fromY="0" toY="-100%"></polymer-translate>
<polymer-fadeout target="{{$.toolbar}}"></polymer-fadeout>
Expand Down Expand Up @@ -261,9 +265,24 @@
this.$.slideAnimation.apply();
},
scrubAnimationEndAction: function(e, detail, sender) {
sender.target.remove();
var index = this.$.mock.withHeaders.indexOf(sender.target.templateInstance.model.contact.__proto__);
console.log('index', index, sender.target.templateInstance.model.contact);
this.deletedContact = sender.target.templateInstance.model.contact.__proto__;
var listRect = this.$.list.getBoundingClientRect();
var itemRect = sender.target.getBoundingClientRect();
var height = listRect.bottom - itemRect.top;
var item = sender.target;
var targets = [];
do {
item = item.nextElementSibling;
if (item.classList.contains('contactItem')) {
targets.push(item);
height -= itemRect.height;
}
} while (height > 0);
this.$.deleteAnimation.target = targets;
this.$.deleteAnimation.play();
},
deleteAnimationEndAction: function(e, detail, sender) {
var index = this.$.mock.withHeaders.indexOf(this.deletedContact);
this.$.mock.withHeaders.splice(index, 1);
this.$.list.forceUpdate();
},
Expand Down

0 comments on commit d0b00b5

Please sign in to comment.