Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit e3b8aa8

Browse files
committed
Disable refresh animation on initial load.
1 parent e6c13a5 commit e3b8aa8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Pod/Classes/WPMediaPickerViewController.m

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ - (void)viewDidLoad
102102
[self.view addGestureRecognizer:self.longPressGestureRecognizer];
103103
}
104104

105-
[self refreshData];
105+
[self refreshDataAnimated:NO];
106106
}
107107

108108
- (void)setupLayout
@@ -182,11 +182,16 @@ -(NSArray *)indexPathsFromIndexSet:(NSIndexSet *)indexSet section:(NSInteger)sec
182182
}
183183

184184
- (void)refreshData
185+
{
186+
[self refreshDataAnimated:YES];
187+
}
188+
189+
- (void)refreshDataAnimated:(BOOL)animated
185190
{
186191
if (self.refreshGroupFirstTime) {
187192
if (![self.refreshControl isRefreshing]) {
188193
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length]) animated:NO];
189-
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length] - (self.refreshControl.frame.size.height)) animated:YES];
194+
[self.collectionView setContentOffset:CGPointMake(0, - [[self topLayoutGuide] length] - (self.refreshControl.frame.size.height)) animated:animated];
190195
[self.refreshControl beginRefreshing];
191196
}
192197
// NOTE: Sergio Estevao (2015-11-19)
@@ -208,7 +213,15 @@ - (void)refreshData
208213
strongSelf.collectionView.allowsMultipleSelection = self.allowMultipleSelection;
209214
strongSelf.collectionView.scrollEnabled = YES;
210215
[strongSelf.collectionView reloadData];
211-
[strongSelf.refreshControl endRefreshing];
216+
217+
if (animated) {
218+
[strongSelf.refreshControl endRefreshing];
219+
} else {
220+
[UIView performWithoutAnimation:^{
221+
[strongSelf.refreshControl endRefreshing];
222+
}];
223+
}
224+
212225
// Scroll to the correct position
213226
if (strongSelf.refreshGroupFirstTime && [strongSelf.dataSource numberOfAssets] > 0){
214227
NSInteger sectionToScroll = 0;

0 commit comments

Comments
 (0)