Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Fixes for the two issues I logged #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions KDXCollectionView.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Pod::Spec.new do |s|
s.name = 'KDXCollectionView'
s.version = '0.1.3'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A better collection view for Mac.'
s.homepage = 'https://github.com/lembacon/KDXCollectionView'
s.author = { 'Chongyu Zhu' => '[email protected]' }
s.source = { :git => 'https://github.com/tsfischer/KDXCollectionView.git' }
s.source_files = 'src/*.{h,c,m}'
s.requires_arc = false

s.osx.deployment_target = '10.6'
s.osx.framework = 'Cocoa'
end
18 changes: 15 additions & 3 deletions src/KDXCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ - (void)_delegateUpdateDraggingItemsForDrag:(id <NSDraggingInfo>)draggingInfo;

@implementation KDXCollectionView

// TSF 7/19/2016 Work-around for a nasty bug where visibleCells array is not trustable during a reloadData.
// Ugly, but trying to minimize pod code changes.
static BOOL doingPreReloadData = false;

#pragma mark - Synthesizing Properties

@synthesize dataSource = _dataSource;
Expand Down Expand Up @@ -448,11 +452,13 @@ - (void)deselectAllItems

- (void)_preReloadData
{
doingPreReloadData = true;
[_selectedIndexes removeAllIndexes];
_hoveringIndex = NSNotFound;

_numberOfItems = [self _dataSourceNumberOfItems];
[self _updateFrame];
doingPreReloadData = false;
}

- (void)_postReloadData
Expand Down Expand Up @@ -659,6 +665,7 @@ - (void)_fixLayoutAfterMoving
_flags.shouldAnimateCellFrameChanging = YES;

[self _updateFramesOfCells];
[self _addVisibleCells];

_flags.shouldAnimateCellFrameChanging = oldShouldAnimateCellFrameChanging;
}
Expand Down Expand Up @@ -754,6 +761,7 @@ - (void)_fixLayoutAfterInsertion
[self _updateFrame];
[self _updateFramesOfCells];
[self _removeInvisibleCells];
[self _addVisibleCells];

_flags.shouldAnimateCellFrameChanging = oldShouldAnimateCellFrameChanging;
}
Expand Down Expand Up @@ -964,7 +972,9 @@ - (void)drawRect:(NSRect)dirtyRect
- (void)setFrame:(NSRect)frameRect
{
[super setFrame:frameRect];
[self _layout];
if (!doingPreReloadData) {
[self _layout];
}

if ([self inLiveResize]) {
[self setNeedsDisplay:YES];
Expand Down Expand Up @@ -2080,11 +2090,13 @@ - (BOOL)acceptsFirstResponder

- (NSView *)hitTest:(NSPoint)aPoint
{
if (NSMouseInRect(aPoint, [self visibleRect], [self isFlipped])) {
NSView *hitView = [super hitTest:aPoint];

if (!hitView && NSMouseInRect(aPoint, [self visibleRect], [self isFlipped])) {
return self;
}

return nil;
return hitView;
}

- (void)_clearTrackingArea
Expand Down