Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Use $timeout to execute directive after $digest #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpetitcolas
Copy link
Contributor

We are using your directive with ui-router. We got two different states (pages), each one having a sticky header. At first display (clicking on refresh button), everything works fine. Yet, when switching page, the header is not well displayed.

This is due to the $digest cycle. The sticky header is initialized before the DOM is fully rendered, causing some troubles with dimension computations. Adding a $timeout would wait for the whole DOM page to be rendered before executing the link function.

scrollableContainer = $(window);
}
link: function(scope, element, attributes, control) {
$timeout(function () {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using scope.$$postDigest()?

Copy link
Contributor Author

@jpetitcolas jpetitcolas Apr 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$$ shows a private method for Angular. Thus, if we can prevent from using it... ;)

@keithnlarsen
Copy link
Contributor

I'm no longer doing Angular development, and I have no way of doing extensive testing of this directive, as I made it when I was working on a project for a different company that I no longer work for. I would like to keep it maintained however as there seems to be quite a few people using it. Would you like me to merge this patch? The other one has a bunch of merge conflicts and I don't feel like fixing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants