@@ -402,6 +402,18 @@ $.fn.sticky = function(parameters) {
402
402
module . determineContainer ( ) ;
403
403
}
404
404
else {
405
+ var tallestHeight = Math . max ( module . cache . context . height , module . cache . element . height ) ;
406
+ if ( tallestHeight - $container . outerHeight ( ) > settings . jitter ) {
407
+ module . debug ( 'Context is taller than container. Specifying exact height for container' , module . cache . context . height ) ;
408
+ $container . css ( {
409
+ height : tallestHeight ,
410
+ } ) ;
411
+ }
412
+ else {
413
+ $container . css ( {
414
+ height : '' ,
415
+ } ) ;
416
+ }
405
417
if ( Math . abs ( $container . outerHeight ( ) - module . cache . context . height ) > settings . jitter ) {
406
418
module . debug ( 'Context has padding, specifying exact height for container' , module . cache . context . height ) ;
407
419
$container . css ( {
@@ -438,7 +450,7 @@ $.fn.sticky = function(parameters) {
438
450
} ,
439
451
size : function ( ) {
440
452
if ( module . cache . element . height !== 0 && module . cache . element . width !== 0 ) {
441
- element . style . setProperty ( 'width' , module . cache . element . width + 'px' , 'important' ) ;
453
+ element . style . setProperty ( 'width' , module . cache . element . width + 'px' , 'important' ) ;
442
454
element . style . setProperty ( 'height' , module . cache . element . height + 'px' , 'important' ) ;
443
455
}
444
456
}
@@ -501,7 +513,7 @@ $.fn.sticky = function(parameters) {
501
513
module . bindBottom ( ) ;
502
514
}
503
515
else if ( scroll . top > element . top ) {
504
- if ( ( element . height + scroll . top - elementScroll ) >= context . bottom ) {
516
+ if ( ( element . height + scroll . top - elementScroll ) >= context . bottom && element . height < context . height ) {
505
517
module . debug ( 'Initial element position is bottom of container' ) ;
506
518
module . bindBottom ( ) ;
507
519
}
@@ -580,6 +592,9 @@ $.fn.sticky = function(parameters) {
580
592
bindTop : function ( ) {
581
593
module . debug ( 'Binding element to top of parent container' ) ;
582
594
module . remove . offset ( ) ;
595
+ if ( settings . setSize ) {
596
+ module . set . size ( ) ;
597
+ }
583
598
$module
584
599
. css ( {
585
600
left : '' ,
@@ -597,6 +612,9 @@ $.fn.sticky = function(parameters) {
597
612
bindBottom : function ( ) {
598
613
module . debug ( 'Binding element to bottom of parent container' ) ;
599
614
module . remove . offset ( ) ;
615
+ if ( settings . setSize ) {
616
+ module . set . size ( ) ;
617
+ }
600
618
$module
601
619
. css ( {
602
620
left : '' ,
0 commit comments