Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:56:40+00:00 2026-06-06T08:56:40+00:00

I have a layer with a CAKeyframeAnimation that is animating it along a path.

  • 0

I have a layer with a CAKeyframeAnimation that is animating it along a path. The layer also has a changing transform property as the animation’s rotationMode is set to kCAAnimationRotateAuto.

When I tap the layer (which I’m detecting with a tap gesture recognizer and hit-testing the presentationLayer of the animated layer like in this question, if there’s a better way to do this let me know), I want to do the following:

  1. Grab the position and transform from the presentation layer
  2. Remove the current animation.
  3. Using the info grabbed in step 1, add a new animation to the layer that maintains the transform and start point and slows the layer’s transit to a new endpoint ~40 pixels from where the previous animation had just ended.

The end result should be that, when tapped, an animating layer will slow to a halt along a straight line that lies tangent to the path at the point where the original keyframe animation was removed.

How would I go about doing this, math-wise? I already have the start point and transform, so it seems to me that I just need to figure out the endpoint, perhaps by using the startpoint, transform, and distance (say 40 for fun). Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:56:42+00:00Added an answer on June 6, 2026 at 8:56 am

    If I understand correctly what you basically want is for the animated layer to decelerate and stop along the same vector as it’s moving when you tap it. If you have the position when you tap it and the transform when you tap it I think you can find out the endpoint by doing the following:

    CATransform3D transform = <Your layer's transform goes here>;
    CGPoint startPoint = <Your layers's current position goes here>;
    CGFloat distance = 40.f;
    
    CGPoint v = CGPointMake(0, distance);
    
    CGAffineTransform affineTransform = CATransform3DGetAffineTransform(transform);
    
    CGPoint offset = CGPointApplyAffineTransform(v, affineTransform);
    CGPoint endPoint = CGPointMake(startPoint.x + offset.x, startPoint.y + offset.y);
    

    P.S. – This only works if you don’t apply any scaling, skewing etc. as part of your animation (i.e. the transform should only represent rotations and translations)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with IE. I have a layer that has this style
We have a layer that appears when a certain text input has the focus
Using a jQuery effect, I have a layer that has a collection of HTML
I have a UIView instance that I am animating using CAKeyframeAnimation . It is
I'm successfully animating a single layer to alter its position along an arbitrary path
For example I have this CAKeyFrameAnimation: CALayer* theLayer = myView.layer; CAKeyframeAnimation* animation; animation =
I have a layer that I need to transform. Currently I am using the
I have one like this: CALayer *layer = stripeButton.layer; CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@bounds.origin.y];
Say you have a layer with markers and an event listener that displays a
I have a Business Layer that passes a Conn string and a SQLCommand to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.