harm-less / angular-sticky

Pure javascript AngularJS directive to make elements stick when scrolling
http://harm-less.github.io/angular-sticky
83 stars 38 forks source link

Sticky element position don't rerendred on resize #38

Open carpogoryanin opened 6 years ago

carpogoryanin commented 6 years ago

Hi. I use this code for program usage of angular-sticky and add resize into events. resize events working, but sticky elemen not rerendered. Only after scroll it fix position:

angular.element($window).bind('scroll resize', function() {
    // draw the sticky element through an apply as the event wasn't from Angular
    $scope.$apply(function() {
        stickyElement.draw();
    });
});

Do you have some ideas what wrong?

catalinoprea commented 6 years ago

You could use angular.element(document.body).injector().get('hlStickyElement')(stickyElement).draw()

On my page doesn't recalculate the correct height of the containers, but on your page maybe will work :)

PS: stickyElement I assume that is an Angular Element type already initialised.