Skip to content

Commit

Permalink
Merge pull request #28 from dmgts/master
Browse files Browse the repository at this point in the history
Changed the behavior of the dynamic width
  • Loading branch information
d-oliveros committed Jan 12, 2015
2 parents 129ed44 + 887f52e commit dc3494c
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 dc3494c

Please sign in to comment.