Skip to content

sig_dev合入sig #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions lib/NestedScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ const {
requireNativeComponent,
} = ReactNative;

const AnimatedImplementation = require('react-native/Libraries/Animated/src/AnimatedImplementation');
const ScrollResponder = require('react-native/Libraries/Components/ScrollResponder');
const AnimatedImplementation = require('react-native/Libraries/Animated/AnimatedImplementation');
const ScrollViewStickyHeader = require('react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader');

const createReactClass = require('create-react-class');
const dismissKeyboard = require('react-native/Libraries/Utilities/dismissKeyboard');
const flattenStyle = require('react-native/Libraries/StyleSheet/flattenStyle');
Expand All @@ -34,14 +32,12 @@ const processDecelerationRate = require('react-native/Libraries/Components/Scrol
const warning = require('fbjs/lib/warning');
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');

import type {PressEvent} from 'CoreEventTypes';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';
import type {EdgeInsetsProp} from 'react-native/Libraries/StyleSheet/EdgeInsetsPropType';
import type {NativeMethodsMixinType} from 'ReactNativeTypes';
import type {ViewStyleProp} from 'StyleSheet';
import type {ViewProps} from 'ViewPropTypes';
import type {PointProp} from 'PointPropType';

import type {ColorValue} from 'StyleSheetTypes';
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
import type {PointProp} from 'react-native/Libraries/StyleSheet/PointPropType';
import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet';

let AndroidScrollView;
let AndroidHorizontalScrollContentView;
Expand Down Expand Up @@ -553,8 +549,8 @@ type State = {|
|};
function createScrollResponder(
node: React.ElementRef<typeof ScrollView>,
): typeof ScrollResponder.Mixin {
const scrollResponder = {...ScrollResponder.Mixin};
): typeof View.props.onResponderGrant {
const scrollResponder = {...View.props.onResponderGrant};
for (const key in scrollResponder) {
if (typeof scrollResponder[key] === 'function') {
scrollResponder[key] = scrollResponder[key].bind(node);
Expand Down Expand Up @@ -611,7 +607,7 @@ class ScrollView extends React.Component<Props, State> {
* component instance.
* 3. Continued...
*/
_scrollResponder: typeof ScrollResponder.Mixin = createScrollResponder(this);
_scrollResponder: typeof View.props.onResponderGrant = createScrollResponder(this);
constructor(props: Props) {
super(props);
/**
Expand All @@ -625,13 +621,13 @@ class ScrollView extends React.Component<Props, State> {
* Since the object returned from that method is the ScrollView instance,
* we need to bind all mixin methods to the ScrollView instance.
*/
for (const key in ScrollResponder.Mixin) {
for (const key in View.props.onResponderGrant) {
if (
typeof ScrollResponder.Mixin[key] === 'function' &&
typeof View.props.onResponderGrant[key] === 'function' &&
key.startsWith('scrollResponder')
) {
// $FlowFixMe - dynamically adding properties to a class
(this: any)[key] = ScrollResponder.Mixin[key].bind(this);
(this: any)[key] = View.props.onResponderGrant[key].bind(this);
}
}
/**
Expand All @@ -640,11 +636,11 @@ class ScrollView extends React.Component<Props, State> {
* 4. Mixins can initialize properties and use properties on the component
* instance.
*/
Object.keys(ScrollResponder.Mixin)
.filter(key => typeof ScrollResponder.Mixin[key] !== 'function')
Object.keys(View.props.onResponderGrant)
.filter(key => typeof View.props.onResponderGrant[key] !== 'function')
.forEach(key => {
// $FlowFixMe - dynamically adding properties to a class
(this: any)[key] = ScrollResponder.Mixin[key];
(this: any)[key] = View.props.onResponderGrant[key];
});
}

Expand All @@ -658,7 +654,7 @@ class ScrollView extends React.Component<Props, State> {

state = {
layoutHeight: null,
...ScrollResponder.Mixin.scrollResponderMixinGetInitialState(),
...View.props.onResponderGrant.scrollResponderMixinGetInitialState(),
};

UNSAFE_componentWillMount() {
Expand Down Expand Up @@ -713,7 +709,7 @@ class ScrollView extends React.Component<Props, State> {
* to the underlying scroll responder's methods.
*/
getScrollResponder(): ScrollResponderType {
// $FlowFixMe - overriding type to include ScrollResponder.Mixin
// $FlowFixMe - overriding type to include View.props.onResponderGrant
return ((this: any): ScrollResponderType);
}

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-nested-scroll-view",
"version": "9.0.0",
"version": "9.0.0-0.0.1",
"description": "React Native ScrollView replacement with NestedScrollView",
"main": "index.js",
"keywords": [
Expand All @@ -9,5 +9,8 @@
"nested-scroll"
],
"author": "Cesar Augusto <cesardeazevedo@outlook.com>",
"license": "MIT"
"license": "MIT",
"dependencies": {
"fbjs": "^3.0.5"
}
}