Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nkalupahana authored Jan 4, 2022
1 parent 28b4809 commit 22f40e7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ proto.exitFullscreen = function() {
this._changeFullscreen( false );
};

proto._changeFullscreen = function( isView ) {
proto._changeFullscreen = async function( isView ) {
if ( this.isFullscreen == isView ) {
return;
}
// Force onto current slide and wait until it's there
// Done in order to avoid bugs when fullscreening during animation
this.select(this.selectedIndex, true, true);
while (this.isAnimating) {
await new Promise(r => setTimeout(r, 10));
}

this.isFullscreen = isView;
var classMethod = isView ? 'add' : 'remove';
document.documentElement.classList[ classMethod ]('is-flickity-fullscreen');
Expand All @@ -83,6 +90,7 @@ proto._changeFullscreen = function( isView ) {
if ( this.isFullscreen ) {
this.reposition();
}

this.dispatchEvent( 'fullscreenChange', null, [ isView ] );
};

Expand Down

0 comments on commit 22f40e7

Please sign in to comment.