diff --git a/src/definitions/modules/sticky.js b/src/definitions/modules/sticky.js index abd884925..de00a4c60 100644 --- a/src/definitions/modules/sticky.js +++ b/src/definitions/modules/sticky.js @@ -43,8 +43,8 @@ $.fn.sticky = function(parameters) { $module = $(this), $window = $(window), - $container = $module.offsetParent(), $scroll = $(settings.scrollContext), + $container, $context, selector = $module.selector || '', @@ -65,6 +65,7 @@ $.fn.sticky = function(parameters) { initialize: function() { + module.determineContainer(); module.determineContext(); module.verbose('Initializing sticky', settings, $container); @@ -126,6 +127,10 @@ $.fn.sticky = function(parameters) { } }, + determineContainer: function() { + $container = $module.offsetParent(); + }, + determineContext: function() { if(settings.context) { $context = $(settings.context); @@ -191,7 +196,7 @@ $.fn.sticky = function(parameters) { module.determineContext(); } if(hardRefresh) { - $container = $module.offsetParent(); + module.determineContainer(); } module.save.positions(); module.stick(); @@ -337,7 +342,7 @@ $.fn.sticky = function(parameters) { if(tagName === 'HTML' || tagName == 'body') { // this can trigger for too many reasons //module.error(error.container, tagName, $module); - $container = $module.offsetParent(); + module.determineContainer(); } else { if( Math.abs($container.height() - module.cache.context.height) > 5) {