diff --git a/lib/sticky.js b/lib/sticky.js index 2a96ff6..9c2f7fb 100644 --- a/lib/sticky.js +++ b/lib/sticky.js @@ -71,6 +71,15 @@ function onResize() { initialCSS.offsetWidth = elem.offsetWidth; checkIfShouldStick(); + + if(isSticking){ + var parent = window.getComputedStyle(elem.parentElement, null), + initialOffsetWidth = elem.parentElement.offsetWidth + - parent.getPropertyValue('padding-right').replace('px', '') + - parent.getPropertyValue('padding-left').replace('px', ''); + + $elem.css('width', initialOffsetWidth+'px'); + } } function onDestroy() { @@ -170,7 +179,7 @@ } $elem - .css('width', initialCSS.offsetWidth+'px') + .css('width', '') .css('top', initialCSS.top) .css('position', initialCSS.position) .css('margin-top', initialCSS.marginTop);