Skip to content

Commit

Permalink
fix bug:#27
Browse files Browse the repository at this point in the history
  • Loading branch information
TalkingJourney committed Jun 24, 2019
1 parent 9241104 commit 4615a17
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions SCIndexView/SCIndexView.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ - (CAShapeLayer *)createSearchLayer

- (void)showIndicator:(BOOL)animated
{
if (!self.indicator.hidden || self.currentSection < 0 || self.currentSection >= (NSInteger)self.subTextLayers.count) return;
if (self.currentSection < 0 || self.currentSection >= (NSInteger)self.subTextLayers.count) return;

CATextLayer *textLayer = self.subTextLayers[self.currentSection];
if (self.configuration.indexViewStyle == SCIndexViewStyleDefault) {
Expand Down Expand Up @@ -369,7 +369,6 @@ - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event

NSInteger deta = self.searchLayer ? 1 : 0;
NSInteger currentSection = currentPosition - deta;
[self hideIndicator:NO];
self.currentSection = currentSection;
[self showIndicator:YES];
[self onActionWithDidSelect];
Expand All @@ -395,7 +394,6 @@ - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
NSInteger currentSection = currentPosition - deta;
if (currentSection == self.currentSection) return YES;

[self hideIndicator:NO];
self.currentSection = currentSection;
[self showIndicator:NO];
[self onActionWithDidSelect];
Expand All @@ -408,12 +406,22 @@ - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
self.touchingIndexView = NO;
NSInteger oldCurrentPosition = self.currentSection;
[self refreshCurrentSection];
if (oldCurrentPosition != self.currentSection) {
[self showIndicator:NO];
}
[self hideIndicator:YES];
}

- (void)cancelTrackingWithEvent:(UIEvent *)event
{
self.touchingIndexView = NO;
NSInteger oldCurrentPosition = self.currentSection;
[self refreshCurrentSection];
if (oldCurrentPosition != self.currentSection) {
[self showIndicator:NO];
}
[self hideIndicator:YES];
}

Expand Down

0 comments on commit 4615a17

Please sign in to comment.