|
@@ -684,17 +684,44 @@ NSString * const ID = @"SDCycleScrollViewCell";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)makeScrollViewScrollToIndex:(NSInteger)index{
|
|
|
+//- (void)makeScrollViewScrollToIndex:(NSInteger)index{
|
|
|
+// if (self.autoScroll) {
|
|
|
+// [self invalidateTimer];
|
|
|
+// }
|
|
|
+// if (0 == _totalItemsCount) return;
|
|
|
+//
|
|
|
+// [self scrollToIndex:(int)(_totalItemsCount * 0.5 + index)];
|
|
|
+//
|
|
|
+// if (self.autoScroll) {
|
|
|
+// [self setupTimer];
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
+//hxd add 20240516 by https://github.com/gsdios/SDCycleScrollView/issues/645
|
|
|
+-(void)makeScrollViewScrollToIndex:(NSInteger)index {
|
|
|
if (self.autoScroll) {
|
|
|
- [self invalidateTimer];
|
|
|
+ [self invalidateTimer];
|
|
|
}
|
|
|
if (0 == _totalItemsCount) return;
|
|
|
-
|
|
|
- [self scrollToIndex:(int)(_totalItemsCount * 0.5 + index)];
|
|
|
-
|
|
|
+
|
|
|
+ [self makeScrollToIndex:index];
|
|
|
+
|
|
|
if (self.autoScroll) {
|
|
|
[self setupTimer];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+-(void)makeScrollToIndex:(NSInteger)targetIndex {
|
|
|
+ if (self.infiniteLoop) {
|
|
|
+ targetIndex = targetIndex%(_totalItemsCount/100);
|
|
|
+ targetIndex = _totalItemsCount * 0.5 + targetIndex;
|
|
|
+ if (targetIndex < [self currentIndex]) {
|
|
|
+ [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:(_totalItemsCount * 0.5 -1) inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
+ }
|
|
|
+ }else if (targetIndex >= _totalItemsCount){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
+}
|
|
|
+
|
|
|
@end
|