Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Save window size of app to portmaster after resize
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed May 8, 2020
1 parent b03555c commit d381388
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/base/src/components/Base.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div class="main-container">
<SaveWindowSize />

<div class="ui basic inverted segment controlbar">
<!-- sidebar header -->
<div v-on:click="selectHome()" class="ui basic inverted segment mess center aligned">
Expand Down Expand Up @@ -95,6 +97,7 @@
</template>

<script>
import SaveWindowSize from "./SaveWindowSize.vue";
import Dashboard from "./Dashboard.vue";
import Settings from "./Settings.vue";
import AppSettings from "./AppSettings.vue";
Expand All @@ -104,6 +107,7 @@ import About from "./About.vue";
export default {
name: "Base",
components: {
SaveWindowSize,
Dashboard,
Settings,
AppSettings,
Expand Down
44 changes: 44 additions & 0 deletions modules/base/src/components/SaveWindowSize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<span />
</template>

<script>
export default {
name: "Dashboard",
components: {
},
data() {
return {
updateID: 0
};
},
methods: {
saveWindowSize() {
// increase ID counter
this.updateID++;
// assign current ID to this instance
let myUpdateID = this.updateID;
// create function to check if loading has finished
let save = () => {
// only save if we are the last instance
if (myUpdateID == this.updateID) {
this.$api.update("core:ui/app/window", {
// window.outer* don't work correctly with IE/MSHTML.
Height: window.outerHeight - 50, // substract a little to compensate for top bar
Width: window.outerWidth - 50, // substract a little to compensate for scroll bar
});
}
};
// save after one second
setTimeout(save, 1000);
}
},
beforeMount() {
window.addEventListener("resize", this.saveWindowSize);
}
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
</style>

0 comments on commit d381388

Please sign in to comment.