blob: a7b220c64192e5dfc3bd84ecfa990741165e1e59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/animation/scrollbar_animation_controller_linear_fade.h"
#include "base/time/time.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/scrollbar_layer_impl_base.h"
namespace cc {
scoped_ptr<ScrollbarAnimationControllerLinearFade>
ScrollbarAnimationControllerLinearFade::Create(
LayerImpl* scroll_layer,
ScrollbarAnimationControllerClient* client,
base::TimeDelta delay_before_starting,
base::TimeDelta duration) {
return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade(
scroll_layer, client, delay_before_starting, duration));
}
ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
LayerImpl* scroll_layer,
ScrollbarAnimationControllerClient* client,
base::TimeDelta delay_before_starting,
base::TimeDelta duration)
: ScrollbarAnimationController(client, delay_before_starting, duration),
scroll_layer_(scroll_layer) {
}
ScrollbarAnimationControllerLinearFade::
~ScrollbarAnimationControllerLinearFade() {}
void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) {
ApplyOpacityToScrollbars(1.f - progress);
if (progress == 1.f)
StopAnimation();
}
void ScrollbarAnimationControllerLinearFade::DidScrollUpdate() {
ScrollbarAnimationController::DidScrollUpdate();
ApplyOpacityToScrollbars(1.f);
}
void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars(
float opacity) {
if (!scroll_layer_->scrollbars())
return;
LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars();
for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin();
it != scrollbars->end();
++it) {
ScrollbarLayerImplBase* scrollbar = *it;
if (scrollbar->is_overlay_scrollbar())
scrollbar->SetOpacity(opacity);
}
}
} // namespace cc
|