Merge pull request #3027 from dreampiggy/feature_convenient_transition_with_duration

Added the convenient transition with duration APIs
This commit is contained in:
DreamPiggy 2020-06-02 11:37:30 +08:00 committed by GitHub
commit b0ceb25747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 1 deletions

View File

@ -83,7 +83,7 @@ typedef void (^SDWebImageTransitionCompletionBlock)(BOOL finished);
*/
@interface SDWebImageTransition (Conveniences)
/// Fade transition.
/// Fade-in transition.
@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *fadeTransition;
/// Flip from left transition.
@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromLeftTransition;
@ -98,6 +98,34 @@ typedef void (^SDWebImageTransitionCompletionBlock)(BOOL finished);
/// Curl down transition.
@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *curlDownTransition;
/// Fade-in transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)fadeTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(fade(duration:));
/// Flip from left transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)flipFromLeftTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(flipFromLeft(duration:));
/// Flip from right transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)flipFromRightTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(flipFromRight(duration:));
/// Flip from top transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)flipFromTopTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(flipFromTop(duration:));
/// Flip from bottom transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)flipFromBottomTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(flipFromBottom(duration:));
/// Curl up transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)curlUpTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(curlUp(duration:));
/// Curl down transition with duration.
/// @param duration transition duration, use ease-in-out
+ (nonnull instancetype)curlDownTransitionWithDuration:(NSTimeInterval)duration NS_SWIFT_NAME(curlDown(duration:));
@end
#endif

View File

@ -84,6 +84,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
@implementation SDWebImageTransition (Conveniences)
+ (SDWebImageTransition *)fadeTransition {
return [self fadeTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)fadeTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction;
@ -94,6 +98,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)flipFromLeftTransition {
return [self flipFromLeftTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)flipFromLeftTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowUserInteraction;
@ -104,6 +112,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)flipFromRightTransition {
return [self flipFromRightTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)flipFromRightTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionAllowUserInteraction;
@ -114,6 +126,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)flipFromTopTransition {
return [self flipFromTopTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)flipFromTopTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionFlipFromTop | UIViewAnimationOptionAllowUserInteraction;
@ -124,6 +140,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)flipFromBottomTransition {
return [self flipFromBottomTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)flipFromBottomTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionFlipFromBottom | UIViewAnimationOptionAllowUserInteraction;
@ -134,6 +154,10 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)curlUpTransition {
return [self curlUpTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)curlUpTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionCurlUp | UIViewAnimationOptionAllowUserInteraction;
@ -144,12 +168,17 @@ CATransition * SDTransitionFromAnimationOptions(SDWebImageAnimationOptions optio
}
+ (SDWebImageTransition *)curlDownTransition {
return [self curlDownTransitionWithDuration:0.5];
}
+ (SDWebImageTransition *)curlDownTransitionWithDuration:(NSTimeInterval)duration {
SDWebImageTransition *transition = [SDWebImageTransition new];
#if SD_UIKIT
transition.animationOptions = UIViewAnimationOptionTransitionCurlDown | UIViewAnimationOptionAllowUserInteraction;
#else
transition.animationOptions = SDWebImageAnimationOptionTransitionCurlDown;
#endif
transition.duration = duration;
return transition;
}