Skip to content

Commit

Permalink
JS-329: Add preview arrows while video is playing (for better navigat…
Browse files Browse the repository at this point in the history
…ion)

    - update UpdateOptions method to don't lose focus and arrows
  • Loading branch information
ValeryYafremau committed Dec 11, 2015
1 parent 6bdac30 commit 7122715
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/web/mage/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,40 @@ define([
* @param {Boolean} isInternal - Is this function called via breakpoints.
*/
updateOptions: function (configuration, isInternal) {

var $selectable =
$('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]')
.not('[tabindex=-1], [disabled], :hidden'),
fotorama = settings.fotoramaApi,
$focus = $(':focus'),
index;

/**
* Displays navigation arrows on preview if it contains ifraime.
* @param fotorama - object of fotorama
*/
function showArrows (fotorama) {
var $arrows = $('[data-gallery-role="arrow"]');

if ((fotorama.activeFrame.$stageFrame.find(':has(iframe)').length && fotorama.fullScreen) ||
(fotorama.fullScreen && config.fullscreen.arrows) ||
(!fotorama.fullScreen && config.arrows)) {
$arrows.show();
} else {
$arrows.hide();
}
};

if (_.isObject(configuration)) {

//Saves index of focus
$selectable.each(function (number) {

if ($(this).is($focus)) {
index = number;
}
});

if (this.isTouchEnabled) {
configuration.arrows = false;
}
Expand All @@ -419,6 +452,11 @@ define([
}
$.extend(true, settings.currentConfig.options, configuration);
settings.fotoramaApi.setOptions(settings.currentConfig.options);
showArrows(fotorama);

if (_.isNumber(index)) {
$selectable.eq(index).focus();
}
}
},

Expand Down

0 comments on commit 7122715

Please sign in to comment.