From 887f52e37ced362e062d9b880d86beb1e52094b6 Mon Sep 17 00:00:00 2001 From: Gutsulyak Dmitry Date: Mon, 12 Jan 2015 12:32:44 +0200 Subject: [PATCH] Changed the behavior of the dynamic width --- lib/sticky.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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);