拖拽手势的判定逻辑需要优化
JC-Sung opened this issue · 1 comments
当要弹的view的高度小于屏幕高度一半的时候,拖拽结束时,即使放手时view的位置和拖拽前一样,判定的任然是需要消失。应该在拖拽手势结束时比较的是弹框view离原来的位置拖动了多少比例,即self.maskView.bounds.size.height * self.panDismissRatio这里不应该用maskView的高度去比较
应不应该消失与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;
}