mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-29 03:48:26 +08:00
e8fa5938ab
* site: use CSS logical properties * Update components/anchor/demo/targetOffset.tsx Co-authored-by: afc163 <afc163@gmail.com> Signed-off-by: lijianan <574980606@qq.com> * fix: fix * fix: fix * chore: fix * fix: add more * fix: add more --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: afc163 <afc163@gmail.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { Anchor, Col, Row } from 'antd';
|
|
|
|
const style: React.CSSProperties = {
|
|
height: '30vh',
|
|
backgroundColor: 'rgba(0, 0, 0, 0.85)',
|
|
position: 'fixed',
|
|
top: 0,
|
|
insetInlineStart: 0,
|
|
width: '75%',
|
|
color: '#fff',
|
|
};
|
|
|
|
const App: React.FC = () => {
|
|
const topRef = React.useRef<HTMLDivElement>(null);
|
|
const [targetOffset, setTargetOffset] = useState<number>();
|
|
|
|
useEffect(() => {
|
|
setTargetOffset(topRef.current?.clientHeight);
|
|
}, []);
|
|
|
|
return (
|
|
<div>
|
|
<Row>
|
|
<Col span={18}>
|
|
<div
|
|
id="part-1"
|
|
style={{ height: '100vh', background: 'rgba(255,0,0,0.02)', marginTop: '30vh' }}
|
|
>
|
|
Part 1
|
|
</div>
|
|
<div id="part-2" style={{ height: '100vh', background: 'rgba(0,255,0,0.02)' }}>
|
|
Part 2
|
|
</div>
|
|
<div id="part-3" style={{ height: '100vh', background: 'rgba(0,0,255,0.02)' }}>
|
|
Part 3
|
|
</div>
|
|
</Col>
|
|
<Col span={6}>
|
|
<Anchor
|
|
targetOffset={targetOffset}
|
|
items={[
|
|
{ key: 'part-1', href: '#part-1', title: 'Part 1' },
|
|
{ key: 'part-2', href: '#part-2', title: 'Part 2' },
|
|
{ key: 'part-3', href: '#part-3', title: 'Part 3' },
|
|
]}
|
|
/>
|
|
</Col>
|
|
</Row>
|
|
<div style={style} ref={topRef}>
|
|
<div>Fixed Top Block</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default App;
|