Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

拖拽手势的判定逻辑需要优化 #56

Open
Lovezysong opened this issue Oct 26, 2020 · 1 comment
Open

拖拽手势的判定逻辑需要优化 #56

Lovezysong opened this issue Oct 26, 2020 · 1 comment

Comments

@Lovezysong
Copy link

当要弹的view的高度小于屏幕高度一半的时候,拖拽结束时,即使放手时view的位置和拖拽前一样,判定的任然是需要消失。应该在拖拽手势结束时比较的是弹框view离原来的位置拖动了多少比例,即self.maskView.bounds.size.height * self.panDismissRatio这里不应该用maskView的高度去比较

@Lovezysong
Copy link
Author

应不应该消失与maskView是没关系,要看弹框view相比于自己原来的位置移动的比例,我是这样写的
BOOL isDismissNeeded = NO;
switch (self.layoutType) {
case zhPopupLayoutTypeTop: {
isDismissNeeded =
- self.view.frame.origin.y > self.view.frame.size.height * self.panDismissRatio;
} break;
case zhPopupLayoutTypeLeft: {
isDismissNeeded = - self.view.frame.origin.x > self.view.bounds.size.width * self.panDismissRatio;
} break;
case zhPopupLayoutTypeBottom: {
isDismissNeeded =
(self.maskView.bounds.size.height - self.view.frame.origin.y) < self.view.frame.size.height * (1 - self.panDismissRatio);
} break;
case zhPopupLayoutTypeRight: {
isDismissNeeded = (self.maskView.bounds.size.width - self.view.frame.origin.x) < self.view.frame.size.width * (1 - self.panDismissRatio);
;
} break;
case zhPopupLayoutTypeCenter: {
if (_directionalVertical) {
isDismissNeeded = CGRectGetMinY(g.view.frame) > self.maskView.bounds.size.height * self.panDismissRatio;
[self directionalUnlock];
}
} break;
default: break;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant