mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
Fabric: scrollview module was moved to components subdirectory
Summary: @public Trivial. We move all components into `/components/` subdirectory. Reviewed By: mdvacca Differential Revision: D8757013 fbshipit-source-id: fe3021862b3a4f8f0799b0dfaf6d3039f8582a7f
This commit is contained in:
committed by
Facebook Github Bot
parent
ecbe9acbaa
commit
b42e674c2f
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 "ScrollViewEventEmitter.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
void ScrollViewEventEmitter::onScroll(const ScrollViewMetrics &scrollViewMetrics) const {
|
||||
dispatchScrollViewEvent("scroll", scrollViewMetrics);
|
||||
}
|
||||
|
||||
void ScrollViewEventEmitter::onScrollBeginDrag(const ScrollViewMetrics &scrollViewMetrics) const {
|
||||
dispatchScrollViewEvent("scrollBeginDrag", scrollViewMetrics);
|
||||
}
|
||||
|
||||
void ScrollViewEventEmitter::onScrollEndDrag(const ScrollViewMetrics &scrollViewMetrics) const {
|
||||
dispatchScrollViewEvent("scrollEndDrag", scrollViewMetrics);
|
||||
}
|
||||
|
||||
void ScrollViewEventEmitter::onMomentumScrollBegin(const ScrollViewMetrics &scrollViewMetrics) const {
|
||||
dispatchScrollViewEvent("momentumScrollBegin", scrollViewMetrics);
|
||||
}
|
||||
|
||||
void ScrollViewEventEmitter::onMomentumScrollEnd(const ScrollViewMetrics &scrollViewMetrics) const {
|
||||
dispatchScrollViewEvent("momentumScrollEnd", scrollViewMetrics);
|
||||
}
|
||||
|
||||
void ScrollViewEventEmitter::dispatchScrollViewEvent(const std::string &name, const ScrollViewMetrics &scrollViewMetrics, const folly::dynamic &payload) const {
|
||||
folly::dynamic compoundPayload = folly::dynamic::object();
|
||||
|
||||
compoundPayload["contentOffset"] = folly::dynamic::object
|
||||
("x", scrollViewMetrics.contentOffset.x)
|
||||
("y", scrollViewMetrics.contentOffset.y);
|
||||
|
||||
compoundPayload["contentInset"] = folly::dynamic::object
|
||||
("top", scrollViewMetrics.contentInset.top)
|
||||
("left", scrollViewMetrics.contentInset.left)
|
||||
("bottom", scrollViewMetrics.contentInset.bottom)
|
||||
("right", scrollViewMetrics.contentInset.right);
|
||||
|
||||
compoundPayload["contentSize"] = folly::dynamic::object
|
||||
("width", scrollViewMetrics.contentSize.width)
|
||||
("height", scrollViewMetrics.contentSize.height);
|
||||
|
||||
compoundPayload["layoutMeasurement"] = folly::dynamic::object
|
||||
("width", scrollViewMetrics.containerSize.width)
|
||||
("height", scrollViewMetrics.containerSize.height);
|
||||
|
||||
compoundPayload["zoomScale"] = scrollViewMetrics.zoomScale;
|
||||
|
||||
if (!payload.isNull()) {
|
||||
compoundPayload.merge_patch(payload);
|
||||
}
|
||||
|
||||
dispatchEvent(name, compoundPayload);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
Reference in New Issue
Block a user