|
@@ -59,7 +59,7 @@ class TSGennertatorSelectStyleListVc: TSBaseVC {
|
|
|
guard let self = self else { return }
|
|
|
if !datas.isEmpty && viewModel.currentIndexPath.item < datas.count {
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
|
|
- self.styleCollectionView.selectItem(at: self.viewModel.currentIndexPath, animated: true, scrollPosition: .centeredVertically)
|
|
|
+ self.selectIndex(indexPath: self.viewModel.currentIndexPath, dir: .centeredVertically)
|
|
|
}
|
|
|
}
|
|
|
}.store(in: &cancellable)
|
|
@@ -96,7 +96,10 @@ class TSGennertatorSelectStyleListVc: TSBaseVC {
|
|
|
|
|
|
public func selectIndex(indexPath: IndexPath, dir: UICollectionView.ScrollPosition = .centeredHorizontally) {
|
|
|
viewModel.currentIndexPath = indexPath
|
|
|
- DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
|
|
+ if let model = self.viewModel.datas.safeObj(At: indexPath.item) {
|
|
|
+ self.selectedValueBlock?(indexPath, model)
|
|
|
+ }
|
|
|
self.styleCollectionView.selectItem(at: self.viewModel.currentIndexPath, animated: true, scrollPosition: dir)
|
|
|
}
|
|
|
}
|
|
@@ -124,9 +127,6 @@ extension TSGennertatorSelectStyleListVc: UICollectionViewDataSource, UICollecti
|
|
|
}
|
|
|
|
|
|
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
- if let model = viewModel.datas.safeObj(At: indexPath.item) {
|
|
|
- selectIndex(indexPath: indexPath, dir: .centeredVertically)
|
|
|
- selectedValueBlock?(indexPath, model)
|
|
|
- }
|
|
|
+ selectIndex(indexPath: indexPath, dir: .centeredVertically)
|
|
|
}
|
|
|
}
|