PositionScrollView icon indicating copy to clipboard operation
PositionScrollView copied to clipboard

moveToPage not working on iOS 14.3

Open dauerr opened this issue 5 years ago • 1 comments

My code:

var pageSize = CGSize(width: 200, height: 300)

    @ObservedObject var psViewModel = PositionScrollViewModel(
            pageSize: CGSize(width: 200, height: 300),
            horizontalScroll: Scroll(
                scrollSetting: ScrollSetting(pageCount: 3, afterMoveType: .fitToNearestUnit),
                pageLength: 200
            )
        )

    var body: some View {
        VStack {
            PositionScrollView(viewModel: self.psViewModel, delegate: self) {
                HStack(spacing: 0) {
                    ForEach(content, id: \.self) { c in
                        Preview(content: c)
                            .frame(width: self.pageSize.width, height: self.pageSize.height)
                        }
                }
            }
            Text("page: \(self.psViewModel.horizontalScroll?.page ?? 0)")
            Text("position: \(self.psViewModel.horizontalScroll?.position ?? 0)")
            HStack {
                roundedButton(text: "Show Previous",
                              onClick: {
                                print("FEATURE NOT IMPLEMENTED")
                              },
                              withArrow: true,
                              arrowRight: false)
                roundedButton(text: "Show Next",
                              onClick: {
                                self.psViewModel.horizontalScroll?.moveToPage(page: self.psViewModel.horizontalScroll!.page + 1)
                              },
                              withArrow: true)
            }
        }
    }

Logs (when 'Show Next' is clicked):

position: 0.0
onChangePage to page: 1

Observed behavior: Nothing happens

dauerr avatar Dec 23 '20 12:12 dauerr

me too self.psViewModel.horizontalScroll?.moveToPage not working

Junyi1227 avatar May 19 '21 02:05 Junyi1227