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() {
|
mView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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 propItemCount;
|
||||||
@property(nonatomic, assign) NSUInteger batchCount;
|
@property(nonatomic, assign) NSUInteger batchCount;
|
||||||
@property(nonatomic, copy) NSString *onPageSelectedFuncId;
|
@property(nonatomic, copy) NSString *onPageSelectedFuncId;
|
||||||
@property(nonatomic) BOOL loop;
|
@property(nonatomic, assign) BOOL loop;
|
||||||
@property(nonatomic) BOOL propLoop;
|
@property(nonatomic, assign) BOOL propLoop;
|
||||||
@property(nonatomic, assign) NSUInteger lastPosition;
|
@property(nonatomic, assign) NSUInteger lastPosition;
|
||||||
@property(nonatomic, copy) NSString *renderPageFuncId;
|
@property(nonatomic, copy) NSString *renderPageFuncId;
|
||||||
@property(nonatomic, copy) NSString *propRenderPageFuncId;
|
@property(nonatomic, copy) NSString *propRenderPageFuncId;
|
||||||
|
@property(nonatomic, assign) BOOL needResetScroll;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface DoricSliderView : UICollectionView
|
@interface DoricSliderView : UICollectionView
|
||||||
@ -101,7 +102,8 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
|
|||||||
- (void)afterBlended:(NSDictionary *)props {
|
- (void)afterBlended:(NSDictionary *)props {
|
||||||
bool needToScroll = (self.propLoop && !self.loop)
|
bool needToScroll = (self.propLoop && !self.loop)
|
||||||
|| (![self.renderPageFuncId isEqualToString:self.propRenderPageFuncId])
|
|| (![self.renderPageFuncId isEqualToString:self.propRenderPageFuncId])
|
||||||
|| (self.itemCount == 0 && self.propItemCount > 0);
|
|| (self.itemCount == 0 && self.propItemCount > 0)
|
||||||
|
|| self.needResetScroll;
|
||||||
|
|
||||||
// handle item count
|
// handle item count
|
||||||
if (self.itemCount != self.propItemCount) {
|
if (self.itemCount != self.propItemCount) {
|
||||||
@ -121,6 +123,7 @@ - (void)afterBlended:(NSDictionary *)props {
|
|||||||
|
|
||||||
// handle loop
|
// handle loop
|
||||||
self.loop = self.propLoop;
|
self.loop = self.propLoop;
|
||||||
|
|
||||||
|
|
||||||
__weak typeof(self) _self = self;
|
__weak typeof(self) _self = self;
|
||||||
if (needToScroll) {
|
if (needToScroll) {
|
||||||
@ -128,7 +131,14 @@ - (void)afterBlended:(NSDictionary *)props {
|
|||||||
__strong typeof(_self) self = _self;
|
__strong typeof(_self) self = _self;
|
||||||
|
|
||||||
[self.view reloadData];
|
[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