Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
fix(card): Add ripple effect on card if primaryAction (closes #106)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed May 14, 2018
1 parent 7743e06 commit e908e47
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions components/card/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<div
class="mdc-card"
:class="classes">
<slot name="media"/>
<div :class="contentClasses">
<div
ref="content"
:class="contentClasses">
<slot name="media"/>
<slot />
</div>
<div
Expand All @@ -25,6 +27,7 @@
</template>

<script>
import { MDCRipple } from '@material/ripple'
import themeClassMixin from '../base/themeClassMixin.js'
export default {
Expand All @@ -45,7 +48,8 @@ export default {
},
data () {
return {
slotObserver: undefined
slotObserver: undefined,
mdcRipple: undefined
}
},
computed: {
Expand All @@ -72,9 +76,14 @@ export default {
childList: true,
subtree: true
})
if (this.primaryAction) { this.mdcRipple = MDCRipple.attachTo(this.$refs.content) }
},
beforeDestroy () {
this.slotObserver.disconnect()
if (typeof this.mdcRipple !== 'undefined') {
this.mdcRipple.destroy()
}
},
methods: {
updateSlots () {
Expand All @@ -93,6 +102,11 @@ export default {
})
}
}
},
watch: {
primaryAction (value) {
value ? this.mdcRipple = MDCRipple.attachTo(this.$refs.content) : this.mdcRipple.destroy()
}
}
}
</script>

0 comments on commit e908e47

Please sign in to comment.