Skip to main content

ScrollBar 滚动条

例子#

基本用法#

import { Window, ScrollBar } from 'ave-ui';
export function main(window: Window) {    const scrollBar = new ScrollBar(window);    scrollBar.SetMinimum(0).SetMaximum(100).SetValue(50).SetShrink(false);    scrollBar.OnScrolling((sender: ScrollBar) => {        console.log(sender.GetValue());    });
    const container = getControlDemoContainer(window, 2, 120, 16);    container.ControlAdd(scrollBar).SetGrid(1, 1, 2, 1);    window.SetContent(container);}

在这个例子中,我们演示了滚动条的基本用法:设置它的上下限(0 ~ 100)与当前值(50),拖动滑块,通过设置的回调获取变化的当前位置的值:

scroll bar basic

控制台将会有这样的输出:

504949484847...363635353434

另外,在这个例子中,我们设置了shrinkfalse,它的作用是使得滚动条大小不变,当设置为true时,效果如下:

scroll bar shrink

API#

export interface IScrollBar extends IControl {    SetMinimum(min: number): ScrollBar;    GetMinimum(): number;
    SetMaximum(max: number): ScrollBar;    GetMaximum(): number;
    SetValue(value: number): ScrollBar;    GetValue(): number;
    SetShrink(shrink: boolean): ScrollBar;    GetShrink(): boolean;
    OnScrolling(callback: (sender: ScrollBar) => void): ScrollBar;}