Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

chore(docs/docModuleComponents): allow browser to scroll to anchors #4723

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/src/templates/js/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) {
}
};

docsApp.directive.docModuleComponents = ['sections', function(sections) {
docsApp.directive.docModuleComponents = ['sections', '$anchorScroll', '$timeout', function(sections, $anchorScroll, $timeout) {
return {
template: ' <div class="component-breakdown">' +
' <h2>Module Components</h2>' +
Expand Down Expand Up @@ -246,9 +246,14 @@ docsApp.directive.docModuleComponents = ['sections', function(sections) {
}
});
$scope.components = components;
}]
}],
link: function() {
// This directive creates new HTML that contains anchors. We need to give the browser the
// opportunity to scroll to them after they have been rendered.
$timeout($anchorScroll);
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't the autoscroll on ngInclude sufficient?

https://github.com/petebacondarwin/angular.js/blob/ec2db151336a4eeb44d7f6fb59e9411416ee2cf2/docs/src/templates/index.html#L336

the use of $timeout just tells me that we have some ordering issue somewhere and timeout seems to fix it, but if whatever is delaying rendering takes longer than the amount of delay timeout gives us the autoscroll will not work once again.

}
};
}]
}];

docsApp.directive.docTutorialNav = function(templateMerge) {
var pages = [
Expand Down