OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/scroll_offset_animations_impl.h" | 5 #include "cc/animation/scroll_offset_animations_impl.h" |
6 | 6 |
7 #include "cc/animation/animation_host.h" | 7 #include "cc/animation/animation_host.h" |
8 #include "cc/animation/animation_id_provider.h" | 8 #include "cc/animation/animation_id_provider.h" |
9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
10 #include "cc/animation/animation_timeline.h" | 10 #include "cc/animation/animation_timeline.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 ScrollOffsetAnimationsImpl::~ScrollOffsetAnimationsImpl() { | 30 ScrollOffsetAnimationsImpl::~ScrollOffsetAnimationsImpl() { |
31 scroll_offset_timeline_->DetachPlayer(scroll_offset_animation_player_.get()); | 31 scroll_offset_timeline_->DetachPlayer(scroll_offset_animation_player_.get()); |
32 animation_host_->RemoveAnimationTimeline(scroll_offset_timeline_.get()); | 32 animation_host_->RemoveAnimationTimeline(scroll_offset_timeline_.get()); |
33 } | 33 } |
34 | 34 |
35 void ScrollOffsetAnimationsImpl::ScrollAnimationCreate( | 35 void ScrollOffsetAnimationsImpl::ScrollAnimationCreate( |
36 ElementId element_id, | 36 ElementId element_id, |
37 const gfx::ScrollOffset& target_offset, | 37 const gfx::ScrollOffset& target_offset, |
38 const gfx::ScrollOffset& current_offset, | 38 const gfx::ScrollOffset& current_offset, |
39 base::TimeDelta delayed_by) { | 39 base::TimeDelta delayed_by, |
| 40 base::TimeDelta animation_start_offset) { |
40 std::unique_ptr<ScrollOffsetAnimationCurve> curve = | 41 std::unique_ptr<ScrollOffsetAnimationCurve> curve = |
41 ScrollOffsetAnimationCurve::Create( | 42 ScrollOffsetAnimationCurve::Create( |
42 target_offset, CubicBezierTimingFunction::CreatePreset( | 43 target_offset, CubicBezierTimingFunction::CreatePreset( |
43 CubicBezierTimingFunction::EaseType::EASE_IN_OUT), | 44 CubicBezierTimingFunction::EaseType::EASE_IN_OUT), |
44 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); | 45 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); |
45 curve->SetInitialValue(current_offset, delayed_by); | 46 curve->SetInitialValue(current_offset, delayed_by); |
46 | 47 |
47 std::unique_ptr<Animation> animation = Animation::Create( | 48 std::unique_ptr<Animation> animation = Animation::Create( |
48 std::move(curve), AnimationIdProvider::NextAnimationId(), | 49 std::move(curve), AnimationIdProvider::NextAnimationId(), |
49 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); | 50 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); |
| 51 animation->set_time_offset(animation_start_offset); |
50 animation->set_is_impl_only(true); | 52 animation->set_is_impl_only(true); |
51 | 53 |
52 DCHECK(scroll_offset_animation_player_); | 54 DCHECK(scroll_offset_animation_player_); |
53 DCHECK(scroll_offset_animation_player_->animation_timeline()); | 55 DCHECK(scroll_offset_animation_player_->animation_timeline()); |
54 | 56 |
55 ReattachScrollOffsetPlayerIfNeeded(element_id); | 57 ReattachScrollOffsetPlayerIfNeeded(element_id); |
56 | 58 |
57 scroll_offset_animation_player_->AddAnimation(std::move(animation)); | 59 scroll_offset_animation_player_->AddAnimation(std::move(animation)); |
58 } | 60 } |
59 | 61 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ElementId element_id) { | 159 ElementId element_id) { |
158 if (scroll_offset_animation_player_->element_id() != element_id) { | 160 if (scroll_offset_animation_player_->element_id() != element_id) { |
159 if (scroll_offset_animation_player_->element_id()) | 161 if (scroll_offset_animation_player_->element_id()) |
160 scroll_offset_animation_player_->DetachElement(); | 162 scroll_offset_animation_player_->DetachElement(); |
161 if (element_id) | 163 if (element_id) |
162 scroll_offset_animation_player_->AttachElement(element_id); | 164 scroll_offset_animation_player_->AttachElement(element_id); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 } // namespace cc | 168 } // namespace cc |
OLD | NEW |