Skip to content

Commit

Permalink
Changed the behavior of the dynamic width
Browse files Browse the repository at this point in the history
  • Loading branch information
dmhts committed Jan 12, 2015
1 parent 129ed44 commit 887f52e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 887f52e

Please sign in to comment.