对CRToast 重力效果略有不满——2018-01-11

//#import "CRToastConfig.m" #770

- (CGPoint)inCollisionPoint1 {
    CGFloat x;
    CGFloat y;
    CGFloat factor = self.presentationType == CRToastPresentationTypeCover ?: 2;
    BOOL push = self.presentationType == CRToastPresentationTypePush;
    switch (self.inAnimationDirection) {
        case CRToastAnimationDirectionTop:
            x = 0;
            //y = factor*(CGRectGetHeight(self.notificationViewAnimationFrame1)+(push ? -4*kCRCollisionTweak : kCRCollisionTweak));
            y = factor*(CGRectGetHeight(self.notificationViewAnimationFrame1)+(push ? 0 : 0));
            break;
        case CRToastAnimationDirectionLeft:
            //x = (factor*CGRectGetWidth(self.notificationViewAnimationFrame1))+(push ? -5*kCRCollisionTweak : 2*kCRCollisionTweak);
            x = (factor*CGRectGetWidth(self.notificationViewAnimationFrame1))+(push ? 0 : 3*kCRCollisionTweak);
            y = CGRectGetHeight(self.notificationViewAnimationFrame1);
            break;
        case CRToastAnimationDirectionBottom:
            x = CGRectGetWidth(self.notificationViewAnimationFrame1);
            //y = -((factor-1)*CGRectGetHeight(self.notificationViewAnimationFrame1))-(push ? -5*kCRCollisionTweak : kCRCollisionTweak);;
            y = -((factor-1)*CGRectGetHeight(self.notificationViewAnimationFrame1))-(push ? 0 : 2*kCRCollisionTweak);
            break;
        case CRToastAnimationDirectionRight:
            //x = -((factor-1)*CGRectGetWidth(self.notificationViewAnimationFrame1))-(push ? -5*kCRCollisionTweak : 2*kCRCollisionTweak);;
            x = -((factor-1)*CGRectGetWidth(self.notificationViewAnimationFrame1))-(push ? 0 : 3*kCRCollisionTweak);
            y = 0;
            break;
    }
    return CGPointMake(x, y);
}

- (CGPoint)inCollisionPoint2 {
    CGFloat x;
    CGFloat y;
    CGFloat factor = self.presentationType == CRToastPresentationTypeCover ?: 2;
    BOOL push = self.presentationType == CRToastPresentationTypePush;
    switch (self.inAnimationDirection) {
        case CRToastAnimationDirectionTop:
            x = CGRectGetWidth(self.notificationViewAnimationFrame1);
            //y = factor*(CGRectGetHeight(self.notificationViewAnimationFrame1)+(push ? -4*kCRCollisionTweak : kCRCollisionTweak));
            y = factor*(CGRectGetHeight(self.notificationViewAnimationFrame1)+(push ? 0 : 0));
            break;
        case CRToastAnimationDirectionLeft:
            //x = (factor*CGRectGetWidth(self.notificationViewAnimationFrame1))+(push ? -5*kCRCollisionTweak : 2*kCRCollisionTweak);
            x = (factor*CGRectGetWidth(self.notificationViewAnimationFrame1))+(push ? 0 : 3*kCRCollisionTweak);
            y = 0;
            break;
        case CRToastAnimationDirectionBottom:
            x = 0;
            //y = -((factor-1)*CGRectGetHeight(self.notificationViewAnimationFrame1))-(push ? -5*kCRCollisionTweak : kCRCollisionTweak);
            y = -((factor-1)*CGRectGetHeight(self.notificationViewAnimationFrame1))-(push ? 0 : 2*kCRCollisionTweak);
            break;
        case CRToastAnimationDirectionRight:
            //x = -((factor-1)*CGRectGetWidth(self.notificationViewAnimationFrame1))-(push ? -5*kCRCollisionTweak : 2*kCRCollisionTweak);
            x = -((factor-1)*CGRectGetWidth(self.notificationViewAnimationFrame1))-(push ? 0 : 3*kCRCollisionTweak);
            y = CGRectGetHeight(self.notificationViewAnimationFrame1);
            break;
    }
    return CGPointMake(x, y);
}

你可能感兴趣的:(对CRToast 重力效果略有不满——2018-01-11)