bugfix: slider need scroll logic
This commit is contained in:
parent
d405f60c7f
commit
4cfb7b4076
@ -173,7 +173,8 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
||||
mView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mView.scrollToPosition(1);
|
||||
int position = slideAdapter.loop ? 1 : 0;
|
||||
mView.scrollToPosition(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -37,11 +37,12 @@ @interface DoricSliderNode () <UICollectionViewDataSource, UICollectionViewDeleg
|
||||
@property(nonatomic, assign) NSUInteger propItemCount;
|
||||
@property(nonatomic, assign) NSUInteger batchCount;
|
||||
@property(nonatomic, copy) NSString *onPageSelectedFuncId;
|
||||
@property(nonatomic) BOOL loop;
|
||||
@property(nonatomic) BOOL propLoop;
|
||||
@property(nonatomic, assign) BOOL loop;
|
||||
@property(nonatomic, assign) BOOL propLoop;
|
||||
@property(nonatomic, assign) NSUInteger lastPosition;
|
||||
@property(nonatomic, copy) NSString *renderPageFuncId;
|
||||
@property(nonatomic, copy) NSString *propRenderPageFuncId;
|
||||
@property(nonatomic, assign) BOOL needResetScroll;
|
||||
@end
|
||||
|
||||
@interface DoricSliderView : UICollectionView
|
||||
@ -101,7 +102,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
|
||||
- (void)afterBlended:(NSDictionary *)props {
|
||||
bool needToScroll = (self.propLoop && !self.loop)
|
||||
|| (![self.renderPageFuncId isEqualToString:self.propRenderPageFuncId])
|
||||
|| (self.itemCount == 0 && self.propItemCount > 0);
|
||||
|| (self.itemCount == 0 && self.propItemCount > 0)
|
||||
|| self.needResetScroll;
|
||||
|
||||
// handle item count
|
||||
if (self.itemCount != self.propItemCount) {
|
||||
@ -122,13 +124,21 @@ - (void)afterBlended:(NSDictionary *)props {
|
||||
// handle loop
|
||||
self.loop = self.propLoop;
|
||||
|
||||
|
||||
__weak typeof(self) _self = self;
|
||||
if (needToScroll) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__strong typeof(_self) self = _self;
|
||||
|
||||
[self.view reloadData];
|
||||
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false];
|
||||
|
||||
int position = self.loop ? 1 : 0;
|
||||
if (self.view.width == 0) {
|
||||
self.needResetScroll = true;
|
||||
} else {
|
||||
self.needResetScroll = false;
|
||||
[self.view setContentOffset:CGPointMake(position * self.view.width, self.view.contentOffset.y) animated:false];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user