Skip to content

Commit cd2310b

Browse files
authored
Rollup merge of #41131 - euclio:collapse-animation, r=GuillaumeGomez
rustdoc: collapse docblock before showing label The animation for collapsing descriptions is currently pretty jarring, as the label starts fading in as the description is collapsing. This causes the description to jump down a line (and sometimes change indentation) while animating. This PR modifies this behavior to collapse the block entirely before starting to fade in the collapse button label. While this PR works well for descriptions of structs, traits, etc., it still does not look ideal for attributes. I'd appreciate any suggestions for improving that animation. Perhaps we want to optimize for the single-attribute case, and try not to collapse the attribute list entirely before fading in the label?
2 parents 72308b1 + 8a1d2a3 commit cd2310b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: src/librustdoc/html/static/main.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -951,14 +951,21 @@
951951
if (relatedDoc.is(".docblock")) {
952952
if (relatedDoc.is(":visible")) {
953953
if (animate === true) {
954-
relatedDoc.slideUp({duration: 'fast', easing: 'linear'});
955-
toggle.children(".toggle-label").fadeIn();
954+
relatedDoc.slideUp({
955+
duration: 'fast',
956+
easing: 'linear',
957+
complete: function() {
958+
toggle.children(".toggle-label").fadeIn();
959+
toggle.parent(".toggle-wrapper").addClass("collapsed");
960+
toggle.children(".inner").text(labelForToggleButton(true));
961+
},
962+
});
956963
} else {
957964
relatedDoc.hide();
958965
toggle.children(".toggle-label").show();
966+
toggle.parent(".toggle-wrapper").addClass("collapsed");
967+
toggle.children(".inner").text(labelForToggleButton(true));
959968
}
960-
toggle.parent(".toggle-wrapper").addClass("collapsed");
961-
toggle.children(".inner").text(labelForToggleButton(true));
962969
} else {
963970
relatedDoc.slideDown({duration: 'fast', easing: 'linear'});
964971
toggle.parent(".toggle-wrapper").removeClass("collapsed");

0 commit comments

Comments
 (0)