QIOSInputContext: animate screen from current transformation

Since we assign a fromValue to the scroll animation directly, the
UIViewAnimationOptionBeginFromCurrentState flag does not have
any effect. So we need to set the fromValue based on the current
presentation state explicit.

The reason why we need to ensure that we scroll from the current
state is to avoid screen 'jumping' as a result of the scroll function
being called many times during the same event loop cycle during after a
focus change (focus object/window change, cursor rect change etc).

Change-Id: Id98f43d60ec5d028b113361dab953569accf9b3f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2014-09-25 11:27:58 +02:00
parent 956e88f23e
commit 4c08e3dfd5

View File

@ -394,7 +394,8 @@ void QIOSInputContext::scroll(int y)
animation = [CABasicAnimation animationWithKeyPath:@"sublayerTransform"]; animation = [CABasicAnimation animationWithKeyPath:@"sublayerTransform"];
} }
animation.fromValue = [NSValue valueWithCATransform3D:rootView.layer.sublayerTransform]; CATransform3D currentSublayerTransform = static_cast<CALayer *>([rootView.layer presentationLayer]).sublayerTransform;
animation.fromValue = [NSValue valueWithCATransform3D:currentSublayerTransform];
animation.toValue = [NSValue valueWithCATransform3D:translationTransform]; animation.toValue = [NSValue valueWithCATransform3D:translationTransform];
[rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"]; [rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"];
rootView.layer.sublayerTransform = translationTransform; rootView.layer.sublayerTransform = translationTransform;