Skip to content

Commit

Permalink
add autoClearGestures feature
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonXi committed Mar 12, 2018
1 parent 8dfca94 commit 36ade84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions LazyScrollView/TMLazyScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@
If it is YES, LazyScrollView will add created item view into
its subviews automatically.
Default value is NO.
Please only set this value before you reload data for the first time.
*/
@property (nonatomic, assign) BOOL autoAddSubview;

/**
If it is YES, LazyScrollView will clear all gestures for item view before
reusing it.
Default value is YES.
*/
@property (nonatomic, assign) BOOL autoClearGestures;

/**
Item views which is in the buffer area.
They will be shown soon.
Expand Down
6 changes: 4 additions & 2 deletions LazyScrollView/TMLazyScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#import "UIView+TMLazyScrollView.h"
#import "TMLazyReusePool.h"

#define LazyBufferHeight 20.0
#define LazyHalfBufferHeight (LazyBufferHeight / 2.0)
#define LazyBufferHeight 30.0
#define LazyHalfBufferHeight 15.0
void * const LazyObserverContext = "LazyObserverContext";

@interface TMLazyOuterScrollViewObserver: NSObject
Expand Down Expand Up @@ -469,7 +469,9 @@ - (UIView *)dequeueReusableItemWithIdentifier:(NSString *)identifier muiID:(NSSt
result = [self.reusePool dequeueItemViewForReuseIdentifier:identifier];
}
if (result) {
if (self.autoClearGestures) {
result.gestureRecognizers = nil;
}
if ([result respondsToSelector:@selector(mui_prepareForReuse)]) {
[(id<TMLazyItemViewProtocol>)result mui_prepareForReuse];
}
Expand Down

0 comments on commit 36ade84

Please sign in to comment.