persist zoom level

This commit is contained in:
Steffen 2020-06-07 21:51:19 +02:00
parent 080b1314ad
commit ff61770150
No known key found for this signature in database
GPG Key ID: 764D74E98267DFC6
3 changed files with 19 additions and 6 deletions

View File

@ -57,11 +57,14 @@
<li v-if="players.length">
<em>
<font-awesome-icon
@click="updateZoom(-0.1)"
@click="setZoom(grimoire.zoom - 0.1)"
icon="search-minus"
/>
{{ Math.round(grimoire.zoom * 100) }}%
<font-awesome-icon @click="updateZoom(0.1)" icon="search-plus" />
<font-awesome-icon
@click="setZoom(grimoire.zoom + 0.1)"
icon="search-plus"
/>
</em>
Zoom
</li>
@ -258,7 +261,7 @@ export default {
"toggleMenu",
"toggleNightOrder",
"updateScreenshot",
"updateZoom",
"setZoom",
"toggleModal"
])
}

View File

@ -65,8 +65,8 @@ export default new Vuex.Store({
toggleNightOrder({ grimoire }) {
grimoire.isNightOrder = !grimoire.isNightOrder;
},
updateZoom({ grimoire }, by = 0) {
grimoire.zoom += by;
setZoom({ grimoire }, zoom) {
grimoire.zoom = zoom;
},
setBackground({ grimoire }, background) {
grimoire.background = background;

View File

@ -1,8 +1,11 @@
module.exports = store => {
// initialize data
if (localStorage.background !== undefined) {
if (localStorage.getItem("background")) {
store.commit("setBackground", localStorage.background);
}
if (localStorage.getItem("zoom")) {
store.commit("setZoom", parseFloat(localStorage.getItem("zoom")));
}
if (localStorage.isPublic !== undefined) {
store.commit("toggleGrimoire", JSON.parse(localStorage.isPublic));
}
@ -56,6 +59,13 @@ module.exports = store => {
localStorage.removeItem("background");
}
break;
case "setZoom":
if (payload !== 1) {
localStorage.setItem("zoom", payload);
} else {
localStorage.removeItem("zoom");
}
break;
case "setEdition":
if (payload === "custom") {
localStorage.removeItem("edition");