@antv/s2
Version:
effective spreadsheet render core lib
76 lines (75 loc) • 2.55 kB
TypeScript
import { Group, type DisplayObject, type ICanvas } from '@antv/g';
import type { ScrollBarTheme } from '../../common/interface/theme';
import type { PointObject, ScrollBarCfg } from './interface';
export declare enum ScrollType {
ScrollChange = "scroll-change",
ScrollEnd = "scroll-end"
}
export interface EventListenerReturn {
remove: () => void;
}
export type EventHandler = {
target: ICanvas;
type: keyof HTMLElementEventMap;
handler: (e: any) => void;
};
export declare class ScrollBar extends Group {
isHorizontal: boolean;
trackLen: number;
thumbLen: number;
position: PointObject;
thumbOffset: number;
scrollTargetMaxOffset: number;
theme: ScrollBarTheme;
scrollBarGroup: Group;
trackShape: DisplayObject;
thumbShape: DisplayObject;
private startPos;
private clearEvents;
private eventHandlers;
private scrollFrameId;
constructor(scrollBarCfg: ScrollBarCfg);
private getCoordinatesName;
/**
* Antv/g 5.0 环境下坐标修正
*
* 当 lineCap 设置为非 'butt' 后,实际绘制左右两端会多两个头,且不计入 getBBox 的计算
* 如长100,strokeWidth=10,实际渲染110长度的线,getBBox 仍返回100
*/
private getCoordinatesWithBBoxExtraPadding;
/**
* 当前滑块滑动的位置 0 ~ 1
*/
current: () => number;
/**
* 更新滑块长度
* @param newThumbLen 新的滑道长度
*/
updateThumbLen: (newThumbLen: number) => void;
/**
* 更新滑块的 offset 值
* @param offset
*/
updateThumbOffset: (offset: number, emitScrollChange?: boolean) => void;
/**
* 只更新位置属性,而不emit滚动事件
* @param offset
*/
onlyUpdateThumbOffset: (offset: number) => void;
emitScrollChange: (offset: number, updateThumbOffset?: boolean) => void;
protected bindEventListener: (target: EventTarget, eventType: keyof HTMLElementEventMap, callback: EventListenerOrEventListenerObject) => EventListenerReturn;
protected addEvent: (target: EventHandler['target'], type: EventHandler['type'], handler: EventHandler['handler']) => void;
private initScrollBar;
private createScrollBarGroup;
private createTrackShape;
private createThumbShape;
private bindEvents;
private onStartEvent;
private bindLaterEvent;
private onTrackClick;
private onPointerMove;
private onPointerUp;
private onTrackPointerOver;
private onTrackPointerOut;
private validateRange;
}