Skip to content

Instantly share code, notes, and snippets.

@davidwallacejackson
Created February 14, 2017 23:00
Show Gist options
  • Select an option

  • Save davidwallacejackson/f33966b3edd905bd642fbf50dbf4e8bf to your computer and use it in GitHub Desktop.

Select an option

Save davidwallacejackson/f33966b3edd905bd642fbf50dbf4e8bf to your computer and use it in GitHub Desktop.
import ResizeSensor from require('css-element-queries/src/ResizeSensor')
export default {
// this will run in addition to any mounted() hook on the component
// using the mixin
mounted () {
this.$resizeSensor = new ResizeSensor(this.$el, () => {
// per the docs (https://vuejs.org/v2/api/#Vue-set),
// this lets you add a reactive data property that wasn't specified in the component's
// data() { } hook
Vue.$set('clientWidth', this.$el.clientWidth)
// then do that again for any other properties set by the library you want to track
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment