Comments (3)
Here is the code I used to test this:
import SwiftUI
import SolidScroll
struct ContentView: View {
let colors: [Color] = [.cyan, .indigo, .gray, .pink, .purple, .teal, .blue, .yellow]
@State var currentPage: Int = 0
let config: PagingViewConfig
init() {
var config = PagingViewConfig()
config.direction = .horizontal
config.size = 100
config.margin = 0
config.spacing = 20
self.config = config
}
var body: some View {
VStack {
PagingView(config: config, page: $currentPage, views: colors.map { color in
Rectangle()
.foregroundColor(color)
.frame(width: 100, height: 60)
})
.frame(height: 80)
Text("Current page: \(currentPage)")
HStack {
Button {
withAnimation(.spring()) {
currentPage = max(0, currentPage - 1)
}
} label: {
Label("Prev", systemImage: "chevron.backward")
}
Button {
withAnimation(.spring()) {
currentPage = min(colors.count - 1, currentPage + 1)
}
} label: {
Label("Next", systemImage: "chevron.forward")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
from solidscroll.
In order to scroll PagingView
with animation, please use the approach with SolidScrollViewProxy.setContentOffset(_:animated:completion:)
which is listed in the example for SolidScrollView
in the README.md. It also works for PagingView
, just retrieve the proxy from the preferences.
from solidscroll.
This solved the issue, thank you. I guess I just didn't read the docs careful enough.
from solidscroll.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solidscroll.