diff --git a/AppKit/CoreAnimation/CALayer.j b/AppKit/CoreAnimation/CALayer.j index 2f60cdccf..4cd003635 100644 --- a/AppKit/CoreAnimation/CALayer.j +++ b/AppKit/CoreAnimation/CALayer.j @@ -29,6 +29,8 @@ @import "CGGeometry.j" @import "CPColor.j" @import "CPView.j" +@import "CAMediaTimingFunction.j" + #define DOM(aLayer) aLayer._DOMElement @@ -984,6 +986,8 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) /* Adds an animation to the layer. Supports CABasicAnimation for Numbers (opacity) and Points (position/anchorPoint). + The animation is exerted by means of periodically applying the keypath on the delegate + Only works if the delegate is set! */ - (void)addAnimation:(CAAnimation)anim forKey:(CPString)key { @@ -1027,7 +1031,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) if (startValue == nil) { try { - startValue = [self valueForKey:keyPath]; + startValue = [[self delegate] valueForKey:keyPath]; } catch (e) { // The keyPath was likely invalid (not KVC compliant), abort. @@ -1186,7 +1190,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) } if (current !== nil) - [self setValue:current forKey:context.keyPath]; + [[self delegate] setValue:current forKey:context.keyPath]; if (linearProgress >= 1.0) { diff --git a/Tests/Manual/CPAnimationContextTest/AppController.j b/Tests/Manual/CPAnimationContextTest/AppController.j index dbcac5947..a9d657859 100644 --- a/Tests/Manual/CPAnimationContextTest/AppController.j +++ b/Tests/Manual/CPAnimationContextTest/AppController.j @@ -411,7 +411,7 @@ [_testView setAlphaValue:1.0]; [_pathView setPath:nil]; // Clear the path view as we aren't using it here - // FIX: Ensure the view is layer-backed. + // Ensure the view is layer-backed. // Without this, [_testView layer] returns nil. [_testView setWantsLayer:YES]; @@ -483,9 +483,10 @@ [_testView setWantsLayer:YES]; var layer = [_testView layer]; - [layer setDelegate:_testView]; // 3. Define the Animation + // Animation is performed on _testView + [layer setDelegate:_testView]; var rotationAnim = [CABasicAnimation animationWithKeyPath:@"angle"]; // Rotate 360 degrees (2 * PI) @@ -630,28 +631,6 @@ @end -/* - Category to allow CALayer to drive the 'angle' property on the view. -*/ -@implementation CALayer (RotationTest) - -- (void)setAngle:(float)anAngle -{ - // Store it so [self valueForKey:@"angle"] works for animation start values - self._angle = anAngle; - - // Forward the value to the View (the layer's delegate) to trigger drawRect - if (_delegate && [_delegate respondsToSelector:@selector(setAngle:)]) - [_delegate setAngle:anAngle]; -} - -- (float)angle -{ - return self._angle || 0.0; -} - -@end - var unCamelCase = function(aString) { // insert a space before all caps