mirror of
https://github.com/status-im/react-native.git
synced 2025-01-19 14:02:10 +00:00
9b7f6abd87
Summary: `onLayout` event is fired when some layoutable node got inserted or updated (with changed layout) during commit phase. Reviewed By: fkgozali Differential Revision: D8119826 fbshipit-source-id: 831003c88fe5c4358a80328aa715be80e484b52e
43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ViewEventHandlers.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
#pragma mark - Accessibility
|
|
|
|
void ViewEventHandlers::onAccessibilityAction(const std::string &name) const {
|
|
dispatchEvent("accessibilityAction", folly::dynamic::object("action", name));
|
|
}
|
|
|
|
void ViewEventHandlers::onAccessibilityTap() const {
|
|
dispatchEvent("accessibilityTap");
|
|
}
|
|
|
|
void ViewEventHandlers::onAccessibilityMagicTap() const {
|
|
dispatchEvent("magicTap");
|
|
}
|
|
|
|
#pragma mark - Layout
|
|
|
|
void ViewEventHandlers::onLayout(const LayoutMetrics &layoutMetrics) const {
|
|
folly::dynamic payload = folly::dynamic::object();
|
|
auto &&frame = layoutMetrics.frame;
|
|
payload["layout"] = folly::dynamic::object
|
|
("x", frame.origin.x)
|
|
("y", frame.origin.y)
|
|
("width", frame.size.width)
|
|
("height", frame.size.height);
|
|
|
|
dispatchEvent("layout", payload);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|