Skip to content

Commit

Permalink
fix(dom): fix layout event trigger condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese authored and hippy-actions[bot] committed Sep 10, 2023
1 parent 615f229 commit a2d7214
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ LayoutResult DomNode::GetLayoutInfoFromRoot() {
void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode>>& changed_nodes) {
auto not_equal = std::not_equal_to<>();
bool changed = layout_node_->IsDirty() || layout_node_->HasNewLayout();
bool has_new_layout = layout_node_->HasNewLayout();
bool trigger_layout_event =
not_equal(layout_.left, layout_node_->GetLeft()) || not_equal(layout_.top, layout_node_->GetTop()) ||
not_equal(layout_.width, layout_node_->GetWidth()) || not_equal(layout_.height, layout_node_->GetHeight());

layout_.left = layout_node_->GetLeft();
layout_.top = layout_node_->GetTop();
Expand Down Expand Up @@ -365,7 +367,7 @@ void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode
layout_param[kLayoutHeightKey] = HippyValue(layout_.height);
HippyValueObjectType layout_obj;
layout_obj[kLayoutLayoutKey] = layout_param;
if (has_new_layout) {
if (trigger_layout_event) {
auto event = std::make_shared<DomEvent>(kLayoutEvent, weak_from_this(),
std::make_shared<HippyValue>(std::move(layout_obj)));
auto root = root_node_.lock();
Expand Down

0 comments on commit a2d7214

Please sign in to comment.