Permalink
Browse files

Avoid affix element is higher than view port

  • Loading branch information...
afc163 committed Dec 10, 2017
1 parent e13c6d8 commit 31a0654ef990eb7bae2b18095fa0d5230b9be1da
Showing with 4 additions and 1 deletion.
  1. +3 −1 components/affix/index.tsx
  2. +1 −0 components/affix/style/index.less
@@ -157,10 +157,12 @@ export default class Affix extends React.Component<AffixProps, AffixState> {
if (scrollTop > elemOffset.top - (offsetTop as number) && offsetMode.top) {
// Fixed Top
const width = elemOffset.width;
const top = targetRect.top + (offsetTop as number);
this.setAffixStyle(e, {
position: 'fixed',
top: targetRect.top + (offsetTop as number),
top,
left: targetRect.left + elemOffset.left,
maxHeight: `calc(100vh - ${top}px)`,
width,
});
this.setPlaceholderStyle({
@@ -3,4 +3,5 @@
.@{ant-prefix}-affix {
position: fixed;
z-index: @zindex-affix;
overflow: auto;
}

2 comments on commit 31a0654

@afc163

This comment has been minimized.

Member

afc163 replied Dec 10, 2017

xx

@shtam

This comment has been minimized.

shtam replied Dec 18, 2017

The overflow:auto breaks any box-shadow on your containing divs, e.g.:

<Affix> <Header style={{ boxShadow: '0 2px 10px rgba(0,0,0,.2)' }}>Hello</Header> </Affix>

Any suggestions?

Please sign in to comment.