From 5ce8b5aa5d062a0740dacdaa11e6c1333a016477 Mon Sep 17 00:00:00 2001 From: charles bourasseau Date: Fri, 4 Jul 2014 21:09:58 +0200 Subject: [PATCH] Position fixed influence the width of an element The width of the stickyElement should be set before the position change for fixed. If the getWidthFrom is the stickyElement itself, the width will be wrong. --- jquery.sticky.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.sticky.js b/jquery.sticky.js index 4072509..94420c2 100644 --- a/jquery.sticky.js +++ b/jquery.sticky.js @@ -52,13 +52,13 @@ newTop = s.topSpacing; } if (s.currentTop != newTop) { - s.stickyElement - .css('position', 'fixed') - .css('top', newTop); - if (typeof s.getWidthFrom !== 'undefined') { s.stickyElement.css('width', $(s.getWidthFrom).width()); } + + s.stickyElement + .css('position', 'fixed') + .css('top', newTop); s.stickyElement.parent().addClass(s.className); s.currentTop = newTop;