0.1.3 • Published 4 years ago

@ewtd/ewt-anchor v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

USAGE

Install

$ npm i @ewtd/ewt

demo

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初始化滚动位置number0
scrollStatescrollIntoView滚动的配置参数object{{behavior: 'smooth',block: 'start'}}
throttle节流毫秒数number500
timeoutscrollIntoView过程与滚动监听的间隔number1000
initTop容器相对于窗口的距离(滚动计算是相对于window)number0