Search code examples
javascriptfotorama

How to set first image after exit fullscreen popup in fotorama js?


How to set first image after cancel fullscreen popup inside fotorama js slider.

By default after cancel fullscreen, last active image in popup are display as main image in slider.

I want to get first image of slider after cancel popup in fotorama js?

Demo link: http://fotorama.io/customize/fullscreen/ This is demo link of fotoram js

Any help would be apericiated.

Thanks.


Solution

  • we can do it using self.settings.api.first()

         /**
                 * Gallery fullscreen settings.
                 */
                initFullscreenSettings: function () {
                    var settings = this.settings,
                        self = this;
    settings.$gallery = this.settings.$element.find('[data-gallery-role="gallery"]');
    settings.$gallery.on('fotorama:fullscreenexit', function () {
                    settings.closeIcon.hide();
                    settings.focusableStart.attr('tabindex', '-1');
                    settings.focusableEnd.attr('tabindex', '-1');
                    settings.api.updateOptions(settings.defaultConfig.options, true);
                    settings.focusableStart.unbind('focusin', this._focusSwitcher);
                    settings.focusableEnd.unbind('focusin', this._focusSwitcher);
                    settings.closeIcon.hide();
    
                    if (!_.isEqual(settings.activeBreakpoint, {}) && settings.breakpoints) {
                        settings.api.updateOptions(settings.activeBreakpoint.options, true);
                    }
                    settings.isFullscreen = false;
                    settings.$element.data('gallery').updateOptions({
                        swipe: true
                    });
    
                    self.settings.api.first();
                });
                }