Browse Source

Related #2605, sticky no longer uses bottomPadding for determining bottom edge of context. This is counterintuitive and in most cases wrong

pull/2616/merge
jlukic 9 years ago
parent
commit
253bdc5c53
1 changed files with 10 additions and 7 deletions
  1. 17
      src/definitions/modules/sticky.js

17
src/definitions/modules/sticky.js

@ -237,8 +237,7 @@ $.fn.sticky = function(parameters) {
}, },
context = { context = {
offset : $context.offset(), offset : $context.offset(),
height : $context.outerHeight(),
bottomPadding : parseInt($context.css('padding-bottom'), 10)
height : $context.outerHeight()
}, },
container = { container = {
height: $container.outerHeight() height: $container.outerHeight()
@ -260,8 +259,7 @@ $.fn.sticky = function(parameters) {
context: { context: {
top : context.offset.top, top : context.offset.top,
height : context.height, height : context.height,
bottomPadding : context.bottomPadding,
bottom : context.offset.top + context.height - context.bottomPadding
bottom : context.offset.top + context.height
} }
}; };
module.set.containerSize(); module.set.containerSize();
@ -457,8 +455,14 @@ $.fn.sticky = function(parameters) {
} }
else if(scroll.top > element.top) { else if(scroll.top > element.top) {
module.debug('Element passed, fixing element to page'); module.debug('Element passed, fixing element to page');
module.fixTop();
if( (element.height + scroll.top - elementScroll) > context.bottom ) {
module.bindBottom();
}
else {
module.fixTop();
}
} }
} }
else if( module.is.fixed() ) { else if( module.is.fixed() ) {
@ -542,8 +546,7 @@ $.fn.sticky = function(parameters) {
$module $module
.css({ .css({
left : '', left : '',
top : '',
marginBottom : module.cache.context.bottomPadding
top : ''
}) })
.removeClass(className.fixed) .removeClass(className.fixed)
.removeClass(className.top) .removeClass(className.top)

Loading…
Cancel
Save