Animate user card popovers

This commit is contained in:
Toby Zerner 2015-03-18 09:12:38 +10:30
parent fe982aa587
commit 018eb7d062
2 changed files with 12 additions and 3 deletions

View File

@ -7,7 +7,7 @@ var precompileTemplate = Ember.Handlebars.compile;
*/
export default Ember.Component.extend({
classNames: ['post-user'],
layout: precompileTemplate('{{#if post.user}}<h3>{{#link-to "user" post.user}}{{user-avatar post.user}} {{user-name post.user}}{{/link-to}} {{ui/item-list items=post.user.badges class="badges"}}</h3>{{#if showCard}}{{user/user-card user=post.user class="user-card-popover" controlsButtonClass="btn btn-default btn-icon btn-sm btn-naked"}}{{/if}}{{else}}<h3>{{user-avatar post.user}} {{user-name post.user}}</h3>{{/if}}'),
layout: precompileTemplate('{{#if post.user}}<h3>{{#link-to "user" post.user}}{{user-avatar post.user}} {{user-name post.user}}{{/link-to}} {{ui/item-list items=post.user.badges class="badges"}}</h3>{{#if showCard}}{{user/user-card user=post.user class="user-card-popover fade" controlsButtonClass="btn btn-default btn-icon btn-sm btn-naked"}}{{/if}}{{else}}<h3>{{user-avatar post.user}} {{user-name post.user}}</h3>{{/if}}'),
didInsertElement: function() {
var component = this;
@ -16,11 +16,16 @@ export default Ember.Component.extend({
clearTimeout(timeout);
timeout = setTimeout(function() {
component.set('showCard', true);
Ember.run.scheduleOnce('afterRender', function() {
Ember.run.next(function() { component.$('.user-card').addClass('in'); });
});
}, 250);
}).bind('mouseout', '> a, .user-card', function() {
clearTimeout(timeout);
timeout = setTimeout(function() {
component.set('showCard', false);
component.$('.user-card').removeClass('in').one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
component.set('showCard', false);
});
}, 250);
});
}

View File

@ -191,8 +191,12 @@
& .user-card {
position: absolute;
top: 100%;
margin-top: 5px;
z-index: @zindex-popover;
.transition(~"opacity 0.2s, margin-top 0.2s");
&.in {
margin-top: 5px;
}
}
}
}