From 7cececfbae9d1140d7500cceaebb1c5bd9d5c999 Mon Sep 17 00:00:00 2001 From: dpedu Date: Thu, 2 Apr 2015 11:41:11 -0700 Subject: [PATCH] Change order of getWidthFrom calculation to prevent innaccurate widths --- jquery.sticky.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.sticky.js b/jquery.sticky.js index 7417c47..807f01f 100644 --- a/jquery.sticky.js +++ b/jquery.sticky.js @@ -54,15 +54,15 @@ newTop = s.topSpacing; } if (s.currentTop != newTop) { + if (typeof s.getWidthFrom !== 'undefined') { + s.stickyElement.css('width', $(s.getWidthFrom).width()); + } + s.stickyElement .css('width', s.stickyElement.width()) .css('position', 'fixed') .css('top', newTop); - if (typeof s.getWidthFrom !== 'undefined') { - s.stickyElement.css('width', $(s.getWidthFrom).width()); - } - s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className); s.currentTop = newTop; }