forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Affix): implement affix by {position: absolute}
- Loading branch information
Showing
5 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 启用绝对布局 | ||
|
||
- order: 3 | ||
|
||
可以通过 `container` 属性设置 Affix 组件需要监听其滚动事件的元素,该属性接收一个函数作为参数,默认为 `() => window`; | ||
设置 absoluteAffix 为 true,通过 absolute 布局实现组件固定。 | ||
|
||
:::lang=en-us | ||
# Container | ||
|
||
- order: 3 | ||
|
||
Change the default container by passing a function to `container`. | ||
|
||
::: | ||
|
||
--- | ||
|
||
````jsx | ||
import { Affix, Button } from '@alifd/next'; | ||
|
||
class Demo extends React.Component { | ||
|
||
_containerRefHandler(ref) { | ||
this.container = ref; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="custom-affix-container" ref={this._containerRefHandler.bind(this)}> | ||
<div className="affix-wrapper"> | ||
<Affix container={() => this.container} offsetTop={0} absoluteAffix={true}> | ||
<Button type="secondary">Affixed Button</Button> | ||
</Affix> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
|
||
ReactDOM.render(<Demo />, mountNode); | ||
```` | ||
|
||
````css | ||
.custom-affix-container { | ||
height: 150px; | ||
overflow-y: scroll; | ||
width: 50px; | ||
background: url(https://img.alicdn.com/tfs/TB1AbJXSpXXXXXJXpXXXXXXXXXX-32-32.jpg) repeat 50% 50%; | ||
} | ||
|
||
.custom-affix-container .affix-wrapper { | ||
padding-top: 100px; | ||
height: 500px; | ||
} | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters