Commit 858e92a1 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Do not drive animation on SetVisible when visibility is not changed

Sometimes TrayItemView::SetVisible() can be called repeatedly.
An example is PowerTrayView() -- its SetVisible() can be called
periodically based on the power status. That causes animation
and AnimationProgressed(), but that is redundant.

Bug: 1082562
Test: manually
Change-Id: I45573360edda49572975966d1a84d4d067edbf13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2223432Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774381}
parent a114be02
......@@ -60,8 +60,12 @@ void TrayItemView::SetVisible(bool set_visible) {
return;
}
// Do not invoke animation when visibility is not changing.
if (set_visible == GetVisible())
return;
if (!animation_) {
animation_.reset(new gfx::SlideAnimation(this));
animation_ = std::make_unique<gfx::SlideAnimation>(this);
animation_->SetSlideDuration(base::TimeDelta::FromMilliseconds(200));
animation_->SetTweenType(gfx::Tween::LINEAR);
animation_->Reset(GetVisible() ? 1.0 : 0.0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment