UNPKG

@aplus-frontend/ui

Version:

92 lines (91 loc) 2.19 kB
import { InternalScrollBarProps, ScrollBarDirection } from '../scroll-bar'; type BarExtraProps = Omit<InternalScrollBarProps, 'direction' | 'scroll' | 'barLength'>; export type ScrollOffsetType = { x: number; y: number; }; export type AutoPlayConfig = { /** * 自动滚动的方向 */ direction?: ScrollBarDirection; /** * 自动滚动的速率,每一帧滚动的长度 */ rate?: number; /** * 是否开启重复滚动 */ repeat?: boolean; }; export interface ScrollViewProps { /** * 外部容器的宽度,当需要横向滚动条时必需设置 */ width?: number | string; /** * 外部容器的高度,当需要竖向滚动时必须设置 */ heigth?: number | string; /** * 是否显示横向滚动条(前提是可以横向滚动) */ showXBar?: boolean; /** * 是否显示竖向滚动条(前提是可以竖向滚动) */ showYBar?: boolean; /** * 设置自动滚动 */ autoPlay?: true | AutoPlayConfig; /** * 横向滚动条额外可配置的属性 */ xBarProps?: BarExtraProps; /** * 竖向滚动条额外可配置属性 */ yBarProps?: BarExtraProps; /** * 滚轮滚动事件 * @returns */ onWheel?: (direction: ScrollBarDirection, offset: number) => void; } export type ScrollOptions = { top?: number; left?: number; smooth?: boolean; }; export type ScrollViewExpose = { /** * 当前滚动距离顶部的位置 */ scrollTop: number; /** * 当前滚动距离左侧的位置 */ scrollLeft: number; /** * 滚动到指定位置 * @param x * @param y * @returns */ scroll: (x?: number, y?: number) => void; /** * 滚动到指定位置(支持指定平滑滚动) * @param options * @returns */ scrollTo: (options: ScrollOptions) => void; /** * 将子元素滚动到可视区域 * @param element * @param position * @returns */ scrollIntoView: (element: Element, position?: 'start' | 'center' | 'end') => void; }; export {};