Skip to content

Commit

Permalink
Fix #118
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-t committed Jul 18, 2020
1 parent 59df28e commit 66b2fb4
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 69 deletions.
36 changes: 19 additions & 17 deletions dist/js/chocolat.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,24 @@ function fit(options) {
}
function openFullScreen(wrapper) {
if (wrapper.requestFullscreen) {
wrapper.requestFullscreen();
return true;
return wrapper.requestFullscreen();
} else if (wrapper.webkitRequestFullscreen) {
wrapper.webkitRequestFullscreen();
return true;
return wrapper.webkitRequestFullscreen();
} else if (wrapper.msRequestFullscreen) {
wrapper.msRequestFullscreen();
return true;
return wrapper.msRequestFullscreen();
} else {
return false;
return Promise.reject();
}
}
function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
return false;
return document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
return false;
return document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
return false;
return document.msExitFullscreen();
} else {
return true;
return Promise.reject();
}
}

Expand Down Expand Up @@ -404,7 +398,7 @@ class Chocolat {

close() {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

Expand Down Expand Up @@ -540,11 +534,19 @@ class Chocolat {
this.off(this.elems.fullscreen, 'click.chocolat');
this.on(this.elems.fullscreen, 'click.chocolat', () => {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

this.state.fullScreenOpen = openFullScreen(this.elems.wrapper);
openFullScreen(this.elems.wrapper);
});
this.off(document, 'fullscreenchange.chocolat');
this.on(document, 'fullscreenchange.chocolat', () => {
if (document.fullscreenElement) {
this.state.fullScreenOpen = true;
} else {
this.state.fullScreenOpen = false;
}
});

if (this.settings.closeOnBackgroundClick) {
Expand Down
36 changes: 19 additions & 17 deletions dist/js/chocolat.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,24 @@ function fit(options) {
}
function openFullScreen(wrapper) {
if (wrapper.requestFullscreen) {
wrapper.requestFullscreen();
return true;
return wrapper.requestFullscreen();
} else if (wrapper.webkitRequestFullscreen) {
wrapper.webkitRequestFullscreen();
return true;
return wrapper.webkitRequestFullscreen();
} else if (wrapper.msRequestFullscreen) {
wrapper.msRequestFullscreen();
return true;
return wrapper.msRequestFullscreen();
} else {
return false;
return Promise.reject();
}
}
function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
return false;
return document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
return false;
return document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
return false;
return document.msExitFullscreen();
} else {
return true;
return Promise.reject();
}
}

Expand Down Expand Up @@ -402,7 +396,7 @@ class Chocolat {

close() {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

Expand Down Expand Up @@ -538,11 +532,19 @@ class Chocolat {
this.off(this.elems.fullscreen, 'click.chocolat');
this.on(this.elems.fullscreen, 'click.chocolat', () => {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

this.state.fullScreenOpen = openFullScreen(this.elems.wrapper);
openFullScreen(this.elems.wrapper);
});
this.off(document, 'fullscreenchange.chocolat');
this.on(document, 'fullscreenchange.chocolat', () => {
if (document.fullscreenElement) {
this.state.fullScreenOpen = true;
} else {
this.state.fullScreenOpen = false;
}
});

if (this.settings.closeOnBackgroundClick) {
Expand Down
36 changes: 19 additions & 17 deletions dist/js/chocolat.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,24 @@
}
function openFullScreen(wrapper) {
if (wrapper.requestFullscreen) {
wrapper.requestFullscreen();
return true;
return wrapper.requestFullscreen();
} else if (wrapper.webkitRequestFullscreen) {
wrapper.webkitRequestFullscreen();
return true;
return wrapper.webkitRequestFullscreen();
} else if (wrapper.msRequestFullscreen) {
wrapper.msRequestFullscreen();
return true;
return wrapper.msRequestFullscreen();
} else {
return false;
return Promise.reject();
}
}
function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
return false;
return document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
return false;
return document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
return false;
return document.msExitFullscreen();
} else {
return true;
return Promise.reject();
}
}

Expand Down Expand Up @@ -405,7 +399,7 @@

close() {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

Expand Down Expand Up @@ -541,11 +535,19 @@
this.off(this.elems.fullscreen, 'click.chocolat');
this.on(this.elems.fullscreen, 'click.chocolat', () => {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen();
exitFullScreen();
return;
}

this.state.fullScreenOpen = openFullScreen(this.elems.wrapper);
openFullScreen(this.elems.wrapper);
});
this.off(document, 'fullscreenchange.chocolat');
this.on(document, 'fullscreenchange.chocolat', () => {
if (document.fullscreenElement) {
this.state.fullScreenOpen = true;
} else {
this.state.fullScreenOpen = false;
}
});

if (this.settings.closeOnBackgroundClick) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chocolat",
"version": "1.0.2",
"version": "1.0.3",
"description": "Responsive Lightbox Plugin",
"main": "dist/js/chocolat.cjs.js",
"module": "dist/js/chocolat.esm.js",
Expand Down
15 changes: 12 additions & 3 deletions src/js/chocolat.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class Chocolat {

close() {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen()
exitFullScreen()
return
}

Expand Down Expand Up @@ -466,11 +466,20 @@ export class Chocolat {
this.off(this.elems.fullscreen, 'click.chocolat')
this.on(this.elems.fullscreen, 'click.chocolat', () => {
if (this.state.fullScreenOpen) {
this.state.fullScreenOpen = exitFullScreen()
exitFullScreen()
return
}

this.state.fullScreenOpen = openFullScreen(this.elems.wrapper)
openFullScreen(this.elems.wrapper)
})

this.off(document, 'fullscreenchange.chocolat')
this.on(document, 'fullscreenchange.chocolat', () => {
if (document.fullscreenElement) {
this.state.fullScreenOpen = true
} else {
this.state.fullScreenOpen = false
}
})

if (this.settings.closeOnBackgroundClick) {
Expand Down
22 changes: 8 additions & 14 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,24 @@ export function fit(options) {

export function openFullScreen(wrapper) {
if (wrapper.requestFullscreen) {
wrapper.requestFullscreen()
return true
return wrapper.requestFullscreen()
} else if (wrapper.webkitRequestFullscreen) {
wrapper.webkitRequestFullscreen()
return true
return wrapper.webkitRequestFullscreen()
} else if (wrapper.msRequestFullscreen) {
wrapper.msRequestFullscreen()
return true
return wrapper.msRequestFullscreen()
} else {
return false
return Promise.reject()
}
}

export function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen()
return false
return document.exitFullscreen()
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen()
return false
return document.webkitExitFullscreen()
} else if (document.msExitFullscreen) {
document.msExitFullscreen()
return false
return document.msExitFullscreen()
} else {
return true
return Promise.reject()
}
}

0 comments on commit 66b2fb4

Please sign in to comment.