uptime-kuma/src/mixins/mobile.js
Matthew Nickson a927f5cd15
Fixed typos + improved clarity and detail of some JSDoc
Apply suggestions from code review

Co-authored-by: Nelson Chan <[email protected]>
2022-06-02 16:40:56 +01:00

39 lines
770 B
JavaScript

export default {
data() {
return {
windowWidth: window.innerWidth,
};
},
created() {
window.addEventListener("resize", this.onResize);
this.updateBody();
},
methods: {
/** Handle screen resize */
onResize() {
this.windowWidth = window.innerWidth;
this.updateBody();
},
/** Add css-class "mobile" to body if needed */
updateBody() {
if (this.isMobile) {
document.body.classList.add("mobile");
} else {
document.body.classList.remove("mobile");
}
}
},
computed: {
isMobile() {
return this.windowWidth <= 767.98;
},
},
};