extends Component
{
6 | public childrenList: ReactNode[]
7 |
8 | public childrenSize: number
9 |
10 | public _childrenList: ReactNode[]
11 |
12 | public _childrenSize: number
13 |
14 | getChildren(
15 | children: ReactNode[] = get(this.props, 'children'),
16 | handleFunc: (child: ReactNode) => ReactNode = (child) => child
17 | ) {
18 | return React.Children.map(children, handleFunc)
19 | }
20 |
21 | setChildrenAttr() {
22 | this.childrenList = this.getChildren()
23 | this.childrenSize = size(this.childrenList)
24 | // 记录初次children值,childrenList之后可能会改变
25 | this._childrenList = this.childrenList
26 | this._childrenSize = this.childrenSize
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/android-old-version/rnscrollview-0.47/RNScrollViewPackage.java:
--------------------------------------------------------------------------------
1 | package com.taumu.rnscrollview;
2 |
3 | import com.facebook.react.ReactPackage;
4 | import com.facebook.react.bridge.JavaScriptModule;
5 | import com.facebook.react.bridge.NativeModule;
6 | import com.facebook.react.bridge.ReactApplicationContext;
7 | import com.facebook.react.uimanager.ViewManager;
8 |
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | public class RNScrollViewPackage implements ReactPackage {
13 |
14 | @Override
15 | public List extends Common<
8 | P,
9 | S
10 | > {
11 | protected _viewPagedProps?: PanResponderCallbacks
12 |
13 | public isBorder: boolean
14 |
15 | public isResponder: boolean
16 |
17 | public startX: number
18 |
19 | public startY: number
20 |
21 | public isTouchMove: boolean
22 |
23 | public hasScrollViewPages: number[]
24 |
25 | public borderDirection: DirectionValues
26 |
27 | public abstract setBorderValue(
28 | startValue: number,
29 | endValue: number,
30 | maxValue: number
31 | ): void
32 |
33 | public abstract _TouchStartEvent(x: number, y: number): void
34 |
35 | public abstract _TouchMoveEvent(
36 | x: number,
37 | y: number,
38 | sizeValue: number,
39 | layoutValue: number
40 | ): void
41 |
42 | public abstract _setScrollViewRef(ref: any): void
43 | }
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 TaumuLu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/abstract-class/view-paged-abstract.tsx:
--------------------------------------------------------------------------------
1 | import { PanResponderInstance, GestureResponderHandlers } from 'react-native'
2 | import { IProps } from '../prop-types'
3 | import { IViewPagedState } from '../types'
4 | import Common from './common'
5 |
6 | export default abstract class ViewPaged<
7 | P = IProps,
8 | S = IViewPagedState
9 | > extends Common {
10 | protected _panResponder?: PanResponderInstance
11 |
12 | protected _AnimatedViewProps?:
13 | | GestureResponderHandlers
14 | | {
15 | onTouchStart: (e: any) => void
16 | ref: (ref: any) => void
17 | // onTouchMove: this._onTouchMove,
18 | onTouchEnd: (e: any) => void
19 | }
20 |
21 | public _isScrollView: boolean
22 |
23 | public _initialPage: number
24 |
25 | public _posPage: number
26 |
27 | public abstract _renderPage(): JSX.Element[]
28 |
29 | public abstract _onChange(): void
30 |
31 | public abstract _TouchStartEvent(): void
32 |
33 | public abstract _TouchMoveEvent(touchState: any): void
34 |
35 | public abstract _TouchEndEvent(touchState: any): void
36 |
37 | public abstract _runMeasurements(width: number, height: number): void
38 | }
39 |
--------------------------------------------------------------------------------
/src/components/index.web.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import Animated from 'animated/lib/targets/react-dom'
3 | import Easing from 'animated/lib/Easing'
4 |
5 | export * from './common'
6 |
7 | const AnimatedView = Animated.div
8 |
9 | const View = (props) => {
10 | const { onLayout, ...otherProps } = props
11 | const extraProps: { ref?: any } = {}
12 | if (onLayout) {
13 | extraProps.ref = onLayout
14 | }
15 |
16 | return
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | package com.taumu.rnscrollview;
11 |
12 | import javax.annotation.Nullable;
13 |
14 | import java.util.Map;
15 |
16 | import com.facebook.react.bridge.ReadableArray;
17 | import com.facebook.react.views.scroll.ReactScrollViewCommandHelper;
18 |
19 | public class RNScrollViewCommandHelper extends ReactScrollViewCommandHelper {
20 |
21 | public static final int COMMAND_SET_SCROLL_ENABLED = 10;
22 |
23 | public interface ScrollCommandHandler