Move maxHeight code into anchor, close #8606

This commit is contained in:
afc163 2017-12-28 13:13:27 +08:00
parent 98ec9100c3
commit 8fb285fce9
6 changed files with 17 additions and 3 deletions

View File

@ -162,7 +162,6 @@ export default class Affix extends React.Component<AffixProps, AffixState> {
position: 'fixed',
top,
left: targetRect.left + elemOffset.left,
maxHeight: `calc(100vh - ${top}px)`,
width,
});
this.setPlaceholderStyle({

View File

@ -3,5 +3,4 @@
.@{ant-prefix}-affix {
position: fixed;
z-index: @zindex-affix;
overflow: auto;
}

View File

@ -226,8 +226,16 @@ export default class Anchor extends React.Component<AnchorProps, any> {
'fixed': !affix && !showInkInFixed,
});
const wrapperStyle = {
maxHeight: offsetTop ? `calc(100vh - ${offsetTop}px)` : '100vh',
...style,
};
const anchorContent = (
<div className={wrapperClass} style={style}>
<div
className={wrapperClass}
style={wrapperStyle}
>
<div className={anchorClass}>
<div className={`${prefixCls}-ink`} >
<span className={inkClass} ref={this.saveInkNode} />

View File

@ -7,6 +7,7 @@ exports[`renders ./components/anchor/demo/basic.md correctly 1`] = `
>
<div
class="ant-anchor-wrapper"
style="max-height:100vh"
>
<div
class="ant-anchor"
@ -82,6 +83,7 @@ exports[`renders ./components/anchor/demo/basic.md correctly 1`] = `
exports[`renders ./components/anchor/demo/static.md correctly 1`] = `
<div
class="ant-anchor-wrapper"
style="max-height:100vh"
>
<div
class="ant-anchor fixed"

View File

@ -7,8 +7,12 @@
.reset-component;
position: relative;
padding-left: @anchor-border-width;
&-wrapper {
background-color: @component-background;
overflow: auto;
padding-left: 4px;
margin-left: -4px;
}
&-ink {

View File

@ -50,6 +50,8 @@ ul.toc > li {
right: 20px;
.ant-affix {
background: #fff;
overflow: auto;
max-height: ~"calc(100vh - 16px)";
}
}
.toc-affix-bottom {