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

  • SEARCH
  • Home
  • 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 8920603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:18:50+00:00 2026-06-15T06:18:50+00:00

I have a pageLeft and pageRight animation that animates the position and alpha of

  • 0

I have a pageLeft and pageRight animation that animates the position and alpha of 2 views, making a total of 4 simultaneous CABasicAnimations:

  1. Move next page into the view
  2. Move current page out of the view
  3. Fade in next page
  4. Fade out current page

Everything works well with the animations and setup. this question is about mouse events after the page animation. I have found that after the animation runs, the nextView does not receive mouseDown: events. If the animation is not run because the shouldNotAnimate block is run below instead, the nextView does receive mouseDown: events.

This means that something about the way I have setup my CABasicAnimations and CATransaction is causing this. I am stumped as to what it could be. Any ideas?


Animation Code:

BOOL forward = currentIndex < index;

if (shouldNotAnimate) {
    // handles swapping pages faster than the animation duration
    [self.sourceViewContainer setSubviews:[NSArray array]];

    [nextView.layer removeAllAnimations];
    [nextView setFrame:self.sourceViewContainer.bounds];
    [nextView.layer setPosition:self.sourceViewContainer.bounds.origin];
    [nextView.layer setOpacity:1.0];
    [self.sourceViewContainer addSubview:nextView];

    [currentView removeFromSuperview];      
    [currentView.layer removeAllAnimations];
    [currentView setFrame:self.sourceViewContainer.bounds];
    [currentView.layer setPosition:self.sourceViewContainer.bounds.origin];
    [currentView.layer setOpacity:1.0];

    self.animationsRunning = NO;

} else {

    self.animationsRunning = YES;

    [CATransaction begin];
    [CATransaction setCompletionBlock:^{
        self.animationsRunning = NO;
    }];

    // Setup incoming push animation
    [nextView setFrame:CGRectMake(self.sourceViewContainer.bounds.size.width * (forward ? 1 : -1), 0, self.sourceViewContainer.bounds.size.width, self.sourceViewContainer.bounds.size.width)];
    [self.sourceViewContainer addSubview:nextView];
    CABasicAnimation *incomingAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
    incomingAnimation.fromValue = [NSValue valueWithPoint:nextView.frame.origin];
    incomingAnimation.toValue = [NSValue valueWithPoint:self.sourceViewContainer.bounds.origin];
    incomingAnimation.duration = PANEL_PAGE_SWIPE_ANIMATION_DURATION;
    incomingAnimation.removedOnCompletion = NO;
    incomingAnimation.fillMode = kCAFillModeForwards;
    incomingAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    incomingAnimation.completion = ^(BOOL finished) {
        [nextView.layer setPosition:self.sourceViewContainer.bounds.origin];
        [nextView.layer removeAnimationForKey:@"incoming"];
    };

    [nextView.layer addAnimation:incomingAnimation forKey:@"incoming"];


    // Setup outgoing push animation
    CGRect offscreen = CGRectMake(self.sourceViewContainer.bounds.size.width * (forward ? -1 : 1), 0, self.sourceViewContainer.bounds.size.width, self.sourceViewContainer.bounds.size.height);
    CABasicAnimation *outgoingAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
    outgoingAnimation.fromValue = [NSValue valueWithPoint:self.sourceViewContainer.bounds.origin];
    outgoingAnimation.toValue = [NSValue valueWithPoint:offscreen.origin];
    outgoingAnimation.duration = PANEL_PAGE_SWIPE_ANIMATION_DURATION;
    outgoingAnimation.removedOnCompletion = NO;
    outgoingAnimation.fillMode = kCAFillModeForwards;
    outgoingAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    outgoingAnimation.completion = ^(BOOL finished) {
        [currentView removeFromSuperview];
        [currentView.layer setPosition:self.sourceViewContainer.bounds.origin];
        [currentView.layer removeAnimationForKey:@"outgoing"];

    };
    [currentView.layer addAnimation:outgoingAnimation forKey:@"outgoing"];


    // Setup incoming alpha animation
    CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fadeInAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
    fadeInAnimation.toValue = [NSNumber numberWithFloat:1.0f];
    fadeInAnimation.duration = PANEL_PAGE_SWIPE_ANIMATION_DURATION;
    fadeInAnimation.removedOnCompletion = NO;
    fadeInAnimation.fillMode = kCAFillModeForwards;
    fadeInAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    fadeInAnimation.completion = ^(BOOL finished) {
        [nextView.layer setOpacity:1.0f];
        [nextView.layer removeAnimationForKey:@"fadeIn"];
    };
    [nextView.layer addAnimation:fadeInAnimation forKey:@"fadeIn"];


    // Setup outgoing alpha animation
    CABasicAnimation *fadeOutAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fadeOutAnimation.fromValue = [NSNumber numberWithFloat:1.0f];
    fadeOutAnimation.toValue = [NSNumber numberWithFloat:0.0f];
    fadeOutAnimation.duration = PANEL_PAGE_SWIPE_ANIMATION_DURATION;
    fadeOutAnimation.removedOnCompletion = NO;
    fadeOutAnimation.fillMode = kCAFillModeForwards;
    fadeOutAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    fadeOutAnimation.completion = ^(BOOL finished) {
        [currentView removeFromSuperview];
        [currentView.layer setOpacity:1.0f];
        [currentView.layer removeAnimationForKey:@"fadeOut"];

    };
    [currentView.layer addAnimation:fadeOutAnimation forKey:@"fadeOut"];

    [CATransaction commit];

} // Run animations

Solution

I had to explicitly set the view frame in the completion block, even though I had done this immediately prior to the animation calls.

    [CATransaction begin];
    [CATransaction setCompletionBlock:^{
        self.animationsRunning = NO;
        [nextView setFrame:self.sourceViewContainer.bounds];
    }];
  • 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-15T06:18:52+00:00Added an answer on June 15, 2026 at 6:18 am

    I think I know what’s going on.

    CAAnimation objects don’t actually change the underlying property that they animation. Instead, it applies the properties to a presentation layer, which is drawn instead of the regular layer. When you create an animation with removedOnCompletion=false, the presentation layer is left active after the animation is completed, but the underlying property still isn’t changed. Plus, moving a view’s layer doesn’t move the view itself, so it won’t respond to user interaction at it’s new location.

    I’d suggest moving your views using UIView block animation (UIView animateWithDuration:completion: and it’s relatives) instead of using CAAnimation objects. Those methods actually move the view to it’s new position, so that it responds to user interaction at the final location once the animation is complete.

    You could do your move and alpha change all in one animation block.

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

Sidebar

Related Questions

I have a scraper that is collecting some data from elsewhere that I have
Have a look at one of my websites: moskah.com The problem is that it
I have a page UIScrollView that will scroll 1 page left or right depending
Have a network location that shows paths in the 8.3 short format. I need
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I have a main div on my page that has the attribute align=center ,
I have a div that is set to 100% height, and it renders perfectly,
i have this jquery crossfade that is working for the most part except it
I have the html structure as below: <div class=pagebody> <div class=pageleft> <div class=sidebarmenu> </div>

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.