Skip to content

Commit

Permalink
button to toggle fullscreen in Undo component #137
Browse files Browse the repository at this point in the history
using HTML5 fullscreen API <https://fullscreen.spec.whatwg.org/>
  • Loading branch information
alex-rind committed Aug 25, 2023
1 parent ceffcd1 commit 8f9346f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/components/UndoRedo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@
<font-awesome-icon icon="redo" />
</span>
</button>
<button
class="button is-small"
title="Vollbildmodus"
@click="fullScreen"
:v-if="canFullscreen"
>
<span class="icon">
<font-awesome-icon
:icon="isFullScreen ? 'compress-arrows-alt' : 'expand-arrows-alt'"
/>
</span>
</button>
</div>
</template>

<script lang="ts">
import { defineComponent, computed } from "vue";
import { defineComponent, computed, ref } from "vue";
import { useStore } from "@/store";
export default defineComponent({
Expand All @@ -39,11 +51,34 @@ export default defineComponent({
return store.state.unredo && store.state.unredo.redoCount > 0;
});
const isFullScreen = ref(false);
return {
canUndo,
canRedo,
undo: () => store.commit("unredo/undo"),
redo: () => store.commit("unredo/redo"),
isFullScreen,
canFullscreen: () => document.fullscreenEnabled,
fullScreen: () => {
if (
window.innerWidth == screen.width &&
window.innerHeight == screen.height
) {
console.log("from full");
document.exitFullscreen().then(() => {
isFullScreen.value = false;
});
} else {
console.log("to full");
const elem = document.documentElement;
if (elem.requestFullscreen) {
elem.requestFullscreen().then(() => {
isFullScreen.value = true;
});
}
}
},
};
},
});
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
// faRedoAlt,
faUndo,
faRedo,
faExpandArrowsAlt,
faCompressArrowsAlt,
faChartBar,
faUserSecret,
faRss,
Expand Down Expand Up @@ -75,6 +77,8 @@ library.add(
// faRedoAlt,
faUndo,
faRedo,
faExpandArrowsAlt,
faCompressArrowsAlt,
faChartBar,
faUserSecret,
faRss,
Expand Down

0 comments on commit 8f9346f

Please sign in to comment.