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

elementWidth() #21

Open markopaju opened 8 years ago

markopaju commented 8 years ago

function elementWidth() { return container ? container.clientWidth : nativeEl.offsetWidth; }

might be better

harm-less commented 8 years ago

I'm not sure, I consider the sticky element and the container as two separate things with their own properties. But why would you say this?

markopaju commented 8 years ago

I'm using the sticky (its a cool plugin) and run into an issue where the sticky was in a container but when you scrolled the page up and down the width for the sticky got really wide as nativeEl.offsetWidth calculated it wrong.

harm-less commented 6 years ago

I think the only way you can fix this (though I'm not 100% certain) with the current code is to use the draw method from the hl-sticky-element service. So you'll no longer be able to use the directive in that case.