agens-no / Anymotion

one unified API for animating UIKit, CoreAnimation, POP and your library of choice.
Other
33 stars 9 forks source link

Add operator: `-[ANYAnimation before:]` and `-[ANYAnimation after:]` #12

Closed hfossli closed 7 years ago

hfossli commented 7 years ago

before: work you want to do before the animation is created and added. after: work you want to do do after the animation is finished/cancelled/removed.

hfossli commented 7 years ago

I want to know which name is better. Please vote.

hfossli commented 7 years ago

Interface

@interface ANYAnimation (Operators)
- (instancetype)initially:(dispatch_block_t)initially;
- (instancetype)finally:(dispatch_block_t)finally;
@end

Usage

[[anim initially:^{
    [view addSubview:maskView];
}] finally:^{
    [maskView removeFromSuperview];
}];
hfossli commented 7 years ago

Interface

@interface ANYAnimation (Operators)
- (instancetype)before:(dispatch_block_t)before;
- (instancetype)after:(dispatch_block_t)after;
@end

Usage

[[anim before:^{
    [view addSubview:maskView];
}] after:^{
    [maskView removeFromSuperview];
}];
hfossli commented 7 years ago

RAC uses initially and finally on 2.5

kostiakoval commented 7 years ago

what is latest RAC version? How about other libs like Rx and POP. And most important UIKit and CoreAnimation, because it's Apple :)

aarsland commented 7 years ago

finally feels like something that will be done under all circumstances - like a try-catch block, but I support @kostiakoval.

hfossli commented 7 years ago

Well Apple is probably more along the line of

Interface

@interface ANYAnimation (Operators)
- (instancetype)willStart:(dispatch_block_t)willStart;
@end

Usage

[[anim willStart:^{
    [view addSubview:maskView];
}] complete:^(BOOL success){
    [maskView removeFromSuperview];
}];
matshau commented 7 years ago

@hfossli What's the status here? Looks like before and after is implemented?

hfossli commented 7 years ago

Yep, I am not 100% satisfied. It somehow felter weird. It might be better to rename them. Let's close this and reopen a new one later.