d-oliveros / ngSticky

AngularJS directive to make elements stick when scrolling down.
MIT License
351 stars 148 forks source link

on hide / show not re-rendering #23

Closed peteringram0 closed 9 years ago

peteringram0 commented 9 years ago

When using this plugin i am hiding the section that i am using 'sticky' on then showing the section on larger devices. The plugin works fine until the section is hided then shown again.

trevcor commented 9 years ago

I am also seeing this issue. It looks like the width is being set to 0 on show/hide.

trevcor commented 9 years ago

Changing my ng-show's to ng-if's fixes the problem for me. This makes sense since the directive will just re-run when the ng-if expresssion = true.

d-oliveros commented 9 years ago

Hmm... the problem is that the width of the element is being calculated on load, to keep the element's width even when position: fixed. I'll hapilly merge a PR if someone manages to fix this :)

In the meanwhile, you can use ng-if instead of ng-show, as @trevcor suggested.