mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
修复拖拽时聚拢动效散开的问题
Signed-off-by: zenix_zxy <zhengxingyou1@huawei.com> Change-Id: Id040660b3f557b994b20ba44cca6d988139c71d4
This commit is contained in:
parent
dd7bbfa77a
commit
11fd643c60
@ -420,6 +420,7 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co
|
||||
|
||||
auto actionEnd = [weak = WeakClaim(this)](GestureEvent& info) {
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "Trigger drag action end.");
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck();
|
||||
CHECK_NULL_VOID(pipelineContext);
|
||||
auto dragDropManager = pipelineContext->GetDragDropManager();
|
||||
|
@ -483,6 +483,7 @@ void GestureEventHub::HandleOnDragStart(const GestureEvent& info)
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "Drag stop because user release mouse button");
|
||||
return;
|
||||
}
|
||||
DragDropGlobalController::GetInstance().UpdateDragDropInitiatingStatus(frameNode, DragDropInitiatingStatus::MOVING);
|
||||
if (info.GetInputEventType() == InputEventType::MOUSE_BUTTON) {
|
||||
SetMouseDragMonitorState(true);
|
||||
}
|
||||
@ -854,6 +855,8 @@ void GestureEventHub::OnDragStart(const GestureEvent& info, const RefPtr<Pipelin
|
||||
},
|
||||
option.GetOnFinishEvent());
|
||||
}
|
||||
} else {
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
}
|
||||
if (info.GetInputEventType() == InputEventType::MOUSE_BUTTON && IsNeedSwitchToSubWindow()) {
|
||||
ret = RegisterCoordinationListener(pipeline);
|
||||
@ -1013,6 +1016,7 @@ OnDragCallbackCore GestureEventHub::GetDragCallback(const RefPtr<PipelineBase>&
|
||||
TAG_LOGE(AceLogTag::ACE_DRAG, "handle drag end callback, can not get container.");
|
||||
return;
|
||||
}
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
TAG_LOGI(
|
||||
AceLogTag::ACE_DRAG, "handle drag end callback, windowId is %{public}d.", container->GetWindowId());
|
||||
dragDropManager->ResetDragEndOption(notifyMessage, dragEvent, id);
|
||||
@ -1192,6 +1196,7 @@ int32_t GestureEventHub::GetSelectItemSize()
|
||||
|
||||
void GestureEventHub::FireCustomerOnDragEnd(const RefPtr<PipelineBase>& context, const WeakPtr<EventHub>& hub)
|
||||
{
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
auto eventHub = hub.Upgrade();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
auto pipeline = AceType::DynamicCast<PipelineContext>(context);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include <csignal>
|
||||
#include <thread>
|
||||
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
|
||||
DragDropGlobalController::~DragDropGlobalController() {}
|
||||
@ -40,5 +42,26 @@ bool DragDropGlobalController::IsMenuShowing() const
|
||||
return isContextMenuShowing_;
|
||||
}
|
||||
|
||||
void DragDropGlobalController::UpdateDragDropInitiatingStatus(const RefPtr<FrameNode>& frameNode,
|
||||
const DragDropInitiatingStatus& dragStatus)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
if (dragStatus == DragDropInitiatingStatus::MOVING) {
|
||||
currentDragNode_ = frameNode;
|
||||
}
|
||||
}
|
||||
|
||||
bool DragDropGlobalController::IsInMoving() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||
return currentDragNode_;
|
||||
}
|
||||
|
||||
void DragDropGlobalController::ResetDragDropInitiatingStatus()
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||
currentDragNode_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -23,11 +23,19 @@
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/memory/referenced.h"
|
||||
#include "base/utils/macros.h"
|
||||
#include "base/utils/noncopyable.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
|
||||
class FrameNode;
|
||||
enum class DragDropInitiatingStatus : int32_t {
|
||||
IDLE = 0,
|
||||
READY,
|
||||
PRESS,
|
||||
LIFTING,
|
||||
MOVING,
|
||||
};
|
||||
class ACE_FORCE_EXPORT DragDropGlobalController {
|
||||
public:
|
||||
~DragDropGlobalController();
|
||||
@ -36,6 +44,10 @@ public:
|
||||
|
||||
void UpdateMenuShowingStatus(bool isShowing);
|
||||
bool IsMenuShowing() const;
|
||||
bool IsInMoving() const;
|
||||
void ResetDragDropInitiatingStatus();
|
||||
void UpdateDragDropInitiatingStatus(const RefPtr<FrameNode>& frameNode,
|
||||
const DragDropInitiatingStatus& dragStatus);
|
||||
|
||||
private:
|
||||
DragDropGlobalController() = default;
|
||||
@ -44,6 +56,7 @@ private:
|
||||
// this is the real time menu show status flag, need to change to pair with menu target node in future
|
||||
bool isContextMenuShowing_ = false;
|
||||
ACE_DISALLOW_COPY_AND_MOVE(DragDropGlobalController);
|
||||
RefPtr<FrameNode> currentDragNode_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
#include "core/components_ng/manager/drag_drop/drag_drop_behavior_reporter/drag_drop_behavior_reporter.h"
|
||||
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
|
||||
#include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h"
|
||||
#include "core/components_ng/pattern/grid/grid_event_hub.h"
|
||||
#include "core/components_ng/pattern/list/list_event_hub.h"
|
||||
#include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
|
||||
@ -639,6 +640,7 @@ void DragDropManager::TransDragWindowToDragFwk(int32_t windowContainerId)
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "TransDragWindowToDragFwk is %{public}d", isDragFwkShow_);
|
||||
ACE_SCOPED_TRACE("drag: set drag window visible by transfer");
|
||||
InteractionInterface::GetInstance()->SetDragWindowVisible(true);
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
isDragFwkShow_ = true;
|
||||
auto overlayManager = GetDragAnimationOverlayManager(windowContainerId);
|
||||
CHECK_NULL_VOID(overlayManager);
|
||||
@ -827,6 +829,7 @@ void DragDropManager::DoDragReset()
|
||||
isDragWithContextMenu_ = false;
|
||||
dampingOverflowCount_ = 0;
|
||||
isDragNodeNeedClean_ = false;
|
||||
DragDropGlobalController::GetInstance().ResetDragDropInitiatingStatus();
|
||||
}
|
||||
|
||||
void DragDropManager::ResetDraggingStatus(const TouchEvent& touchPoint)
|
||||
|
@ -6472,7 +6472,7 @@ void OverlayManager::RemoveGatherNode()
|
||||
|
||||
void OverlayManager::RemoveGatherNodeWithAnimation()
|
||||
{
|
||||
if (!hasGatherNode_) {
|
||||
if (!hasGatherNode_ || DragDropGlobalController::GetInstance().IsInMoving()) {
|
||||
return;
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_DRAG, "Remove gather node with animation");
|
||||
|
Loading…
Reference in New Issue
Block a user