Skip to content

Instantly share code, notes, and snippets.

@rubenestevao
Created September 7, 2018 19:56
Show Gist options
  • Save rubenestevao/7c2465e584745a10205ddf07ccc58923 to your computer and use it in GitHub Desktop.
Save rubenestevao/7c2465e584745a10205ddf07ccc58923 to your computer and use it in GitHub Desktop.
<script>
/**
* @link https://jsfiddle.net/adamwathan/2juusxqo/
*/
const erd = elementResizeDetectorMaker({ strategy: 'scroll' });
export default {
data() {
return {
width: null,
height: null,
};
},
mounted() {
erd.listenTo(this.$el, (el) => {
this.width = el.offsetWidth;
this.height = el.offsetHeight;
});
},
render() {
return this.$scopedSlots.default({
width: this.width,
height: this.height,
});
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment