Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to send fullscreen request without breaking toggling #27

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/FloatingFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export default {
this.bringDialogToFront(id);
}
},
onFullscreen: function() {
this.$emit("onFullscreen");
onFullscreen: function(val) {
this.$emit("onFullscreen"); this.$emit("onFullscreen", val);
},
dialogMaximise: function(id) {
this.maximiseDialog(id);
Expand Down
61 changes: 39 additions & 22 deletions src/components/MapContent.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div style="height: 100%;width:100%;z-index:1" ref="MapApp">
<FloatingFlow @onFullscreen="onFullscreen" ref="flow"/>
<tutorial :parentRefs="this.$refs" :fullscreen="isFullscreen"></tutorial>
<tutorial :parentRefs="this.$refs"></tutorial>
</div>
</template>

Expand All @@ -20,16 +20,32 @@ export default {
FloatingFlow,
Tutorial
},
data: function(){
return{
isFullscreen: false
}
},
methods: {
onFullscreen: function() {
let mapApp = this.$refs.MapApp;
if (document.fullscreenElement || document.webkitFullscreenElement ||
document.mozFullScreenElement || document.msFullscreenElement ) {
isFullscreen: function(){
return (document.fullscreenElement || document.webkitFullscreenElement ||
document.mozFullScreenElement || document.msFullscreenElement )
},
onFullscreen: function(fullscreenReq) {
//If a request is sent, try it
if (fullscreenReq !== undefined){
if (fullscreenReq && !this.isFullscreen()){
this.goFullscreen()
}
if(!fullscreenReq && this.isFullscreen()){
this.leaveFullscreen()
}
}
// Else we toggle fullscreen
else{
if(this.isFullscreen()){
this.leaveFullscreen()
} else {
this.goFullscreen()
}
}
},
leaveFullscreen: function(){
if (this.isFullscreen()) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) { /* Firefox */
Expand All @@ -39,18 +55,19 @@ export default {
} else if (document.msExitFullscreen) { /* IE/Edge */
document.msExitFullscreen();
}
this.isFullscreen = false;
} else {
if (mapApp.requestFullscreen) {
mapApp.requestFullscreen();
} else if (mapApp.mozRequestFullScreen) { /* Firefox */
mapApp.mozRequestFullScreen();
} else if (mapApp.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
mapApp.webkitRequestFullscreen();
} else if (parent.msRequestFullscreen) { /* IE/Edge */
mapApp.msRequestFullscreen();
}
this.isFullscreen = true;
}

},
goFullscreen: function(){
let mapApp = this.$refs.MapApp;
if (mapApp.requestFullscreen) {
mapApp.requestFullscreen();
} else if (mapApp.mozRequestFullScreen) { /* Firefox */
mapApp.mozRequestFullScreen();
} else if (mapApp.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
mapApp.webkitRequestFullscreen();
} else if (parent.msRequestFullscreen) { /* IE/Edge */
mapApp.msRequestFullscreen();
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/Tutorial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Vue.use(VueTour);

export default {
name: "Tutorial",
props: ['parentRefs', 'fullscreen'],
props: ['parentRefs'],
methods: {
/**
* Callback when an action is performed (open new dialogs).
Expand Down Expand Up @@ -73,9 +73,7 @@ export default {

// Step one goes to full screen
if (currentStep === 1){
if (!this.fullscreen){
this.flow.onFullscreen();
}
this.flow.onFullscreen(true);
}

// Hack on step three to show tooltip for the heart
Expand Down