Skip to content

Commit

Permalink
Merge pull request #2202 from cxfeng1/ios-feature-20170118
Browse files Browse the repository at this point in the history
* [ios] fix bug that horizontalpan and verticalpan can not trigger si…
  • Loading branch information
cxfeng1 committed Jan 10, 2017
2 parents 72544be + eb03cb0 commit 4f65b4d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
Expand Up @@ -440,22 +440,35 @@ - (void)onPan:(UIPanGestureRecognizer *)gesture
NSDictionary *resultTouch = [self touchResultWithScreenLocation:screenLocation pageLocation:pageLoacation identifier:gesture.wx_identifier];

if (gesture.state == UIGestureRecognizerStateBegan) {
eventName = @"panstart";
if (_listenPanStart) {
eventName = @"panstart";
}
state = @"start";
} else if (gesture.state == UIGestureRecognizerStateEnded) {
eventName = @"panend";
if (_listenPanEnd) {
eventName = @"panend";
}
state = @"end";
gesture.wx_identifier = nil;
} else if (gesture.state == UIGestureRecognizerStateChanged) {
eventName = @"panmove";
if (_listenPanMove) {
eventName = @"panmove";
}
state = @"move";
}

if (_listenHorizontalPan) {

CGPoint translation = [_panGesture translationInView:self.view];

if (_listenHorizontalPan && fabs(translation.y) <= fabs(translation.x)) {
[self fireEvent:@"horizontalpan" params:@{@"state":state, @"changedTouches":resultTouch ? @[resultTouch] : @[]}];
} else if (_listenVerticalPan) {
}

if (_listenVerticalPan && fabs(translation.y) > fabs(translation.x)) {
[self fireEvent:@"verticalpan" params:@{@"state":state, @"changedTouches":resultTouch ? @[resultTouch] : @[]}];
} else if (eventName) {
}

if (eventName) {
[self fireEvent:eventName params:@{@"changedTouches":resultTouch ? @[resultTouch] : @[]}];
}
}
Expand Down

0 comments on commit 4f65b4d

Please sign in to comment.