Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #include "platform/scroll/SmoothScrollSequencer.h" | |
| 5 | |
| 6 #include "platform/scroll/ProgrammaticScrollAnimator.h" | |
| 7 #include "platform/scroll/ScrollableArea.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 SmoothScrollSequencer* SmoothScrollSequencer::create() { | |
| 12 return new SmoothScrollSequencer(); | |
| 13 } | |
| 14 | |
| 15 SmoothScrollSequencer::SmoothScrollSequencer() {} | |
| 16 | |
| 17 SmoothScrollSequencer::~SmoothScrollSequencer() {} | |
| 18 | |
| 19 void SmoothScrollSequencer::queueAnimation(ScrollableArea* scrollable, | |
| 20 ScrollOffset offset) { | |
| 21 ScrollerAndOffsetPair scrollerOffset(scrollable, offset); | |
| 22 m_queue.push_back(scrollerOffset); | |
| 23 } | |
| 24 | |
| 25 void SmoothScrollSequencer::runQueuedAnimations() { | |
| 26 if (!m_queue.empty()) { | |
| 27 ScrollerAndOffsetPair scrollerOffset = m_queue.back(); | |
| 28 ScrollableArea* scrollable = scrollerOffset.first; | |
| 29 ScrollOffset offset = scrollerOffset.second; | |
| 30 scrollable->programmaticScrollAnimator().animateToOffset(offset); | |
|
bokan
2017/04/07 15:56:52
Unless I'm missing something, I think it'd be bett
sunyunjia
2017/05/12 18:40:25
Done.
| |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void SmoothScrollSequencer::notifyAnimationFinished() { | |
| 35 if (!m_queue.empty()) { | |
| 36 m_queue.pop_back(); | |
| 37 runQueuedAnimations(); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 void SmoothScrollSequencer::abortAnimations() { | |
| 42 m_queue.clear(); | |
| 43 } | |
| 44 | |
| 45 } // namespace blink | |
| OLD | NEW |