1 /* 2 * Copyright (c) 2023 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 "bridge/declarative_frontend/jsview/js_scrollable_base.h" 17 #include "core/components_ng/pattern/scrollable/scrollable_model_ng.h" 18 19 namespace OHOS::Ace::Framework { JSFlingSpeedLimit(const JSCallbackInfo & info)20void JSScrollableBase::JSFlingSpeedLimit(const JSCallbackInfo& info) 21 { 22 double max = -1.0; 23 if (!JSViewAbstract::ParseJsDouble(info[0], max)) { 24 return; 25 } 26 double density = PipelineBase::GetCurrentDensity(); 27 NG::ScrollableModelNG::SetMaxFlingSpeed(max * density); 28 } 29 JSBind(BindingTarget globalObj)30void JSScrollableBase::JSBind(BindingTarget globalObj) 31 { 32 MethodOptions opt = MethodOptions::NONE; 33 JSClass<JSScrollableBase>::Declare("JSContainerBase"); 34 JSClass<JSScrollableBase>::StaticMethod("flingSpeedLimit", &JSScrollableBase::JSFlingSpeedLimit, opt); 35 JSClass<JSScrollableBase>::InheritAndBind<JSContainerBase>(globalObj); 36 } 37 } // namespace OHOS::Ace::Framework 38