Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

手指慢慢拖动切换 listDidAppear不会执行 #213

Closed
zhangtong99 opened this issue Aug 29, 2022 · 4 comments
Closed

手指慢慢拖动切换 listDidAppear不会执行 #213

zhangtong99 opened this issue Aug 29, 2022 · 4 comments

Comments

@zhangtong99
Copy link

No description provided.

@thomashooo
Copy link

thomashooo commented Nov 8, 2022

我被这个坑了几天了,不知道是不是类似问题,主要就是滑动切换,没有进行
去更新JXPagingListContainerView.swift中,didClickSelectedItem操作(点击和代码切换都有):

public func didClickSelectedItem(at index: Int) {
    guard checkIndexValid(index) else {
        return
    }
    willAppearIndex = -1
    willDisappearIndex = -1
    if currentIndex != index {
        listWillDisappear(at: currentIndex)
        listWillAppear(at: index)
        listDidDisappear(at: currentIndex)
        listDidAppear(at: index)
    }
}

问题代码:

JXSegmentedView.swift中:
if index == selectedIndex {
if selectedType == .code {
listContainer?.didClickSelectedItem(at: index)
}else if selectedType == .click {
delegate?.segmentedView(self, didClickSelectedItemAt: index)
listContainer?.didClickSelectedItem(at: index)
}else if selectedType == .scroll {
delegate?.segmentedView(self, didScrollSelectedItemAt: index)
//这里拖动缺少:listContainer?.didClickSelectedItem的操作,为什么呢?我是加上就好了。不改源码的话,可以在上面方法外调用一下:listContainer?.didClickSelectedItem
//我的场景是每次会更新listContainer的高度,因为底部内容过少主Cell就不必要那么高垂直滚动。
}
delegate?.segmentedView(self, didSelectedItemAt: index)
scrollingTargetIndex = -1
return
}

可以外部实现delegate修一下:
func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
//修正滑动切换,内部不更新listContainer内索引?导致混乱
segmentedView.listContainer?.didClickSelectedItem(at: index)
}

@thomashooo
Copy link

持续研究了一下,最终导致问题的是
scrollViewDidScroll中调用listDidAppearOrDisappear方法无法触发为,下一页。落到scrollViewDidEndDecelerating去执行了取消滑动了。。。

@thomashooo
Copy link

参考这个解决:#204
添加:scrollView.isDecelerating 状态检测。

@pujiaxin33
Copy link
Owner

已修复,via #201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants