ScrollPane

Scroll property

After the component or list is set to “overflow processing” as “horizontal scroll”, “vertical scroll”, and “free scroll”, the component or list becomes a scroll container. Click next to “Overflow Handling”Button, you can set detailed scroll related properties.

ScrollPane

When the component’s “overflow processing” is set to “rolling”,GComponent.scrollPaneUse scroll-related functions, such as:

ScrollPane scrollPane = aComponent.scrollPane;
    // Set the scroll position to 100 pixels
    scrollPane.posX = 100;
    // Scroll to the middle position with animation process
    scrollPane.SetPercX (0.5f, true);

After you add or delete subcomponents, or move the position of the subcomponent, adjust the size of the subcomponent, the container automatically updates the scroll area, and does not need to call any API. This refresh occurs before drawing this frame. If you want immediate access to the correct coordinates of the child element, you can callEnsureBoundsCorrectNotifies GComponent to reorder immediately. EnsureBoundsCorrect is a friendly function, you don’t need to worry about the extra performance cost of repeated calls.

The commonly used APIs in ScrollPane are:

You can listen for scroll changes, and in any case the scroll position change will trigger this event.

// Unity / Cry
    scrollPane.onScroll.Add (onScroll);
    // AS3
    scrollPane.addEventListener (Event.SCROLL, onScroll);
    // Egret
    scrollPane.addEventListener (ScrollPane.SCROLL, this.onScroll, this);
    // Laya, pay attention to listening with components, not ScrollPane
    aComponent.on (fairygui.Events.SCROLL, this, this.onScroll);
    // Cocos2dx, pay attention to listening with components, not ScrollPane
    aComponent-> addEventListener (UIEventType :: Scroll, CC_CALLBACK_1 (AClass :: onScroll, this));
    // CocosCreator, pay attention to using component listening, not ScrollPane
    aComponent.on (fgui.Event.SCROLL, this.onScroll, this);

Events related to scrolling:

//Unity/Cry
scrollPane.onScrollEnd.Add(onScrollEnd);
scrollPane.onPullDownRelease.Add(onPullDownRelease);
scrollPane.onPullUpRelease.Add(onPullUpRelease);
//AS3
scrollPane.addEventListener(ScrollPane.SCROLL_END, onScrollEnd);
scrollPane.addEventListener(ScrollPane.PULL_DOWN_RELEASE, onPullDownRelease);
scrollPane.addEventListener(ScrollPane.PULL_UP_RELEASE, onPullUpRelease);
//Egret
scrollPane.addEventListener(ScrollPane.SCROLL_END, this.onScrollEnd, this);
scrollPane.addEventListener(ScrollPane.PULL_DOWN_RELEASE, this.onPullDownRelease, this);
scrollPane.addEventListener(ScrollPane.PULL_UP_RELEASE, this.onPullUpRelease, this);
//Laya,注意是用组件侦听,不是ScrollPane
aComponent.on(fairygui.Events.SCROLL_END, this, this.onScrollEnd);
aComponent.on(fairygui.Events.PULL_DOWN_RELEASE, this, this.onPullDownRelease);
aComponent.on(fairygui.Events.PULL_UP_RELEASE, this, this.onPullUpRelease);
//Cocos2dx,注意是用组件侦听,不是ScrollPane
aComponent->addEventListener(UIEventType::ScrollEnd, CC_CALLBACK_1(AClass::onScrollEnd, this));
aComponent->addEventListener(UIEventType::PullDownRelease, CC_CALLBACK_1(AClass::onPullDownRelease, this));
aComponent->addEventListener(UIEventType::PullUpRelease, CC_CALLBACK_1(AClass::onPullUpRelease, this));
//CocosCreator,注意使用组件侦听,不是ScrollPane
scrollPane.on(fgui.Event.SCROLL_END, this.onScrollEnd, this);
scrollPane.on(fgui.Event.PULL_DOWN_RELEASE, this.onPullDownRelease, this);
scrollPane.on(fgui.Event.PULL_UP_RELEASE, this.onPullUpRelease, this);