Merge branch 'feature/animated-favorite-and-boost' into 'develop'

add a spin animation to favorite and boost actions

See merge request !52
This commit is contained in:
lambadalambda 2017-03-09 03:08:59 -05:00
commit 7a5bed0684
4 changed files with 28 additions and 6 deletions

View File

@ -1,5 +1,10 @@
const FavoriteButton = { const FavoriteButton = {
props: [ 'status' ], props: ['status'],
data () {
return {
animated: false
}
},
methods: { methods: {
favorite () { favorite () {
if (!this.status.favorited) { if (!this.status.favorited) {
@ -7,13 +12,18 @@ const FavoriteButton = {
} else { } else {
this.$store.dispatch('unfavorite', {id: this.status.id}) this.$store.dispatch('unfavorite', {id: this.status.id})
} }
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
} }
}, },
computed: { computed: {
classes () { classes () {
return { return {
'icon-star-empty': !this.status.favorited, 'icon-star-empty': !this.status.favorited,
'icon-star': this.status.favorited 'icon-star': this.status.favorited,
'animate-spin': this.animated
} }
} }
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<i :class='classes' class='favorite-button fa' v-on:click.prevent='favorite()'></i> <i :class='classes' class='favorite-button fa' @click.prevent='favorite()'/>
<span v-if='status.fave_num > 0'>{{status.fave_num}}</span> <span v-if='status.fave_num > 0'>{{status.fave_num}}</span>
</div> </div>
</template> </template>
@ -10,6 +10,7 @@
<style lang='scss'> <style lang='scss'>
.favorite-button { .favorite-button {
cursor: pointer; cursor: pointer;
animation-duration: 0.6s;
&:hover { &:hover {
color: orange; color: orange;
} }
@ -17,4 +18,5 @@
.icon-star { .icon-star {
color: orange; color: orange;
} }
</style> </style>

View File

@ -1,16 +1,26 @@
const RetweetButton = { const RetweetButton = {
props: [ 'status' ], props: ['status'],
data () {
return {
animated: false
}
},
methods: { methods: {
retweet () { retweet () {
if (!this.status.repeated) { if (!this.status.repeated) {
this.$store.dispatch('retweet', {id: this.status.id}) this.$store.dispatch('retweet', {id: this.status.id})
} }
this.animated = true
setTimeout(() => {
this.animated = false
}, 500)
} }
}, },
computed: { computed: {
classes () { classes () {
return { return {
'retweeted': this.status.repeated 'retweeted': this.status.repeated,
'animate-spin': this.animated
} }
} }
} }

View File

@ -11,12 +11,12 @@
@import '../../_variables.scss'; @import '../../_variables.scss';
.icon-retweet { .icon-retweet {
cursor: pointer; cursor: pointer;
animation-duration: 0.6s;
&:hover { &:hover {
color: $green; color: $green;
} }
} }
.retweeted { .retweeted {
cursor: auto;
color: $green; color: $green;
} }
</style> </style>