Nertivia-Client/src/utils/windowProperties.js
2019-08-08 17:20:33 +01:00

29 lines
No EOL
596 B
JavaScript

import Vue from "vue";
import throttle from "lodash/throttle";
const WindowProperties = new Vue({
data () {
return {
resizeWidth: 0,
resizeHeight: 0,
}
},
created() {
this.resizeWidth = window.innerWidth;
this.resizeHeight = window.innerHeight;
this.debouncedResize = throttle(this.onResize, 70);
window.addEventListener("resize", this.debouncedResize);
},
methods: {
onResize() {
this.resizeWidth = window.innerWidth;
this.resizeHeight = window.innerHeight;
}
}
})
export default WindowProperties;