Skip to content

Commit

Permalink
disables prefetchEnabled by default
Browse files Browse the repository at this point in the history
Summary:
Disables `prefetchEnabled` by default on `IGListCollectionView` (#318).

- [x] All tests pass. Demo project builds and runs.
- [x] I added tests, an experiment, or detailed why my change isn't tested.
- [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md)
Closes #323

Differential Revision: D4319761

Pulled By: rnystrom

fbshipit-source-id: a3ea4c3d1d1f3123a60c8168fb333e73ab93cb1e
  • Loading branch information
svenbacia authored and Facebook Github Bot committed Dec 13, 2016
1 parent 626d268 commit fb9d8ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag

This release closes the [2.1.0 milestone](https://github.com/Instagram/IGListKit/milestone/2).

### Enhancements
- Disables `prefetchEnabled` by default on `IGListCollectionView`. [Sven Bacia (#323)](https://github.com/Instagram/IGListKit/pull/323)

2.0.0
-----

Expand Down
13 changes: 13 additions & 0 deletions Source/IGListCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,24 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
self.backgroundColor = [UIColor whiteColor];
}

if ([self respondsToSelector:@selector(setPrefetchingEnabled:)]) {
self.prefetchingEnabled = NO;
}

self.alwaysBounceVertical = YES;
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super initWithCoder:aDecoder]) {
if ([self respondsToSelector:@selector(setPrefetchingEnabled:)]) {
self.prefetchingEnabled = NO;
}
}
return self;
}

- (void)layoutSubviews {
/**
UICollectionView will sometimes lay its cells out with an animation. This is especially noticeable on older devices
Expand Down
18 changes: 18 additions & 0 deletions Tests/IGListCollectionViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ -(void)test_thatIGListCollectionViewHasCorrectDefaults {
IGListCollectionView *collectionView = [[IGListCollectionView alloc] initWithFrame: kIGListCollectionViewTestFrame collectionViewLayout:[UICollectionViewFlowLayout new]];

XCTAssertTrue(collectionView.alwaysBounceVertical);

if ([collectionView respondsToSelector:@selector(isPrefetchingEnabled)]) {
XCTAssertFalse(collectionView.isPrefetchingEnabled);
}
}

-(void)test_thatStoryboardIGListCollectionViewHasCorrectDefaults {
UIWindow *window = [[UIWindow alloc] initWithFrame:kIGListCollectionViewTestFrame];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"IGTestStoryboard" bundle:[NSBundle bundleForClass:self.class]];
IGTestStoryboardViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"testVC"];
[window addSubview:viewController.view];
[viewController performSelectorOnMainThread:@selector(loadView) withObject:nil waitUntilDone:YES];

XCTAssertFalse(viewController.collectionView.alwaysBounceVertical);

if ([UICollectionView instancesRespondToSelector:@selector(isPrefetchingEnabled)]) {
XCTAssertFalse(viewController.collectionView.isPrefetchingEnabled);
}
}

-(void)test_whenUsingUIAppearance_thatStoryboardIGListCollectionViewUsesAppearanceBackgroundColor {
Expand Down

0 comments on commit fb9d8ce

Please sign in to comment.