Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 71 ยท Components and Interaction

ScrollView in Depth: Bounce, Zoom, Snapping and Scroll Events

Go beyond the basics of ScrollView: bounce and deceleration, zooming, snapToInterval and pagination, momentum and drag events, indicators, and when not to use it.

The previous lesson covered the everyday ScrollView: scrolling, contentContainerStyle, refresh and the keyboard. This lesson goes through the rest of its props, grouped by what they change, so that when you see an unfamiliar one in a code base you know where it belongs. Many of them are platform-specific, which is the first thing to remember: a prop marked iOS has no effect on Android, and the other way round, and React Native does not warn you.

What runs on this site. Scrolling physics belong to the native platform, so the real React Native code below is read-only. The runnable examples are stand-ins: plain JavaScript that computes the same numbers the native scroller uses (snap positions, event order), drawn as HTML.

Props by purpose

Where ScrollView props live

Feel Bounce, deceleration, overscroll.
Zoom Min, max and current scale.
Snapping Interval, offsets, paging.
Events Drag, momentum, size change.

Check the platform badge before using a prop.

1 / 2

The feel of scrolling

Bounce and overscroll. On iOS, a list that is dragged past its end springs back. bounces={false} turns that off. alwaysBounceVertical and alwaysBounceHorizontal make a scroll view bounce even when its content is smaller than the view (by default it only bounces when the content is larger). Android's equivalent is overScrollMode, which takes "auto", "always" or "never": the glow or stretch effect at the edge.

Deceleration. After you lift your finger, the view keeps moving and slows down. decelerationRate controls how fast it slows: the strings "normal" and "fast", or a number just under 1 (a bigger number glides further). "fast" is the usual partner of snapping, so the view settles quickly on the target.

Direction lock. directionalLockEnabled (iOS) stops a diagonal drag from scrolling both ways, locking to whichever direction the finger moved first. Useful for a horizontal carousel inside a vertical page.

Indicators. showsVerticalScrollIndicator and showsHorizontalScrollIndicator hide the scroll bars. indicatorStyle (iOS) picks "default", "black" or "white" so the bar is visible on your background, and scrollIndicatorInsets (iOS) moves the bar inward, for example below a translucent header. On Android, persistentScrollbar keeps the bar visible instead of fading it out, and fadingEdgeLength adds a fading edge to the content. flashScrollIndicators() is an instance method (iOS) that shows the bars briefly, a nice hint that the content scrolls.

Insets and centering. contentInset (iOS) adds space around the content inside the scrollable area, and contentInsetAdjustmentBehavior="automatic" lets iOS add the right amount for a navigation bar or safe area. centerContent (iOS) centres content that is smaller than the view. contentOffset sets the starting scroll position. scrollsToTop (iOS, default true) scrolls back to the top when the user taps the status bar; set it to false on a scroll view that should not respond, usually when several are on screen.

Sticky headers. stickyHeaderIndices pins children, and invertStickyHeaders pins them to the bottom instead, which is for inverted lists.

Keeping position. maintainVisibleContentPosition={{ minIndexForVisible: 0, autoscrollToTopThreshold: 10 }} keeps the visible content steady when items are added above it, as in a chat app that loads older messages. The autoscrollToTopThreshold lets the view stay glued to the newest message while the user is near the top.

JSX
<ScrollView
  bounces={false}
  overScrollMode="never"
  decelerationRate="fast"
  showsVerticalScrollIndicator={false}
  contentInsetAdjustmentBehavior="automatic"
  scrollsToTop={false}
>
  {children}
</ScrollView>

Zooming

Pinch zoom is an iOS feature of ScrollView, controlled by:

Prop Meaning
minimumZoomScale the smallest scale (default 1)
maximumZoomScale the largest scale (default 1, which disables zoom)
zoomScale the current scale, readable and settable
bouncesZoom whether zooming springs past the limits and settles back
pinchGestureEnabled allow or block the pinch gesture itself

Zooming only turns on when maximumZoomScale is greater than minimumZoomScale. The usual setup is minimumZoomScale={1} maximumZoomScale={4} around an Image for a photo viewer. On Android, ScrollView has no built-in pinch zoom; use a gesture library (see Reanimated and Gestures) or a ready-made image viewer.

Snapping and pagination

There are three levels of snapping, from simplest to most flexible.

  1. pagingEnabled snaps to multiples of the view's own width (or height, vertically). One screen equals one page.
  2. snapToInterval={n} snaps to every n points. Use it for cards narrower than the screen so the next card peeks out. Pair it with decelerationRate="fast".
  3. snapToOffsets={[0, 120, 400, 700]} snaps to a list of positions, for uneven items.

Fine tuning: snapToAlignment (iOS) decides which part of the card lands on the snap point: "start" (the default), "center" or "end". snapToStart and snapToEnd (default true) decide whether the very start and end of the content are snap points too. disableIntervalMomentum makes a flick move at most one interval at a time instead of gliding across several. Inside a FlatList, the same props are available because it is built on ScrollView.

JSX
const CARD = 260;
const GAP = 12;

<ScrollView
  horizontal
  snapToInterval={CARD + GAP}      // card width plus the gap after it
  snapToAlignment="start"
  decelerationRate="fast"
  disableIntervalMomentum
  contentContainerStyle={{ gap: GAP, paddingHorizontal: 16 }}
  showsHorizontalScrollIndicator={false}
>
  {cards.map((c) => <Card key={c.id} width={CARD} {...c} />)}
</ScrollView>

The interval must include the gap. A common bug is snapToInterval={CARD}: each snap then drifts by the gap, and by the fifth card the alignment is visibly wrong.

The next example is a stand-in. It uses the same rules to turn a release position into the snap position, so you can see how snapToInterval, snapToStart, snapToEnd and the content size interact.

Where does the scroll settle? (snap calculator)

Slide the control and watch the rows. The maximum offset is content - view, so the last snap point is 640 whenever snapToEnd is true, even though 640 is not a multiple of 272: that is what lets you reach the end of the content. With snapToEnd off, the last card can end up out of reach.

Scroll events

A scroll produces a fixed sequence of events. Knowing the order lets you choose the right callback.

Callback Fires when
onScrollBeginDrag the finger starts moving the content
onScroll the offset changes (many times; see scrollEventThrottle)
onScrollEndDrag the finger lifts
onMomentumScrollBegin the content keeps moving after the lift
onMomentumScrollEnd the content has come to rest
onContentSizeChange the size of the content changes, with (width, height)
onScrollToTop (iOS) the user tapped the status bar

If the finger lifts while the content is already still, there is no momentum phase, so onMomentumScrollBegin never fires. For "the user stopped scrolling", listen to both onScrollEndDrag (when there is no momentum) and onMomentumScrollEnd.

onContentSizeChange is the standard way to scroll to the end of a growing list, such as a chat: onContentSizeChange={() => ref.current?.scrollToEnd({ animated: true })}.

Event order for a drag with and without momentum

The throttle trap

onScroll on iOS fires once per frame only if you set scrollEventThrottle={16}. The default of 0 sends one event when scrolling starts. Android sends events regardless. For a parallax header or a scroll-linked animation, use Animated.event with useNativeDriver: true (see The Animated API) so the event does not need to cross into JavaScript at all.

Instance methods and legacy names

Through a ref, a ScrollView offers scrollTo({ x, y, animated }), scrollToEnd({ animated }), flashScrollIndicators() (iOS) and the escape hatches getScrollResponder() and getScrollableNode(). Older code may call scrollWithoutAnimationTo, which was replaced by scrollTo({ animated: false }). Props such as scrollPerfTag (a profiling label) and endFillColor (an Android colour for the empty area below short content) are legacy and rarely needed today.

Touch handling also has two escape hatches: canCancelContentTouches (iOS) decides whether a drag can cancel a touch that began on a child (for example, a button), and disableScrollViewPanResponder hands the gesture to a child entirely, which matters when you put a custom gesture handler inside.

Advantages and disadvantages

Advantages. It is the simplest way to make content scroll, there is no data array or renderItem to write, and it supports zoom, snapping, sticky headers and pull to refresh. The children can be anything, including different layouts, which makes it ideal for a settings page, a form, an article or an onboarding carousel.

Disadvantages. All children are created and measured at once, so a long list uses memory and slows the first render. There is no item recycling, no virtualization and no built-in separators or empty state. For hundreds of similar rows, use FlatList or FlashList. Nested scroll views in the same direction (a ScrollView inside a ScrollView) confuse both the user and the layout and trigger a warning from FlatList.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A horizontal carousel has cards 260 wide with a 12 gap. What should snapToInterval be?

    Each snap step moves past one card and one gap, so the interval is card width plus gap. Using 260 makes the alignment drift.
  2. 2. Which props turn on pinch zoom for a ScrollView on iOS?

    Zoom activates when the maximum scale is larger than the minimum. pinchGestureEnabled can only block it, and bouncesZoom only affects the limits.
  3. 3. A user drags and lifts their finger while the content is not moving. Which event never fires?

    Without velocity there is no momentum phase, so the momentum events do not fire. That is why 'scrolling stopped' needs both onScrollEndDrag and onMomentumScrollEnd.
  4. 4. Why is onScroll reported only once on iOS unless you set scrollEventThrottle?

    On iOS the native side sends scroll events only as often as scrollEventThrottle allows. 16 gives roughly one per frame.
  5. 5. Which is the main reason not to put 2,000 rows in a ScrollView?

    ScrollView has no virtualization. FlatList renders only what is near the screen.

Summary

  • Group ScrollView props by purpose (feel, zoom, snapping, events) and check the platform: many are iOS-only or Android-only.
  • Snapping: pagingEnabled for whole pages, snapToInterval (card width plus gap) with decelerationRate="fast", or snapToOffsets for uneven items.
  • Zoom works on iOS when maximumZoomScale exceeds minimumZoomScale.
  • A drag emits begin-drag, scroll, end-drag, and then momentum events only if the content keeps moving; detect "stopped" with both end events.
  • Set scrollEventThrottle={16} on iOS, or use Animated.event with the native driver.
  • ScrollView is for a small amount of varied content; use FlatList for long lists.

Next: Text and TextInput in Depth.