Skip to content

Instantly share code, notes, and snippets.

@ducan-ne
Created May 3, 2018 13:16
Show Gist options
  • Save ducan-ne/9cdc5298d5aadffaf4d788871e8861d9 to your computer and use it in GitHub Desktop.
Save ducan-ne/9cdc5298d5aadffaf4d788871e8861d9 to your computer and use it in GitHub Desktop.
<button is="ladda" :loading="isLoading">Submit</button>
import Ladda from 'ladda'
export default {
props: ['loading'],
render(h) {
return h('button', this.$slots.default)
},
mounted() {
this.$el.className += ' ladda-button'
this.$el['data-spinner-size'] = 35
this.$el['data-spinner-color'] = '#ffffff'
this.ladda = Ladda.create(this.$el)
this.renderLoader()
},
methods: {
renderLoader() {
if (this.loading == true) {
!this.ladda.isLoading() && this.ladda.start()
return
}
this.ladda.stop()
}
},
watch: {
loading(val) {
this.renderLoader()
}
},
beforeDestroy() {
this.ladda.remove()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment