vue-element-Resize-detector
Vue Directive to detect resize events on elements or components. Uses element Resize Detector under the hood.
⚙️ Installation
$ npm install vue-fabric-wrapper
? How to use in Vue
In main.js
import resize from "vue-element-resize-detector";
Vue.use(resize)
<template>
<div id="app">
<h1>Vue Element Resize Detector</h1>
<div v-resize @resize="onResize">This divs with is: {{ width }}</div>
</div>
</template>
<script>
export default {
name: "app",
data() {
return {
width: 0
};
},
methods: {
onResize(e) {
console.log("resize event", e.detail.width, e.detail.height);
this.width = e.detail.width;
}
}
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>