Skip to content

Commit 41bcf2f

Browse files
committed
Merge remote-tracking branch 'origin/port-2572' into port-2572
2 parents 2b8e315 + db8476a commit 41bcf2f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

lib/web/magnifier/magnify.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ define([
277277

278278
settings = $.extend(dimentions, {
279279
top: top,
280-
bottom: bottom,
281280
left: left,
282281
right: right
283282
});
@@ -557,6 +556,16 @@ define([
557556
trailing: false
558557
});
559558

559+
/**
560+
* Returns top position value for passed jQuery object.
561+
*
562+
* @param $el
563+
* @return {number}
564+
*/
565+
function getTop($el) {
566+
return parseInt($el.get(0).style.top);
567+
}
568+
560569
function shiftImage(dx, dy, e) {
561570
var top = +imagePosY + dy,
562571
left = +imagePosX + dx,
@@ -584,16 +593,13 @@ define([
584593
}
585594

586595
if ($image.height() > $imageContainer.height()) {
587-
588-
if ($imageContainer.offset().top + $imageContainer.height() > top + $image.height()) {
589-
top = $imageContainer.offset().top + $imageContainer.height() - $image.height();
596+
if ($imageContainer.height() > $image.height() + top) {
597+
$image.css('top', $imageContainer.height() - $image.height());
590598
} else {
591-
top = $imageContainer.offset().top < top ? 0 : top;
599+
top = $image.height() - getTop($image) - $imageContainer.height();
600+
dy = dy < top ? dy : top;
601+
$image.css('top', getTop($image) + dy);
592602
}
593-
$image.offset({
594-
'top': top
595-
});
596-
$image.css('bottom', '');
597603
}
598604

599605
if ($image.width() > $imageContainer.width()) {
@@ -690,7 +696,7 @@ define([
690696
} else if (gallery.fullScreen && (!transitionEnabled || !transitionActive)) {
691697
e.preventDefault();
692698

693-
imagePosY = $image.offset().top;
699+
imagePosY = getTop($image);
694700
imagePosX = $image.offset().left;
695701

696702
if (isTouchEnabled) {
@@ -746,6 +752,7 @@ define([
746752
}
747753

748754
if (allowZoomOut) {
755+
imagePosY = getTop($(fullscreenImageSelector, $gallery));
749756
shiftImage(clientX - startX, clientY - startY, e);
750757
}
751758
}
@@ -771,13 +778,13 @@ define([
771778
isFullScreen = $(gallerySelector).data('fotorama').fullScreen,
772779
initVars = function () {
773780
imagePosX = $(fullscreenImageSelector, $gallery).offset().left;
774-
imagePosY = $(fullscreenImageSelector, $gallery).offset().top;
781+
imagePosY = getTop($(fullscreenImageSelector, $gallery));
775782
};
776783

777784
if (($focus.attr('data-gallery-role') || !$focus.length) && allowZoomOut) {
778785
if (isFullScreen) {
779786
imagePosX = $(fullscreenImageSelector, $(gallerySelector)).offset().left;
780-
imagePosY = $(fullscreenImageSelector, $(gallerySelector)).offset().top;
787+
imagePosY = getTop($(fullscreenImageSelector, $(gallerySelector)));
781788
}
782789

783790
if (e.keyCode === 39) {

0 commit comments

Comments
 (0)