dist/viewer.common.js
function play() {
    var _this2 = this;

    var fullscreen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

    if (!this.isShown || this.played) {
      return this;
    }

    var options = this.options,
        player = this.player;

    var onLoad = this.loadImage.bind(this);
    var list = [];
    var total = 0;
    var index = 0;

    this.played = true;
    this.onLoadWhenPlay = onLoad;

    if (fullscreen) {
      this.requestFullscreen();
    }

    addClass(player, CLASS_SHOW);
    forEach(this.items, function (item, i) {
      var img = item.querySelector('img');
      var image = document.createElement('img');

      image.src = getData(img, 'originalUrl');
      image.alt = img.getAttribute('alt');
      total += 1;
      addClass(image, CLASS_FADE);
      toggleClass(image, CLASS_TRANSITION, options.transition);

      if (hasClass(item, CLASS_ACTIVE)) {
        addClass(image, CLASS_IN);
        index = i;
      }

      list.push(image);
      addListener(image, EVENT_LOAD, onLoad, {
        once: true
      });
      player.appendChild(image);
    });

    if (isNumber(options.interval) && options.interval > 0) {
      var play = function play() {
        _this2.playing = setTimeout(function () {
          removeClass(list[index], CLASS_IN);
          index += 1;
          index = index < total ? index : 0;
          addClass(list[index], CLASS_IN);
          play();
        }, options.interval);
      };

      if (total > 1) {
        play();
      }
    }

    return this;
  }
function play() {
    var _this2 = this;

    var fullscreen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

    if (!this.isShown || this.played) {
      return this;
    }

    var options = this.options,
        player = this.player;

    var onLoad = this.loadImage.bind(this);
    var list = [];
    var total = 0;
    var index = 0;

    this.played = true;
    this.onLoadWhenPlay = onLoad;

    if (fullscreen) {
      this.requestFullscreen();
    }

    addClass(player, CLASS_SHOW);
    forEach(this.items, function (item, i) {
      var img = item.querySelector('img');
      var image = document.createElement('img');

      image.src = getData(img, 'originalUrl');
      image.alt = img.getAttribute('alt');
      total += 1;
      addClass(image, CLASS_FADE);
      toggleClass(image, CLASS_TRANSITION, options.transition);

      if (hasClass(item, CLASS_ACTIVE)) {
        addClass(image, CLASS_IN);
        index = i;
      }

      list.push(image);
      addListener(image, EVENT_LOAD, onLoad, {
        once: true
      });
      player.appendChild(image);
    });

    if (isNumber(options.interval) && options.interval > 0) {
      var play = function play() {
        _this2.playing = setTimeout(function () {
          removeClass(list[index], CLASS_IN);
          index += 1;
          index = index < total ? index : 0;
          addClass(list[index], CLASS_IN);
          play();
        }, options.interval);
      };

      if (total > 1) {
        play();
      }
    }

    return this;
  }
function play ( ) { var _this2 = this ; var fullscreen = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : false ; if ( ! this . isShown || this . played ) { return this ; } var options = this . options , player = this . player ; var onLoad = this . loadImage . bind ( this ) ; var list = [ ] ; var total = 0 ; var index = 0 ; this . played = true ; this . onLoadWhenPlay = onLoad ; if ( fullscreen ) { this . requestFullscreen ( ) ; } addClass ( player , CLASS_SHOW ) ; forEach ( this . items , function ( item , i ) { var img = item . querySelector ( 'img' ) ; var image = document . createElement ( 'img' ) ; image . src = getData ( img , 'originalUrl' ) ; image . alt = img . getAttribute ( 'alt' ) ; total += 1 ; addClass ( image , CLASS_FADE ) ; toggleClass ( image , CLASS_TRANSITION , options . transition ) ; if ( hasClass ( item , CLASS_ACTIVE ) ) { addClass ( image , CLASS_IN ) ; index = i ; } list . push ( image ) ; addListener ( image , EVENT_LOAD , onLoad , { once : true } ) ; player . appendChild ( image ) ; } ) ; if ( isNumber ( options . interval ) && options . interval > 0 ) { var play = function play ( ) { _this2 . playing = setTimeout ( function ( ) { removeClass ( list [ index ] , CLASS_IN ) ; index += 1 ; index = index < total ? index : 0 ; addClass ( list [ index ] , CLASS_IN ) ; play ( ) ; } , options . interval ) ; } ; if ( total > 1 ) { play ( ) ; } } return this ; }
Play the images
@param {boolean} [fullscreen=false] - Indicate if request fullscreen or not.
@returns {Viewer} this
Play the images