Skip to content

Commit ecb41c7

Browse files
committed
Merge pull request #73 from ValeryYafremau/JS-329
JS-329: Add preview arrows while video is playing (for better navigat…
2 parents aa3d774 + 7122715 commit ecb41c7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/web/mage/gallery/gallery.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,40 @@ define([
401401
* @param {Boolean} isInternal - Is this function called via breakpoints.
402402
*/
403403
updateOptions: function (configuration, isInternal) {
404+
405+
var $selectable =
406+
$('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]')
407+
.not('[tabindex=-1], [disabled], :hidden'),
408+
fotorama = settings.fotoramaApi,
409+
$focus = $(':focus'),
410+
index;
411+
412+
/**
413+
* Displays navigation arrows on preview if it contains ifraime.
414+
* @param fotorama - object of fotorama
415+
*/
416+
function showArrows (fotorama) {
417+
var $arrows = $('[data-gallery-role="arrow"]');
418+
419+
if ((fotorama.activeFrame.$stageFrame.find(':has(iframe)').length && fotorama.fullScreen) ||
420+
(fotorama.fullScreen && config.fullscreen.arrows) ||
421+
(!fotorama.fullScreen && config.arrows)) {
422+
$arrows.show();
423+
} else {
424+
$arrows.hide();
425+
}
426+
};
427+
404428
if (_.isObject(configuration)) {
429+
430+
//Saves index of focus
431+
$selectable.each(function (number) {
432+
433+
if ($(this).is($focus)) {
434+
index = number;
435+
}
436+
});
437+
405438
if (this.isTouchEnabled) {
406439
configuration.arrows = false;
407440
}
@@ -419,6 +452,11 @@ define([
419452
}
420453
$.extend(true, settings.currentConfig.options, configuration);
421454
settings.fotoramaApi.setOptions(settings.currentConfig.options);
455+
showArrows(fotorama);
456+
457+
if (_.isNumber(index)) {
458+
$selectable.eq(index).focus();
459+
}
422460
}
423461
},
424462

0 commit comments

Comments
 (0)