0.1.3 • Published 5 years ago
@ewtd/ewt-anchor v0.1.3
USAGE
Install
$ npm i @ewtd/ewtdemo
import { Anchor } from '@ewtd/ewt';
const dataSource: [
{
title: 'string',
element: document.getElementById('title'),
},
{
title: <div>element</div>,
element: this.refs.element,
},
],
<Anchor
style={{
position: 'relative',
right: 0,
top: 0,
}}
dataSource={dataSource}
active={0}
initTop={0}
/>API
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| dataSource | 锚点列表 | array | {title: string / element, element: document.getElementById('##') / ref} |
| style | 自定义样式 | object | {position: 'fixed',top: 0,right: 0,width: '120px'} |
| active | 初始化滚动位置 | number | 0 |
| scrollState | scrollIntoView滚动的配置参数 | object | {{behavior: 'smooth',block: 'start'}} |
| throttle | 节流毫秒数 | number | 500 |
| timeout | scrollIntoView过程与滚动监听的间隔 | number | 1000 |
| initTop | 容器相对于窗口的距离(滚动计算是相对于window) | number | 0 |