ScrollView

A composite that allows its content to overflow either vertically (default) or horizontally. Since the ScrollView does not compute its own size, the width and height must be defined by the respective layout properties (e.g. either width or left and right must be specified).

Import this type with “const {ScrollView} = require('tabris');”

Android

iOS

Methods

scrollToX(offset, options)

Parameters:

offset: number

the offset to scroll to in dip.

options: {animate?: boolean} [Optional]

an additional object to control the animation. Set to {animate: false} to scroll without an animation.

Returns:this

Scrolls to the given horizontal offset. Give {animate: false} as the second parameter to suppress the animation.

scrollToY(offset, options)

Parameters:

offset: number

the offset to scroll to in dip.

options: {animate?: boolean} [Optional]

an additional object to control the animation. Set to {animate: false} to scroll without an animation.

Returns:this

Scrolls to the given vertical offset. Give {animate: false} as the second parameter to suppress the animation.

scrollX

Event Parameters

scrollY

Fired while scrolling vertically.

Event Parameters

target: this
The widget the event was fired on.

offset: number
Indicates the current vertical scrolling position.

Example

const{Button,ScrollView,TextView,ui}=require('tabris');// Create a horizontal scroll view and populate it with text viewsletscrollView=newScrollView({left:0,right:0,top:'40%',bottom:'40%',direction:'horizontal',background:'#234'}).appendTo(ui.contentView);for(leti=0;i<=50;i++){newTextView({left:i*30+20,centerY:0,width:30,textColor:'white',text:i+'°'}).appendTo(scrollView);}newButton({left:16,bottom:16,text:'scroll'}).on('select',()=>scrollView.scrollToX(310)).appendTo(ui.contentView);