I
I
ilya_tsym2018-02-02 19:49:14
JavaScript
ilya_tsym, 2018-02-02 19:49:14

How to make the Fotorama slider start showing from the first photo after closing the modal window?

Hello! I use fotorama slider in popup window.
Slider code:

<div id="foto" class="overlay js-overlay-thank-you">
        <div class="fotorama fotorama-style js-thank-you" data-nav="thumbs" data-auto="false" data-width="800"
     				data-height="600">
     				<a href="#close" title="Close" class="close">X</a>
        </div>
        <div class="close-popup js-close-thank-you"></div>
      </div>

I take a photo:
$('.fotorama').fotorama({   data: [   
  {img: 'img/gallery/2/1.jpg'},   
  {img: 'img/gallery/2/2.jpg'}   
  ] })

Called by clicking on a link:
$('.sl-fotorama').click(function() { 
  $('.js-overlay-thank-you').fadeIn();
});

Hide on click:
$(document).mouseup(function (e) { // по клику вне попапа
    var popup = $('.fotorama');
    if (e.target!=popup[0]&&popup.has(e.target).length === 0){
        $('.js-overlay-thank-you').fadeOut();
    }
});

The essence of the problem: if you open the slider, scroll through the photos and close, then the next time you open the display, the display will start from the picture on which you closed it, and not from the first one. How to reset the value of the slider when the modal closes?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question