1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "picker_animation.h"
17 
18 namespace OHOS::Ace {
19 
Init()20 void PickerAnimation::Init()
21 {
22     animation_ = AceType::MakeRefPtr<CurveAnimation<double>>(start_, end_, curve_);
23     animation_->AddListener(Animation<double>::ValueCallback(callback_));
24     controller_ = CREATE_ANIMATOR(pipe_);
25     controller_->SetDuration(duration_);
26     controller_->SetStartDelay(delay_);
27 }
28 
Play()29 void PickerAnimation::Play()
30 {
31     if (!controller_ || !animation_) {
32         return;
33     }
34 
35     controller_->ClearInterpolators();
36     controller_->AddInterpolator(animation_);
37     controller_->Play();
38 }
39 
Stop()40 void PickerAnimation::Stop()
41 {
42     if (controller_) {
43         controller_->Finish();
44     }
45 }
46 
47 } // namespace OHOS::Ace
48 
49