artpolikarpov / fotorama

A simple, stunning, powerful jQuery gallery.
http://fotorama.io
Other
1.58k stars 380 forks source link

Exit full screen mode throws js error #566

Open BackuPs opened 3 years ago

BackuPs commented 3 years ago

fotorama throws js error on exit full screen mode. Even on fotorama.io

uncaught (in promise) TypeError: Not in fullscreen mode
    cancel https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js:4
    kd https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js:4
    Fotorama https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js:5
fotorama.js:4:15238

The function cancelFullScreen needs to be changed.

  function cancelFullScreen () {
    if (that.fullScreen) {
      that.fullScreen = false;
      if (FULLSCREEN && that.fullScreen) {
        fullScreenApi.cancel(fotorama);
      }

      $BODY.removeClass(_fullscreenClass);
      $HTML.removeClass(_fullscreenClass);

      $fotorama
          .removeClass(fullscreenClass)
          .insertAfter($anchor);

      measures = $.extend({}, measuresStash);

      unloadVideo($videoPlaying, true, true);

      updateTouchTails('x', false);

      that.resize();
      loadImg(activeIndexes, 'stage');

      lockScroll($WINDOW, scrollLeft, scrollTop);

      triggerEvent('fullscreenexit');
    }
  }