• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_ANIMATOR_H
17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_ANIMATOR_H
18 
19 #include "frameworks/base/memory/ace_type.h"
20 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
21 #include "frameworks/core/animation/keyframe_animation.h"
22 
23 namespace OHOS::Ace::Framework {
24 
25 class JSAnimator : public AceType {
26     DECLARE_ACE_TYPE(JSAnimator, AceType);
27 
28 public:
29     JSAnimator() = default;
30     ~JSAnimator() override = default;
31 
32     static void JSBind(BindingTarget globalObj);
33     static void Create(const JSCallbackInfo& info);
34     static void Pop();
35 
36     static void SetState(int32_t state);
37     static void SetDuration(int32_t duration);
38     static void SetCurve(const JSCallbackInfo& info);
39     static void SetDelay(int32_t delay);
40     static void SetFillMode(int32_t fillMode);
41     static void SetIteration(int32_t iteration);
42     static void SetPlayMode(int32_t playMode);
43     static void SetMotion(const JSCallbackInfo& info);
44 
45     static void OnStart(const JSCallbackInfo& info);
46     static void OnPause(const JSCallbackInfo& info);
47     static void OnRepeat(const JSCallbackInfo& info);
48     static void OnCancel(const JSCallbackInfo& info);
49     static void OnFinish(const JSCallbackInfo& info);
50     static void OnFrame(const JSCallbackInfo& info);
51 
52 private:
53     static EventMarker GetEventMarker(const JSCallbackInfo& info);
54     static std::string animatorId_;
55 
56 };
57 
58 class JSSpringProp : public AceType {
59     DECLARE_ACE_TYPE(JSSpringProp, AceType);
60 
61 public:
62     JSSpringProp() = default;
63     ~JSSpringProp() override = default;
64 
65     static void ConstructorCallback(const JSCallbackInfo& info);
66     static void DestructorCallback(JSSpringProp* obj);
67 
SetSpringProp(const RefPtr<SpringProperty> & springProp)68     void SetSpringProp(const RefPtr<SpringProperty>& springProp)
69     {
70         springProp_ = springProp;
71     }
72 
GetSpringProp()73     const RefPtr<SpringProperty>& GetSpringProp()
74     {
75         return springProp_;
76     }
77 
78 private:
79     RefPtr<SpringProperty> springProp_;
80 
81 };
82 
83 class JSMotion : public AceType {
84     DECLARE_ACE_TYPE(JSMotion, AceType);
85 
86 public:
87     JSMotion() = default;
88     ~JSMotion() override = default;
89 
90     static void ConstructorCallback(const JSCallbackInfo& info);
91     static void DestructorCallback(JSMotion* obj);
92 
SetMotion(const RefPtr<Motion> & motion)93     void SetMotion(const RefPtr<Motion>& motion)
94     {
95         motion_ = motion;
96     }
97 
GetMotion()98     const RefPtr<Motion>& GetMotion()
99     {
100         return motion_;
101     }
102 
103 private:
104     RefPtr<Motion> motion_;
105 
106 };
107 
108 } // namespace OHOS::Ace::Framework
109 
110 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_ANIMATOR_H