diff options
author | skobes@chromium.org <skobes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-18 22:37:26 +0000 |
---|---|---|
committer | skobes@chromium.org <skobes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-18 22:37:26 +0000 |
commit | 7a7d5bec832fd997b6b2eef3ec9c0906b74ef16d (patch) | |
tree | 618f497d0ca76b781df27da3ae6de9188b00bcdf /cc/trees/layer_tree_host_impl.cc | |
parent | 472de00aa7609c352c95d64abb125145296fc73a (diff) | |
download | chromium_src-7a7d5bec832fd997b6b2eef3ec9c0906b74ef16d.zip chromium_src-7a7d5bec832fd997b6b2eef3ec9c0906b74ef16d.tar.gz chromium_src-7a7d5bec832fd997b6b2eef3ec9c0906b74ef16d.tar.bz2 |
Scroll offset animation curve retargeting.
Adds support for updating the target of an in-progress input-triggered impl-side scroll offset animation, keeping the velocity function continuous.
BUG=575
Review URL: https://codereview.chromium.org/393713002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees/layer_tree_host_impl.cc')
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index a2c8111..f137cb4 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2302,9 +2302,25 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( const gfx::Point& viewport_point, const gfx::Vector2dF& scroll_delta) { - if (CurrentlyScrollingLayer()) { - // TODO(skobes): Update the target of the existing animation. - return ScrollIgnored; + if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { + Animation* animation = + layer_impl->layer_animation_controller()->GetAnimation( + Animation::ScrollOffset); + if (!animation) + return ScrollIgnored; + + ScrollOffsetAnimationCurve* curve = + animation->curve()->ToScrollOffsetAnimationCurve(); + + gfx::Vector2dF new_target = curve->target_value() + scroll_delta; + new_target.SetToMax(gfx::Vector2dF()); + new_target.SetToMin(layer_impl->MaxScrollOffset()); + + curve->UpdateTarget( + animation->TrimTimeToCurrentIteration(CurrentFrameTimeTicks()), + new_target); + + return ScrollStarted; } // ScrollAnimated is only used for wheel scrolls. We use the same bubbling // behavior as ScrollBy to determine which layer to animate, but we do not @@ -2341,7 +2357,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( curve->SetInitialValue(current_offset); scoped_ptr<Animation> animation = - Animation::Create(curve->Clone().Pass(), + Animation::Create(curve.PassAs<AnimationCurve>(), AnimationIdProvider::NextAnimationId(), AnimationIdProvider::NextGroupId(), Animation::ScrollOffset); |