Skip to content

Commit

Permalink
fix(list): make props reactive
Browse files Browse the repository at this point in the history
fix #231
  • Loading branch information
stasson committed Jan 29, 2018
1 parent 6da65cc commit bb6aeea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
38 changes: 31 additions & 7 deletions components/list/mdc-list-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default {
return this.mdcList && this.mdcList.interactive
},
hasSecondary () {
return !!this.$slots['secondary']
return this.$slots['secondary'] && (
this.mdcList && this.mdcList.twoLine
)
},
hasEndDetail () {
return !!this.$slots['end-detail']
Expand All @@ -48,16 +50,38 @@ export default {
return !!this.$slots['start-detail']
}
},
mounted () {
if (this.isInteractive) {
this.ripple = new RippleBase(this)
this.ripple.init()
watch: {
isInteractive (value) {
if (value) {
this.addRipple()
} else {
this.removeRipple()
}
}
},
mounted () {
this.isInteractive && this.addRipple()
},
beforeDestroy () {
this.ripple && this.ripple.destroy()
this.ripple = null
this.removeRipple()
},
methods: {
addRipple () {
if (!this.ripple) {
let ripple = new RippleBase(this)
ripple.init()
this.ripple = ripple
}
},
removeRipple () {
if (this.ripple) {
let ripple = this.ripple
this.ripple = null
ripple.destroy()
}
}
}
}
</script>

6 changes: 3 additions & 3 deletions components/list/mdc-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default {
provide () {
return { mdcList: this }
},
data () {
return {
classes: {
computed: {
classes () {
return {
'mdc-list--dense': this.dense,
'mdc-list--avatar-list': this.avatarList,
'mdc-list--two-line': this.twoLine,
Expand Down

0 comments on commit bb6aeea

Please sign in to comment.