Scroll Controller

A Scroll Controller is a special variable type that controls the scrolling behavior of scrollable widgets. It allows you to programmatically control scroll positions, create scroll-driven animations, and respond to scroll events.

Supported Widgets

The Scroll Controller can be used with:

When to Use

Use a Scroll Controller when you need to:

  • Programmatically scroll to specific positions

  • Create "scroll to top" buttons

  • Implement scroll-driven animations (parallax, fade effects)

  • Animate scrolling with custom easing curves

  • Track and respond to scroll positions

  • Synchronize scroll positions across multiple widgets

Creating a Scroll Controller

  1. Navigate to Variables in your project

  2. Click Add Variable

  3. Select Scroll Controller as the type

  4. Give it a descriptive name (e.g., listScrollController, pageScrollController)

Binding to Widgets

ListView Example

GridView Example

Smart Scroll View Example

Controller Methods

Use the Control Object action to invoke these methods on the controller.

jumpTo

Instantly jumps to a scroll position without animation.

Parameter
Type
Description

offset

Number

The scroll position in pixels

Example Use Cases:

  • Jump to top: offset: 0

  • Jump to bottom: offset: 99999

  • Jump to specific position: offset: 500

When to Use:

  • Immediate positioning needed (e.g., reset scroll on navigation)

  • No animation required

  • Faster than animateTo


animateTo

Smoothly animates the scroll to a given position.

Parameter
Type
Description

offset

Number

The scroll position in pixels

durationInMs

Number

Animation duration in milliseconds

curve

String

The easing curve for animation

Available Curves:

  • linear - Constant speed

  • easeIn - Slow start, fast end

  • easeOut - Fast start, slow end

  • easeInOut - Slow start and end, fast middle

  • bounceOut - Bouncing effect at end

  • elasticOut - Elastic spring effect

Example Use Cases:

  • Smooth scroll to top: offset: 0, durationInMs: 500, curve: 'easeOut'

  • Scroll to section: offset: 1200, durationInMs: 800, curve: 'easeInOut'

  • Quick scroll: offset: 500, durationInMs: 200, curve: 'linear'

When to Use:

  • Better UX with smooth transitions

  • Highlighting a scroll action

  • Drawing attention to content


Common Use Cases

1. Scroll to Top Button

Show a button that appears after scrolling down, which scrolls back to top when clicked.

Setup:

Implementation:

2. Scroll-Driven Animations

Create effects that respond to scroll position (headers that fade, parallax backgrounds).

Setup:

The animationValue variable inside Animation Builder represents the current scroll offset.

See the Using ListView with Animation Builder guide for detailed examples.

3. Navigate to Specific Section

Scroll to a specific item or section in a list.

4. Reset Scroll on Navigation

Reset scroll position when navigating to a page.

5. Synchronized Scrolling

Use the same controller on multiple widgets to synchronize their scroll positions.

Both widgets will scroll together.

Best Practices

  • One controller per scrollable widget: Each scrollable widget should have its own controller unless you want synchronized scrolling

  • Use descriptive names: Name controllers after their purpose (listScrollController, pageScrollController)

  • Choose appropriate curves: Use easeOut for most scroll animations, linear for quick jumps

  • Set reasonable durations: 300-600ms works well for most scroll animations; too long feels sluggish

  • Handle edge cases: Check scroll bounds before jumping to calculated positions

  • Use jumpTo for immediate actions: Use jumpTo on page load, animateTo for user-triggered actions

  • Optimize animation performance: Avoid heavy animations while scrolling for better performance

Common Patterns

Scroll to Top

Scroll to Bottom

Conditional Visibility Based on Scroll

Smooth Scroll to Section

Troubleshooting

Controller Not Working

  • Ensure the controller variable is properly created in Variables

  • Check that the controller is bound to the widget using ${controllerName}

  • Verify the widget supports Scroll Controller

Animation Feels Choppy

  • Reduce animation duration

  • Use a simpler easing curve like linear

  • Check for heavy widgets that might slow rendering

Scroll Position Not Accurate

  • Ensure offset values are correct

  • Check that content is fully loaded before scrolling

  • Consider using jumpTo first, then animateTo

  • Animation Builder - Create scroll-driven animations

  • Using ListView with Animation Builder - Detailed guide with examples

  • ListView - Scrollable list widget

  • GridView - Scrollable grid widget

  • Control Object Action - Invoke controller methods

  • Variables Overview - Learn about all variable types

Last updated