/* * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. * Description: TjdZoomTransition * Author: * Create: 2023-11 */ #include "TjdZoomTransition.h" #include "TransitionManager.h" #include "animator/easing_equation.h" namespace OHOS { static constexpr int16_t RANGE = 1000; REGIST_TRANSITION(TransitionType::TJD_TRANSITION_ZOOM, TjdZoomTransition, 250, false, true); void TjdZoomTransition::OnTransitionStart(UIViewGroup *current, UIImageView *target) { current_ = current; target_ = target; current_->SetVisible(false); }; void TjdZoomTransition::TransitionAlg(uint32_t time) { if ((current_ == nullptr) || (target_ == nullptr)) { return; } float scale = EasingEquation::QuadEaseIn(0, RANGE, time, duration_) / static_cast(RANGE); uint8_t opa = scale * OPA_OPAQUE; int16_t centerX = target_->GetX() + target_->GetWidth() / 2; // 2: half of width int16_t centerY = target_->GetY() + target_->GetHeight() / 2; // 2: half of height target_->SetVisible(true); target_->Scale(Vector2{scale, scale}, Vector2{centerX, centerY}); target_->SetOpaScale(opa); } } // namespace OHOS