Skip to content

Commit 53f7c51

Browse files
JS-200: Test existing accessibility features
1 parent 62f4887 commit 53f7c51

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

lib/web/fotorama/fotorama.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ fotoramaVersion = '4.6.4';
9191
verticalImageClass = _fotoramaClass + '_vertical_ratio';
9292
var JQUERY_VERSION = $ && $.fn.jquery.split('.');
9393

94-
var borderPos = 0;
94+
var borderPos = 0,
95+
curSlide = 1;
9596

9697
if (!JQUERY_VERSION
9798
|| JQUERY_VERSION[0] < 1
@@ -1616,9 +1617,9 @@ fotoramaVersion = '4.6.4';
16161617
if ($el.selector !== '.fotorama__nav-wrap .fotorama__nav .fotorama__nav__shaft') {
16171618
$el.css($.extend(getDuration(options.time), translate));
16181619

1619-
if ($el.selector === ".fotorama__thumb-border") {
1620+
if ($el.selector === "." + thumbBorderClass) {
16201621

1621-
var slideLength = Math.floor($el.closest('.fotorama__wrap').width()/options.thumb.width),
1622+
var slideLength = Math.floor($el.closest('.' + wrapClass).width() / options.thumb.width),
16221623
borderStep = options.thumb.margin,
16231624
slidePosition;
16241625

@@ -1642,7 +1643,8 @@ fotoramaVersion = '4.6.4';
16421643
}
16431644
}
16441645
}
1645-
borderPos = options.pos;
1646+
borderPos = options.pos;
1647+
curSlide = Math.floor(borderPos / borderStep / slideLength) + 1;
16461648
}
16471649
}
16481650
}
@@ -1655,7 +1657,7 @@ fotoramaVersion = '4.6.4';
16551657
} else {
16561658
$el.stop().animate(translate, options.time, BEZIER, onEndFn);
16571659
options.measures.nw = -slidePosition + borderStep * (slideLength - 1);
1658-
$('.fotorama__nav__shaft').css($.extend(getDuration(options.time), translate));
1660+
$('.' + navShaftClass).css($.extend(getDuration(options.time), translate));
16591661
}
16601662
}
16611663

@@ -1666,7 +1668,7 @@ fotoramaVersion = '4.6.4';
16661668
} else {
16671669
options.measures.nw = -slidePosition + borderStep * (slideLength - 1);
16681670
}
1669-
$('.fotorama__nav__shaft').css($.extend(getDuration(options.time), translate));
1671+
$('.' + navShaftClass).css($.extend(getDuration(options.time), translate));
16701672
}
16711673

16721674
function fade($el1, $el2, $frames, options, fadeStack, chain) {
@@ -2498,6 +2500,7 @@ fotoramaVersion = '4.6.4';
24982500

24992501
lastOptions = $.extend({}, opts);
25002502
setStagePosition();
2503+
that.showSlide(curSlide);
25012504
}
25022505

25032506
function normalizeIndex(index) {
@@ -2748,7 +2751,11 @@ fotoramaVersion = '4.6.4';
27482751
setTimeout(function () {
27492752
lockScroll($nav);
27502753
}, 0);
2751-
slideNavShaft({time: o_transitionDuration, guessIndex: $(this).data().eq, minMax: navShaftTouchTail});
2754+
if (!opts.carouselnavigation) {
2755+
slideNavShaft({time: o_transitionDuration, guessIndex: $(this).data().eq, minMax: navShaftTouchTail});
2756+
} else {
2757+
that.showSlide(Math.floor($(this).data().eq / slidesNumb) + 1)
2758+
}
27522759
});
27532760
}
27542761

@@ -3187,12 +3194,12 @@ fotoramaVersion = '4.6.4';
31873194
}
31883195

31893196
that.showSlide = function(index) {
3190-
if ((index > 0) && (index <= $navShaft.children().length - 1)) {
3197+
if (index > 0 && activeFrame) {
31913198
index --;
31923199
var borderStep = opts.navdir === 'vertical' ?
31933200
opts.thumbheight + opts.thumbmargin :
31943201
opts.thumbwidth + opts.thumbmargin,
3195-
slideLength = Math.floor($el.closest('.fotorama__wrap').width()/opts.thumbwidth),
3202+
slideLength = Math.floor($('.' + wrapClass).width()/opts.thumbwidth),
31963203
options = {
31973204
time: opts.transitionduration,
31983205
direction: opts.navdir,
@@ -3337,6 +3344,10 @@ fotoramaVersion = '4.6.4';
33373344
showedFLAG = typeof lastActiveIndex !== 'undefined' && lastActiveIndex !== activeIndex;
33383345
lastActiveIndex = activeIndex;
33393346

3347+
if (opts.carouselnavigation) {
3348+
that.showSlide(curSlide);
3349+
}
3350+
33403351
return this;
33413352
};
33423353

@@ -3782,7 +3793,7 @@ fotoramaVersion = '4.6.4';
37823793
onEnd: function (result) {
37833794

37843795
function onEnd() {
3785-
slideNavShaft.l = opts.carouselnavigation ? slideDrag.slidePosition : result.newPos;
3796+
slideNavShaft.l = opts.carouselnavigation ? slideDrag.slidePosition: result.newPos;
37863797
releaseAutoplay();
37873798
changeAutoplay();
37883799
thumbsDraw(result.newPos, true);

0 commit comments

Comments
 (0)