<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2" -->

---
title: Scroll-driven effects in SwiftUI: phases, geometry and...
description: SwiftUI offers four distinct APIs for tying visual effects and interface updates to scroll position, each suited to a different job. scrollTransition() and...
canonical: https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Scroll-driven effects in SwiftUI: phases, geometry and scroll state | daily.dev
og:description: SwiftUI offers four distinct APIs for tying visual effects and interface updates to scroll position, each suited to a different job. scrollTransition() and...
og:url: https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2
og:image: https://api.daily.dev/og/posts/TAOGLv3y2.png
og:image:alt: Scroll-driven effects in SwiftUI: phases, geometry and scroll state
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Scroll-driven effects in SwiftUI: phases, geometry and scroll state

**[Nil Coalescing](https://daily.dev/sources/nilcoalescing)** · 8 min read · 0 upvotes · 0 comments

## Summary

SwiftUI offers four distinct APIs for tying visual effects and interface updates to scroll position, each suited to a different job. scrollTransition() and visualEffect() change only the attached view and don't trigger layout updates, using phases like topLeading, bottomTrailing and identity or a GeometryProxy for continuous effects like parallax. onScrollGeometryChange() derives state from scroll geometry (offset, content size, insets) to drive other parts of the UI, while onScrollVisibilityChange() fires a Boolean when a view crosses a visibility threshold, defaulting to 0.5. The guidance: pick the narrowest API that covers the effect, since it does the least work during scrolling.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nilcoalescing.com/blog/ScrollDrivenEffectsInSwiftUI>

## Questions this post answers

### What's the difference between scrollTransition and visualEffect in SwiftUI for scroll animations?

scrollTransition() applies effects based on discrete phases (topLeading, identity, bottomTrailing) as a view enters or leaves the visible scroll region, while visualEffect() uses a GeometryProxy to produce effects that vary continuously with the view's exact position, such as a parallax offset calculated from frame(in: .scrollView) and bounds(of: .scrollView). Both only affect the attached view and don't change layout.

_Developers fine-tuning scroll animations can compare SwiftUI scroll APIs side by side on daily.dev._

### How do I show visible photo index state in SwiftUI based on horizontal scroll position?

Use onScrollGeometryChange(for:of:action:) with an Int type, transforming geometry.contentOffset.x divided by a card stride into a clamped index, then updating @State in the action closure with withAnimation. The action only re-runs when the derived Equatable value changes, so reducing the geometry to the smallest needed value, like an index or Boolean, limits how often dependent views update.

_Developers wiring scroll position to UI state can find patterns like this through daily.dev._

### What does onScrollVisibilityChange threshold parameter do in SwiftUI?

The threshold parameter sets the fraction of a view that must be within the visible scroll region for it to count as visible, defaulting to 0.5. Passing 0.9, for example, counts a photo as visible only when it's almost entirely shown, leaving partially visible photos at the edges unaffected. The action also fires on first appearance if the threshold is already met, so visibility-dependent state initializes correctly.

_Developers tuning visibility-triggered animations can track SwiftUI API details like this via daily.dev._

## Similar posts on daily.dev

- [Responding to geometry changes in SwiftUI](https://daily.dev/posts/responding-to-geometry-changes-in-swiftui-hosixtvxh) · Nil Coalescing · 1 upvotes · 0 comments
- [Attempting BookMyShow’s Rating Animation](https://daily.dev/posts/attempting-bookmyshow-s-rating-animation-3fpkfvalh) · Medium · 0 upvotes · 0 comments
- [Creating multi-step animations with PhaseAnimator in SwiftUI](https://daily.dev/posts/creating-multi-step-animations-with-phaseanimator-in-swiftui-xazmyyxwq) · Nil Coalescing · 0 upvotes · 0 comments

---

Tags: [#ios](https://daily.dev/tags/ios), [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Scroll-driven effects in SwiftUI: phases, geometry and scroll state","url":"https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2"},"datePublished":"2026-11-19T08:20:15.781Z","dateModified":"2026-11-19T08:20:43.052Z","description":"SwiftUI offers four distinct APIs for tying visual effects and interface updates to scroll position, each suited to a different job. scrollTransition() and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/948b189f6f7f92e9432415a6265b1e9b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/948b189f6f7f92e9432415a6265b1e9b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nil Coalescing","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nil Coalescing","logo":"https://media.daily.dev/image/upload/s--rcEu6sag--/f_auto,q_auto/v1785654899/logos/nilcoalescing?_a=BAMAMicg0","url":"https://daily.dev/sources/nilcoalescing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ios,swift,swiftui","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nil Coalescing","item":"https://daily.dev/sources/nilcoalescing"},{"@type":"ListItem","position":3,"name":"Scroll-driven effects in SwiftUI: phases, geometry and scroll state"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/scroll-driven-effects-in-swiftui-phases-geometry-and-scroll-state-taoglv3y2#faq","mainEntity":[{"@type":"Question","name":"What's the difference between scrollTransition and visualEffect in SwiftUI for scroll animations?","acceptedAnswer":{"@type":"Answer","text":"scrollTransition() applies effects based on discrete phases (topLeading, identity, bottomTrailing) as a view enters or leaves the visible scroll region, while visualEffect() uses a GeometryProxy to produce effects that vary continuously with the view's exact position, such as a parallax offset calculated from frame(in: .scrollView) and bounds(of: .scrollView). Both only affect the attached view and don't change layout. Developers fine-tuning scroll animations can compare SwiftUI scroll APIs side by side on daily.dev."}},{"@type":"Question","name":"How do I show visible photo index state in SwiftUI based on horizontal scroll position?","acceptedAnswer":{"@type":"Answer","text":"Use onScrollGeometryChange(for:of:action:) with an Int type, transforming geometry.contentOffset.x divided by a card stride into a clamped index, then updating @State in the action closure with withAnimation. The action only re-runs when the derived Equatable value changes, so reducing the geometry to the smallest needed value, like an index or Boolean, limits how often dependent views update. Developers wiring scroll position to UI state can find patterns like this through daily.dev."}},{"@type":"Question","name":"What does onScrollVisibilityChange threshold parameter do in SwiftUI?","acceptedAnswer":{"@type":"Answer","text":"The threshold parameter sets the fraction of a view that must be within the visible scroll region for it to count as visible, defaulting to 0.5. Passing 0.9, for example, counts a photo as visible only when it's almost entirely shown, leaving partially visible photos at the edges unaffected. The action also fires on first appearance if the threshold is already met, so visibility-dependent state initializes correctly. Developers tuning visibility-triggered animations can track SwiftUI API details like this via daily.dev."}}]}
```

