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 FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_PAN_HANDLER_H
17 #define FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_PAN_HANDLER_H
18 
19 #include "core/components/gesture_listener/gesture_listener_component.h"
20 #include "core/event/ace_event_handler.h"
21 #include "frameworks/bridge/declarative_frontend/engine/functions/js_pan_function.h"
22 #include "frameworks/bridge/declarative_frontend/jsview/js_view_abstract.h"
23 
24 namespace OHOS::Ace::Framework {
25 
26 class JSPanHandler {
27 private:
28     enum class PanEvent { START, UPDATE, END, CANCEL };
29 
30 private:
31     RefPtr<OHOS::Ace::Component> component_;
32     RefPtr<JsPanFunction> jsOnStartFunc_;
33     RefPtr<JsPanFunction> jsOnUpdateFunc_;
34     RefPtr<JsPanFunction> jsOnEndFunc_;
35     RefPtr<JsPanFunction> jsOnCancelFunc_;
36 
37 public:
38     JSPanHandler() = default;
~JSPanHandler()39     virtual ~JSPanHandler() {}
40 
41     virtual RefPtr<OHOS::Ace::SingleChild> CreateComponent(const JSCallbackInfo& args);
42 
43     static void JSBind(BindingTarget globalObj);
44 
45     void JsHandlerOnPan(PanEvent action, const JSCallbackInfo& args);
46     void JsHandlerOnStart(const JSCallbackInfo& args);
47     void JsHandlerOnUpdate(const JSCallbackInfo& args);
48     void JsHandlerOnEnd(const JSCallbackInfo& args);
49     void JsHandlerOnCancel(const JSCallbackInfo& args);
50 }; // JSPanHandler
51 
52 } // namespace OHOS::Ace::Framework
53 #endif // FOUNDATION_ACE_ACE_ENGINE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JSVIEW_JS_PAN_HANDLER_H
54