1 /* 2 * Copyright (c) 2021-2022 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_FRAMEWORKS_CORE_ANIMATION_BILATERAL_SPRING_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_BILATERAL_SPRING_NODE_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/animation/bilateral_spring_adapter.h" 21 #include "core/animation/simple_spring_node.h" 22 23 namespace OHOS::Ace { 24 25 class BilateralSpringNode : public SimpleSpringNode { 26 DECLARE_ACE_TYPE(BilateralSpringNode, SimpleSpringNode); 27 28 public: BilateralSpringNode(const WeakPtr<PipelineBase> & context,int32_t index,double value)29 BilateralSpringNode(const WeakPtr<PipelineBase>& context, int32_t index, double value) 30 : SimpleSpringNode(context, index, value) {} 31 ~BilateralSpringNode() override = default; 32 33 void NotifyNext(double endValue, double initVelocity) override; 34 35 void SetDeltaValue(double delta) override; 36 37 protected: 38 void OnAnimation() override; 39 40 private: 41 void DoCollision(); 42 43 void FixValue(double springValue); 44 45 void SimpleFixedValue(double springValue); 46 47 bool switchCollision_ = true; 48 bool fixMode_ = false; 49 double lastTheoryValue_ = 0.0; 50 }; 51 52 } // namespace OHOS::Ace 53 54 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_ANIMATION_BILATERAL_SPRING_NODE_H 55