File tree 2 files changed +15
-5
lines changed
src/librustdoc/html/static
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1931,18 +1931,24 @@ in storage.js
1931
1931
}
1932
1932
1933
1933
.scraped-example : not (.expanded ) .code-wrapper {
1934
- max-height : 120px ;
1934
+ /* scrape-examples.js has a constant DEFAULT_MAX_LINES (call it N) for the number
1935
+ * of lines shown in the un-expanded example code viewer. This pre needs to have
1936
+ * a max-height equal to line-height * N. The line-height is currently 1.5em,
1937
+ * and we include additional 10px for padding. */
1938
+ max-height : calc (1.5em * 5 + 10px );
1935
1939
}
1936
1940
1937
1941
.scraped-example : not (.expanded ) .code-wrapper pre {
1938
1942
overflow-y : hidden;
1939
- max-height : 120px ;
1940
1943
padding-bottom : 0 ;
1944
+ /* See above comment, should be the same max-height. */
1945
+ max-height : calc (1.5em * 5 + 10px );
1941
1946
}
1942
1947
1943
1948
.more-scraped-examples .scraped-example : not (.expanded ) .code-wrapper ,
1944
1949
.more-scraped-examples .scraped-example : not (.expanded ) .code-wrapper pre {
1945
- max-height : 240px ;
1950
+ /* See above comment, except this height is based on HIDDEN_MAX_LINES. */
1951
+ max-height : calc (1.5em * 10 + 10px );
1946
1952
}
1947
1953
1948
1954
.scraped-example .code-wrapper .next ,
Original file line number Diff line number Diff line change 6
6
// Number of lines shown when code viewer is not expanded.
7
7
// DEFAULT is the first example shown by default, while HIDDEN is
8
8
// the examples hidden beneath the "More examples" toggle.
9
+ //
10
+ // NOTE: these values MUST be synchronized with certain rules in rustdoc.css!
9
11
const DEFAULT_MAX_LINES = 5 ;
10
12
const HIDDEN_MAX_LINES = 10 ;
11
13
24
26
} else {
25
27
const wrapper = elt . querySelector ( ".code-wrapper" ) ;
26
28
const halfHeight = wrapper . offsetHeight / 2 ;
27
- const offsetMid = ( lines . children [ loc [ 0 ] ] . offsetTop
28
- + lines . children [ loc [ 1 ] ] . offsetTop ) / 2 ;
29
+ const offsetTop = lines . children [ loc [ 0 ] ] . offsetTop ;
30
+ const lastLine = lines . children [ loc [ 1 ] ] ;
31
+ const offsetBot = lastLine . offsetTop + lastLine . offsetHeight ;
32
+ const offsetMid = ( offsetTop + offsetBot ) / 2 ;
29
33
scrollOffset = offsetMid - halfHeight ;
30
34
}
31
35
You can’t perform that action at this time.
0 commit comments