Skip to content

Commit

Permalink
Merge pull request #181 from dwabyick/master
Browse files Browse the repository at this point in the history
fixed scroll layout in 10.12
  • Loading branch information
jwilling authored Sep 3, 2016
2 parents d4092aa + 0007a74 commit c1d9769
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions JNWCollectionView/JNWCollectionViewFramework.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#import "JNWCollectionViewLayout.h"
#import "JNWCollectionViewLayout+Private.h"

#ifndef NSAppKitVersionNumber10_11
#define NSAppKitVersionNumber10_11 1404
#endif

typedef NS_ENUM(NSInteger, JNWCollectionViewSelectionType) {
JNWCollectionViewSelectionTypeSingle,
JNWCollectionViewSelectionTypeExtending,
Expand Down Expand Up @@ -639,6 +643,17 @@ - (void)layout {
}
}

- (void)reflectScrolledClipView:(NSClipView*)clipView {
[super reflectScrolledClipView:clipView];

// 10.12 started optimizing the layout pass and reducing the number of calls to layout(). As
// such, invalidate our layout when the scroll changes on 10.12 and above.
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_11) {
// Invalidate our layout when we our scrolled. This is required for 10.12 and above.
self.needsLayout = YES;
}
}

- (void)collectionViewLayoutWasInvalidated:(JNWCollectionViewLayout *)layout {
// First we prepare the layout. In the future it would possibly be a good idea to coalesce
// this call to reduce unnecessary layout preparation calls.
Expand Down

0 comments on commit c1d9769

Please sign in to comment.