Interface for Scroller component.

Scroller 组件接口。

interface IScroller {
    barDisplay: ScrollBarDisplay;
    barFloating: boolean;
    barMargin: number[];
    barOnLeft: boolean;
    bouncebackEffect: ScrollBounceBackEffect;
    get contentHeight(): number;
    get contentWidth(): number;
    decelerationRate: number;
    direction: ScrollDirection;
    get footer(): GWidget;
    footerRes: Prefab;
    get header(): GWidget;
    headerRes: Prefab;
    get hScrollBar(): GScrollBar;
    hScrollBarRes: Prefab;
    inertiaDisabled: boolean;
    get isBottomMost(): boolean;
    get isDragged(): boolean;
    get isRightMost(): boolean;
    mouseWheelDisabled: boolean;
    owner: GPanel;
    paddingMaskDisabled: boolean;
    get pageCountX(): number;
    get pageCountY(): number;
    pageMode: boolean;
    pageX: number;
    pageY: number;
    percX: number;
    percY: number;
    posX: number;
    posY: number;
    get scrollingPosX(): number;
    get scrollingPosY(): number;
    snapToItem: boolean;
    step: number;
    touchEffect: ScrollTouchEffect;
    touchEffectButton: number;
    get viewHeight(): number;
    get viewWidth(): number;
    get vScrollBar(): GScrollBar;
    vScrollBarRes: Prefab;
    cancelDragging(): void;
    getFirstChildInView(): number;
    isChildInView(obj: GWidget): boolean;
    lockFooter(size: number): void;
    lockHeader(size: number): void;
    scrollBottom(ani?: boolean): void;
    scrollDown(ratio?: number, ani?: boolean): void;
    scrollLeft(ratio?: number, ani?: boolean): void;
    scrollRight(ratio?: number, ani?: boolean): void;
    scrollTo(target: GWidget, ani?: boolean, setFirst?: boolean): void;
    scrollTo(target: GWidget, ani?: boolean, secondTarget?: GWidget): void;
    scrollTo(target: Rectangle, ani?: boolean, setFirst?: boolean): void;
    scrollTo(target: number, ani?: boolean, setFirst?: boolean): void;
    scrollTop(ani?: boolean): void;
    scrollUp(ratio?: number, ani?: boolean): void;
    setPageX(value: number, ani?: boolean): void;
    setPageY(value: number, ani?: boolean): void;
    setPercX(value: number, ani?: boolean): void;
    setPercY(value: number, ani?: boolean): void;
    setPosX(value: number, ani?: boolean): void;
    setPosY(value: number, ani?: boolean): void;
    setViewSize(width: number, height: number): void;
}

实现于

访问器

  • get decelerationRate(): number
  • 返回 number

    The deceleration rate of the scroller. The global default value can be set through UIConfig2.defaultScrollDecelerationRate.

    Scroller 的减速率。全局的默认值可以通过UIConfig2.defaultScrollDecelerationRate设置。

  • set decelerationRate(value): void
  • 参数

    • value: number

    返回 void

  • get isDragged(): boolean
  • 返回 boolean

    Returns true if the scroller is being dragged, otherwise false.

    Whether the scroller is currently being dragged.

    Scroller 是否正在被拖动。

  • get paddingMaskDisabled(): boolean
  • 返回 boolean

    Whether to disable padding mask. Generally, the viewport does not include the padding area set around it, meaning that the empty space around the container will also be clipped. If needed, this option can be checked to prevent clipping of the empty space around the container.

    禁用裁剪边缘。一般情况下,视口不包括边缘设置的部分,也即是容器设置四周的留空部分也会被裁剪。如果需要,可以勾选这个选项,使容器四周的留空部分不被裁剪。

  • set paddingMaskDisabled(value): void
  • 参数

    • value: boolean

    返回 void

  • get scrollingPosX(): number
  • 返回 number

    When no bounce occurs, the value is the same as posX; when a bounce occurs, posX is constrained between 0 and overlapSize.x, while scrollingPosX returns the actual position value.

    当没有发生回弹时,返回值和posX一致;当发生回弹时,posX会被限制在0和overlapSize.x之间,而scrollingPosX会返回真实的位置值。

  • get scrollingPosY(): number
  • 返回 number

    When no bounce occurs, the value is the same as posY; when a bounce occurs, posY is constrained between 0 and overlapSize.y, while scrollingPosY returns the actual position value.

    当没有发生回弹时,返回值和posY一致;当发生回弹时,posY会被限制在0和overlapSize.y之间,而scrollingPosY会返回真实的位置值。

  • get step(): number
  • 返回 number

  • set step(value): void
  • 参数

    • value: number

    返回 void

    The step size for scrolling when using the mouse wheel. The global default value can be set through UIConfig2.defaultScrollStep.

    当使用鼠标滚轮滚动时,每次滚动的距离。全局的默认值可以通过UIConfig2.defaultScrollStep设置。

  • get touchEffectButton(): number
  • 返回 number

    The touch effect for buttons in the scroller. Default value can be set globally through UIConfig2.touchEffectButton.

    用于触摸拖动的鼠标按键,开启了touchEffect后有效。 0-左键,1-中键,2-右键。

  • set touchEffectButton(value): void
  • 参数

    • value: number

    返回 void

方法

  • 返回 number

    Returns the index of the first child widget in view, or -1 if no child is in view.

    Gets the index of the first child widget that is currently in view.

    获取当前在视图中的第一个子部件的索引。

  • 参数

    • obj: GWidget

      The child widget to check.

    返回 boolean

    Returns true if the child widget is in view, otherwise false.

    Checks if a specific child widget is currently in view.

    检查指定的子部件是否在视图中。

  • 参数

    • size: number

      The size of the footer.

    返回 void

    Locks the footer widget, keeping it visible and fixed at the bottom during scrolling.

    锁定页尾部件,即使其显示,并在滚动时保持在底部。

  • 参数

    • size: number

      The size of the header.

    返回 void

    Locks the header widget, keeping it visible and fixed at the top during scrolling.

    锁定页头部件,即使其显示,并在滚动时保持在顶部。

  • 参数

    • 可选ani: boolean

      Whether to animate the scroll action.

    返回 void

    Scrolls to the bottom of the content area.

    滚动到内容区域的底部。

  • 参数

    • 可选ratio: number

      The ratio of the step size, ranging from 0 to 1, with a default value of 1. The base is the value of the step property , and if in page mode, the base is the height of the page.

    • 可选ani: boolean

      Whether to use an animated transition, default is false.

    返回 void

    Scrolls down once, with the step size controlled by the ratio parameter.

    向下滚动一次,步长由ratio参数控制。

  • 参数

    • 可选ratio: number

      The ratio of the step size, ranging from 0 to 1, with a default value of 1. The base is the value of the step property, and if in page mode, the base is the width of the page.

    • 可选ani: boolean

      Whether to use an animated transition, default is false.

    返回 void

    Scrolls to the left once, with the step size controlled by the ratio parameter.

    向左滚动一次,步长由ratio参数控制。

  • 参数

    • 可选ratio: number

      The ratio of the step size, ranging from 0 to 1, with a default value of 1. The base is the value of the step property, and if in page mode, the base is the width of the page.

    • 可选ani: boolean

      Whether to use an animated transition, default is false.

    返回 void

    Scrolls to the right once, with the step size controlled by the ratio parameter.

    向右滚动一次,步长由ratio参数控制。

  • 参数

    • target: GWidget

      The target widget to scroll to.

    • 可选ani: boolean

      Whether to animate the scroll action, default is false.

    • 可选setFirst: boolean

      If true, sets the target as the first child in view.

    返回 void

    Scrolls to a specific target widget, with an option to animate the scroll action.

    滚动到指定的目标部件,可以选择是否使用动画过渡。

  • 参数

    • target: GWidget

      The target rectangle to scroll to.

    • 可选ani: boolean

      Whether to animate the scroll action, default is false.

    • 可选secondTarget: GWidget

      If not null, sets it as the first child in view.

    返回 void

    Scrolls to a specific target rectangle, with an option to animate the scroll action.

    滚动到指定的目标矩形,可以选择是否使用动画过渡。

  • 参数

    • target: Rectangle

      The target rectangle to scroll to.

    • 可选ani: boolean

      Whether to animate the scroll action, default is false.

    • 可选setFirst: boolean

      If true, sets the target as the first child in view.

    返回 void

    Scrolls to a specific target rectangle, with an option to animate the scroll action.

    滚动到指定的目标矩形,可以选择是否使用动画过渡。

  • 参数

    • target: number

      The index of the child to scroll to.

    • 可选ani: boolean

      Whether to animate the scroll action, default is false.

    • 可选setFirst: boolean

      If true, sets the target as the first child in view.

    返回 void

    Scrolls to a child with specific index, with an option to animate the scroll action.

    滚动到指定索引的子项,可以选择是否使用动画过渡。

  • 参数

    • 可选ani: boolean

      Whether to animate the scroll action.

    返回 void

    Scrolls to the top of the content area.

    滚动到内容区域的顶部。

  • 参数

    • 可选ratio: number

      The ratio of the step size, ranging from 0 to 1, with a default value of 1. The base is the value of the step property, and if in page mode, the base is the height of the page.

    • 可选ani: boolean

      Whether to use an animated transition, default is false.

    返回 void

    Scrolls up once, with the step size controlled by the ratio parameter.

    向上滚动一次,步长由ratio参数控制。

  • 参数

    • value: number

      The page index value.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the index of the current page in the x-direction.

  • 参数

    • value: number

      The page index value.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the index of the current page in the y-direction.

  • 参数

    • value: number

      The percentage value, ranging from 0 to 1.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the percentage of the scroller's position in the x-direction.

    设置 Scroller 在 x 方向上的位置百分比。

  • 参数

    • value: number

      The percentage value, ranging from 0 to 1.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the percentage of the scroller's position in the y-direction.

    设置 Scroller 在 y 方向上的位置百分比。

  • 参数

    • value: number

      The x-coordinate value.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the x-coordinate of the top-left corner of the scroller's content.

    设置 Scroller 内容的左上角 x 坐标。

  • 参数

    • value: number

      The y-coordinate value.

    • 可选ani: boolean

      Whether to animate the change.

    返回 void

    Sets the y-coordinate of the top-left corner of the scroller's content.

    设置 Scroller 内容的左上角 y 坐标。

  • 参数

    • width: number

      The width of the viewport.

    • height: number

      The height of the viewport.

    返回 void

    Sets the size of the viewport.

    设置 Scroller 视口的大小。