Setting AnimationCurve for implicit animations

  • Hi List,

    does anybody know, if it's possible, to change the AnimationCurve of
    an implicit Animation. I know I can create a CAAnimation an set an
    CAMediaTimingFunction into it but how do I get the Animation Object
    for an implicit animation which is not a property?

    An Example for this, is the CAScrollLayer with its Method
    "scrollToPoint". This is perfectly animated but always uses Ease In /
    Ease out as the animation curve, but I want it to be linear.

    I get a smooth scrolling effect with just a few lines of code:

    [CATransaction begin];
    [CATransaction setValue:[NSNumber numberWithFloat:((NSWidth([textView
    bounds])-NSWidth([self bounds]))/2)*0.10f]
                        forKey:kCATransactionAnimationDuration];
    [textLayer scrollPoint:NSMakePoint((NSWidth([textView bounds])-
    NSWidth([self bounds])), 0.0)];
    [CATransaction commit];

    The "textLayer" of Type CATextLayer, is included within a
    CAScrollLayer. As I said before, scrolling is fine but with the wrong
    curve. How can I get the animation Object that is responsible for the
    Animation of "scrollPoint" to set its "timming" Property?

    Any Ideas?

    regards
    Joachim
  • Hi Again,

    I solved the problem myself:

    The "scrollPoint" of CATextLayer does nothing more than modifying the
    "bounds" of itself or more exactly the origin: Thereby the "bounds"
    Property-KVO gets triggered. So all I had to do, is setting up an
    animation for the "bounds" property of CAScrollLayer with the right
    CAMediaTimingFunction.

    Now the code looks like this:

    CAMediaTimingFunction *timing = [CAMediaTimingFunction
    functionWithName:kCAMediaTimingFunctionLinear];
    CABasicAnimation *animation = [CABasicAnimation
    animationWithKeyPath:@"bounds"];
    animation.duration = ((NSWidth([textView bounds])-NSWidth([self
    bounds]))/2)*0.10f;
    animation.timingFunction = timing;

    [scrollLayer addAnimation:animation forKey:@"boundsAnimation"];
    [textLayer scrollPoint:NSMakePoint((NSWidth([textView bounds])-
    NSWidth([self bounds])), 0.0)];

    regards
    Joachim

    Am 30.10.2007 um 22:21 schrieb Joachim Deelen:

    > Hi List,
    >
    > does anybody know, if it's possible, to change the AnimationCurve of
    > an implicit Animation. I know I can create a CAAnimation an set an
    > CAMediaTimingFunction into it but how do I get the Animation Object
    > for an implicit animation which is not a property?
    >
    > An Example for this, is the CAScrollLayer with its Method
    > "scrollToPoint". This is perfectly animated but always uses Ease
    > In / Ease out as the animation curve, but I want it to be linear.
    >
    > I get a smooth scrolling effect with just a few lines of code:
    >
    > [CATransaction begin];
    > [CATransaction setValue:[NSNumber numberWithFloat:
    > ((NSWidth([textView bounds])-NSWidth([self bounds]))/2)*0.10f]
    > forKey:kCATransactionAnimationDuration];
    > [textLayer scrollPoint:NSMakePoint((NSWidth([textView bounds])-
    > NSWidth([self bounds])), 0.0)];
    > [CATransaction commit];
    >
    > The "textLayer" of Type CATextLayer, is included within a
    > CAScrollLayer. As I said before, scrolling is fine but with the
    > wrong curve. How can I get the animation Object that is responsible
    > for the Animation of "scrollPoint" to set its "timming" Property?
    >
    > Any Ideas?
    >
    > regards
    > Joachim
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today