diff --git a/dom/include/dom/animation/animation_manager.h b/dom/include/dom/animation/animation_manager.h index af60274e547..7dad15666bd 100644 --- a/dom/include/dom/animation/animation_manager.h +++ b/dom/include/dom/animation/animation_manager.h @@ -114,9 +114,9 @@ class AnimationManager void ParseAnimation(const std::shared_ptr& node); void FetchAnimationsFromObject(const std::string& prop, const std::shared_ptr& value, - std::unordered_map& result); + std::unordered_map>& result); void FetchAnimationsFromArray(HippyValue& value, - std::unordered_map& result); + std::unordered_map>& result); void UpdateCubicBezierAnimation(double current, uint32_t related_animation_id, std::unordered_map>& update_node_map); @@ -140,7 +140,7 @@ class AnimationManager * the key of this map is dom node id and the value are all animation properties of the node * the key of props' map is animation id and value is ths name of prop. */ - std::unordered_map> node_animation_props_map_; + std::unordered_map>> node_animation_props_map_; uint64_t listener_id_; }; } // namespace dom diff --git a/dom/src/dom/animation/animation_manager.cc b/dom/src/dom/animation/animation_manager.cc index 72bd39c9b36..04aa8fdd332 100644 --- a/dom/src/dom/animation/animation_manager.cc +++ b/dom/src/dom/animation/animation_manager.cc @@ -79,7 +79,7 @@ void AnimationManager::ParseAnimation(const std::shared_ptr& node) { auto use_animation_it = dom_ext_map_->find(kUseAnimation); if (use_animation_it != dom_ext_map_->end()) { auto style_map_ = node->GetStyleMap(); - std::unordered_map animation_prop_map; + std::unordered_map> animation_prop_map; for (auto& style: *style_map_) { if (style.second->IsObject()) { FetchAnimationsFromObject(style.first, style.second, animation_prop_map); @@ -103,20 +103,26 @@ void AnimationManager::ParseAnimation(const std::shared_ptr& node) { auto& orig_animation_prop_map = node_animation_props_it->second; for (auto& pair: animation_prop_map) { auto animation_id = pair.first; - auto prop = pair.second; - if (orig_animation_prop_map[animation_id] == prop) { + auto props = pair.second; + if (orig_animation_prop_map[animation_id] == props) { auto animation = GetAnimation(animation_id); if (animation == nullptr) continue; - node->EmplaceStyleMap(prop, HippyValue(animation->GetCurrentValue())); + for (auto prop: props) { + node->EmplaceStyleMap(prop, HippyValue(animation->GetCurrentValue())); + } } else { orig_animation_prop_map[animation_id] = animation_prop_map[animation_id]; - EmplaceNodeProp(node, pair.second, animation_id); + for (auto prop: pair.second) { + EmplaceNodeProp(node, prop, animation_id); + } } } } else { node_animation_props_map_.insert({node_id, animation_prop_map}); for (const auto& pair: animation_prop_map) { - EmplaceNodeProp(node, pair.second, pair.first); + for (auto prop: pair.second) { + EmplaceNodeProp(node, prop, pair.first); + } } } } @@ -128,7 +134,7 @@ void AnimationManager::ParseAnimation(const std::shared_ptr& node) { void AnimationManager::FetchAnimationsFromObject( const std::string& prop, const std::shared_ptr& value, - std::unordered_map& result) { + std::unordered_map>& result) { if (value->IsObject()) { footstone::value::HippyValue::HippyValueObjectType obj; if (value->ToObject(obj)) { @@ -138,7 +144,14 @@ void AnimationManager::FetchAnimationsFromObject( if (id.IsNumber()) { double animation_id; if (id.ToDouble(animation_id)) { - result.insert({static_cast(animation_id), prop}); + auto it = result.find(static_cast(animation_id)); + if (it != result.end()) { + it->second.insert(prop); + } else { + std::set props; + props.insert(prop); + result.insert({static_cast(animation_id), props}); + } } } } else { @@ -154,7 +167,7 @@ void AnimationManager::FetchAnimationsFromObject( } void AnimationManager::FetchAnimationsFromArray(HippyValue& value, - std::unordered_map& result) { + std::unordered_map>& result) { if (value.IsArray()) { footstone::value::HippyValue::HippyValueArrayType array; if (value.ToArray(array)) { @@ -330,9 +343,12 @@ void AnimationManager::UpdateCubicBezierAnimation(double current, diff_value = *(dom_node->GetDiffStyle()); } HippyValue prop_value(current); - dom_node->EmplaceStyleMapAndGetDiff(prop_it->second, prop_value, diff_value); - FOOTSTONE_DLOG(INFO) << "animation related_animation_id = " << related_animation_id - << "node id = " << dom_node->GetId() << ", key = " << prop_it->second << ", value = " << prop_value; + for (auto prop: prop_it->second) { + dom_node->EmplaceStyleMapAndGetDiff(prop, prop_value, diff_value); + FOOTSTONE_DLOG(INFO) << "animation related_animation_id = " << related_animation_id + << "node id = " << dom_node->GetId() << ", key = " << prop << ", value = " << prop_value; + } + dom_node->SetDiffStyle(std::make_shared< std::unordered_map>>(std::move(diff_value))); diff --git a/driver/js/examples/hippy-react-demo/src/modules/Animation/index.jsx b/driver/js/examples/hippy-react-demo/src/modules/Animation/index.jsx index 0dd70d3a9c5..34f277d523c 100644 --- a/driver/js/examples/hippy-react-demo/src/modules/Animation/index.jsx +++ b/driver/js/examples/hippy-react-demo/src/modules/Animation/index.jsx @@ -559,7 +559,8 @@ export default class AnimationExample extends React.Component { }} style={[styles.square, { transform: [{ - scale: this.scaleAnimationSet, + scaleX: this.scaleAnimationSet, + scaleY: this.scaleAnimationSet, }], }]} />