Skip to content

Commit

Permalink
#1011 Popup positioning problem when scroll position is down
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTr committed Dec 15, 2017
1 parent 5dbbe12 commit 1b6acbd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions inc/js/jquery.dolPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
};

$.fn.dolPopupCenter = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
var dy = $(window).height() > $(this).outerHeight() ? ($(window).height() - $(this).outerHeight()) / 2 : 0;
var dx = $(window).width() > $(this).outerWidth() ? ($(window).width() - $(this).outerWidth()) / 2 : 0;
this.css("position","absolute");
this.css("top", Math.max(0, dy + $(window).scrollTop()) + "px");
this.css("left", Math.max(0, dx + $(window).scrollLeft()) + "px");
return this;
}

Expand Down

0 comments on commit 1b6acbd

Please sign in to comment.