mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-26 18:15:36 +00:00
_CPObjectAnimator & CPViewAnimator
Make subclassing easier. For a specific animator, can choose the implementation to invoke by subclassing - (id) forwardingTargetForSelector: The pattern for the animator class, if no -(id)animator is implemented, is now <TargetClass>Animator by default and it searches for a <TargetSuperClass>Animator if necessary. NEW: Added support for CPAnimationTriggerOrderIn|Out animated key.
This commit is contained in:
1 parent
db5b103ab3
commit
c75f1685c5
2 files changed
+54
-12
No files matched your search
@@ -8,6 +8,36 @@
|
||||
{
|
||||
}
|
||||
|
||||
- (void)viewWillMoveToSuperview:(CPView)aSuperview
|
||||
{
|
||||
var orderInAnim = [self animationForKey:@"CPAnimationTriggerOrderIn"];
|
||||
|
||||
if (orderInAnim && [orderInAnim isKindOfClass:[CAPropertyAnimation class]])
|
||||
{
|
||||
[_target setValue:[orderInAnim fromValue] forKeyPath:[orderInAnim keyPath]];
|
||||
}
|
||||
|
||||
[_target viewWillMoveToSuperview:aSuperview];
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToSuperview
|
||||
{
|
||||
var orderInAnim = [self animationForKey:@"CPAnimationTriggerOrderIn"];
|
||||
|
||||
if (orderInAnim && [orderInAnim isKindOfClass:[CAPropertyAnimation class]])
|
||||
{
|
||||
[self _setTargetValue:YES withKeyPath:@"CPAnimationTriggerOrderIn" fallback:nil completion:function()
|
||||
{
|
||||
[_target setValue:[orderInAnim toValue] forKeyPath:[orderInAnim keyPath]];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_target viewDidMoveToSuperview];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)removeFromSuperview
|
||||
{
|
||||
[self _setTargetValue:nil withKeyPath:@"CPAnimationTriggerOrderOut" setter:_cmd];
|
||||
@@ -61,6 +91,7 @@
|
||||
}
|
||||
|
||||
- (void)_setTargetValue:(id)aTargetValue withKeyPath:(CPString)aKeyPath fallback:(Function)fallback completion:(Function)completion
|
||||
- (void)_setTargetValue:(id)aTargetValue withKeyPath:(CPString)aKeyPath fallback:(Function)fallback completion:(Function)completion
|
||||
{
|
||||
var animation = [_target animationForKey:aKeyPath],
|
||||
context = [CPAnimationContext currentContext];
|
||||
@@ -126,22 +157,32 @@ var CPVIEW_PROPERTIES_DESCRIPTOR = @{
|
||||
return [CPVIEW_PROPERTIES_DESCRIPTOR objectForKey:aKeyPath];
|
||||
}
|
||||
|
||||
- (id)DOMElementForKeyPath:(CPString)aKeyPath
|
||||
+ (Class)animatorClass
|
||||
{
|
||||
return _DOMElement;
|
||||
var anim_class = CPClassFromString(CPStringFromClass(self) + "Animator");
|
||||
|
||||
if (anim_class)
|
||||
return anim_class;
|
||||
|
||||
return [super animatorClass];
|
||||
}
|
||||
|
||||
- (id)animator
|
||||
{
|
||||
if (!_animator)
|
||||
_animator = [[CPViewAnimator alloc] initWithTarget:self];
|
||||
_animator = [[[[self class] animatorClass] alloc] initWithTarget:self];
|
||||
|
||||
return _animator;
|
||||
}
|
||||
|
||||
- (id)DOMElementForKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
return _DOMElement;
|
||||
}
|
||||
|
||||
+ (CAAnimation)defaultAnimationForKey:(CPString)aKey
|
||||
{
|
||||
if ([[self class] cssPropertiesForKeyPath:aKey] !== nil)
|
||||
if ([self cssPropertiesForKeyPath:aKey] !== nil)
|
||||
return [CAAnimation animation];
|
||||
|
||||
return nil;
|
||||
|
||||
@@ -47,25 +47,26 @@ var _supportsCSSAnimations = null;
|
||||
return [_target isEqual:anObject];
|
||||
}
|
||||
|
||||
- (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
|
||||
{
|
||||
return [_target methodSignatureForSelector:aSelector];
|
||||
}
|
||||
|
||||
- (id)forwardingTargetForSelector:(SEL)aSelector
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
|
||||
- (CPMethodSignature)methodSignatureForSelector:(SEL)aSelector
|
||||
{
|
||||
return [_target methodSignatureForSelector:aSelector];
|
||||
}
|
||||
|
||||
- (void)forwardInvocation:(CPInvocation)anInvocation
|
||||
{
|
||||
[anInvocation setTarget:_target];
|
||||
[anInvocation invoke];
|
||||
var target = [self forwardingTargetForSelector:[anInvocation selector]];
|
||||
[anInvocation invokeWithTarget:target];
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)doesNotRecognizeSelector:(SEL)aSelector
|
||||
{
|
||||
[_target doesNotRecognizeSelector:aSelector];
|
||||
[CPException raise:CPInvalidArgumentException reason:@"Animator does not recognize selector " + CPStringFromSelector(aSelector)];
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
|
||||
Reference in new issue
Block a user