You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add horizontal scrolling support to onAdditionalLoading (#67)
## Summary
This PR adds horizontal scrolling support to the `.onAdditionalLoading`
modifier. Previously, the modifier only supported vertical scrolling,
but now it works with both horizontal and vertical scroll axes.
## Changes
- **Added `axis` parameter** to `AdditionalLoading` struct with default
value `.vertical`
- **Refactored `calculate` function** to use generic parameters instead
of Y-specific ones
- **Updated `_Modifier` implementation** to handle both horizontal and
vertical axes using switch statements
- **Added axis parameter to all public APIs**:
- `ScrollView.onAdditionalLoading` (binding and non-binding overloads)
- `List.onAdditionalLoading`
- `CollectionView.onAdditionalLoading` (binding and non-binding
overloads)
- **Added horizontal scrolling preview** demonstrating the new
functionality
- **Updated documentation** to reflect horizontal scrolling support
## Usage Example
### Horizontal scrolling
```swift
ScrollView(.horizontal) {
LazyHStack {
ForEach(items) { item in
ItemView(item: item)
}
}
}
.onAdditionalLoading(
leadingScreens: 1,
axis: .horizontal, // New parameter!
isLoading: $isLoading,
onLoad: {
// Load more items...
}
)
```
### Vertical scrolling (unchanged)
```swift
ScrollView {
LazyVStack {
ForEach(items) { item in
ItemView(item: item)
}
}
}
.onAdditionalLoading(
isLoading: $isLoading, // axis defaults to .vertical
onLoad: {
// Load more items...
}
)
```
## Backward Compatibility
All existing code continues to work without changes since the `axis`
parameter defaults to `.vertical`.
## Test Plan
- [x] All existing tests pass
- [x] Package builds successfully
- [x] Added horizontal scrolling preview for manual testing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments