Browse Source

Fixes #1256, issues with offsetParent as 'html', should account for padding added to 'body'

pull/1257/head
jlukic 10 years ago
parent
commit
90ae611485
2 changed files with 17 additions and 12 deletions
  1. 25
      src/definitions/modules/popup.js
  2. 4
      src/definitions/modules/popup.less

25
src/definitions/modules/popup.js

@ -408,8 +408,9 @@ $.fn.popup = function(parameters) {
} }
return false; return false;
}, },
offstagePosition: function() {
offstagePosition: function(position) {
var var
position = position || false,
boundary = { boundary = {
top : $(window).scrollTop(), top : $(window).scrollTop(),
bottom : $(window).scrollTop() + $(window).height(), bottom : $(window).scrollTop() + $(window).height(),
@ -418,13 +419,14 @@ $.fn.popup = function(parameters) {
}, },
popup = { popup = {
width : $popup.width(), width : $popup.width(),
height : $popup.outerHeight(),
height : $popup.height(),
offset : $popup.offset() offset : $popup.offset()
}, },
offstage = {}, offstage = {},
offstagePositions = [] offstagePositions = []
; ;
if(popup.offset) {
if(popup.offset && position) {
module.verbose('Checking if outside viewable area', popup.offset);
offstage = { offstage = {
top : (popup.offset.top < boundary.top), top : (popup.offset.top < boundary.top),
bottom : (popup.offset.top + popup.height > boundary.bottom), bottom : (popup.offset.top + popup.height > boundary.bottom),
@ -432,7 +434,6 @@ $.fn.popup = function(parameters) {
left : (popup.offset.left < boundary.left) left : (popup.offset.left < boundary.left)
}; };
} }
module.verbose('Checking if outside viewable area', popup.offset);
// return only boundaries that have been surpassed // return only boundaries that have been surpassed
$.each(offstage, function(direction, isOffstage) { $.each(offstage, function(direction, isOffstage) {
if(isOffstage) { if(isOffstage) {
@ -487,17 +488,22 @@ $.fn.popup = function(parameters) {
popupWidth = $popup.outerWidth(), popupWidth = $popup.outerWidth(),
popupHeight = $popup.outerHeight(), popupHeight = $popup.outerHeight(),
parentWidth = $offsetParent.outerWidth(),
parentHeight = $offsetParent.outerHeight(),
parentWidth = ( $offsetParent.is('html') )
? $offsetParent.find('body').width()
: $offsetParent.outerWidth(),
parentHeight = ( $offsetParent.is('html') )
? $offsetParent.find('body').height()
: $offsetParent.outerHeight(),
distanceAway = settings.distanceAway, distanceAway = settings.distanceAway,
targetElement = $target[0], targetElement = $target[0],
marginTop = (settings.inline)
marginTop = (settings.inline)
? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10) ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
: 0, : 0,
marginLeft = (settings.inline)
marginLeft = (settings.inline)
? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10) ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10)
: 0, : 0,
@ -510,7 +516,6 @@ $.fn.popup = function(parameters) {
; ;
position = position || $module.data(metadata.position) || settings.position; position = position || $module.data(metadata.position) || settings.position;
arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset; arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset;
if(settings.inline) { if(settings.inline) {
module.debug('Adding targets margin to calculation'); module.debug('Adding targets margin to calculation');
if(position == 'left center' || position == 'right center') { if(position == 'left center' || position == 'right center') {
@ -604,7 +609,7 @@ $.fn.popup = function(parameters) {
.addClass(className.loading) .addClass(className.loading)
; ;
// check if is offstage // check if is offstage
offstagePosition = module.get.offstagePosition();
offstagePosition = module.get.offstagePosition(position);
// recursively find new positioning // recursively find new positioning
if(offstagePosition) { if(offstagePosition) {
module.debug('Element is outside boundaries', offstagePosition); module.debug('Element is outside boundaries', offstagePosition);

4
src/definitions/modules/popup.less

@ -236,7 +236,7 @@
.ui.fluid.popup { .ui.fluid.popup {
width: 100%; width: 100%;
max-width: 99999px;
max-width: none;
} }
@ -265,7 +265,7 @@
---------------*/ ---------------*/
.ui.flowing.popup { .ui.flowing.popup {
max-width: 9999px;
max-width: none;
} }

Loading…
Cancel
Save