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

View File

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

View File

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