Files
react-native/packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h
T
Samuel Susla c574ca59dc refactor metrics for ScrollViewEventEmitter (#43532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43532

changelog: [internal]

- use designated initializers.
- make ScrollViewMetrics a struct.
- move ScrollViewMetrics inside of ScrollViewEventEmitter.

This is to be more consistent with other event emitters.

Reviewed By: rubennorte

Differential Revision: D54896331

fbshipit-source-id: 01aecd1835b23bdaccff1355d33eb7b4c5ba8d92
2024-03-21 08:11:49 -07:00

44 lines
1.2 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <memory>
#include <folly/dynamic.h>
#include <react/renderer/components/view/ViewEventEmitter.h>
#include <react/renderer/core/EventEmitter.h>
namespace facebook::react {
class ScrollViewEventEmitter : public ViewEventEmitter {
public:
using ViewEventEmitter::ViewEventEmitter;
struct Metrics {
Size contentSize;
Point contentOffset;
EdgeInsets contentInset;
Size containerSize;
Float zoomScale{};
};
void onScroll(const Metrics& scrollViewMetrics) const;
void onScrollBeginDrag(const Metrics& scrollViewMetrics) const;
void onScrollEndDrag(const Metrics& scrollViewMetrics) const;
void onMomentumScrollBegin(const Metrics& scrollViewMetrics) const;
void onMomentumScrollEnd(const Metrics& scrollViewMetrics) const;
void onScrollToTop(const Metrics& scrollViewMetrics) const;
private:
void dispatchScrollViewEvent(
std::string name,
const Metrics& scrollViewMetrics) const;
};
} // namespace facebook::react