38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
/*
|
|
* 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<float>(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<float>{scale, scale}, Vector2<float>{centerX, centerY});
|
|
target_->SetOpaScale(opa);
|
|
}
|
|
} // namespace OHOS
|