1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.ViewPager = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _reactNative = _interopRequireWildcard(require("react-native"));
|
11 |
|
12 | var _utils = require("./utils");
|
13 |
|
14 | var _ViewPagerNative = require("./ViewPagerNative");
|
15 |
|
16 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
17 |
|
18 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19 |
|
20 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21 |
|
22 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
23 |
|
24 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | class ViewPager extends _react.default.Component {
|
68 | constructor(...args) {
|
69 | super(...args);
|
70 |
|
71 | _defineProperty(this, "isScrolling", false);
|
72 |
|
73 | _defineProperty(this, "viewPager", _react.default.createRef());
|
74 |
|
75 | _defineProperty(this, "getInnerViewNode", () => {
|
76 | return this.viewPager.current.getInnerViewNode();
|
77 | });
|
78 |
|
79 | _defineProperty(this, "_onPageScroll", e => {
|
80 | if (this.props.onPageScroll) {
|
81 | this.props.onPageScroll(e);
|
82 | }
|
83 |
|
84 |
|
85 | if (_reactNative.Platform.OS === 'android') {
|
86 | if (this.props.keyboardDismissMode === 'on-drag') {
|
87 | _reactNative.Keyboard.dismiss();
|
88 | }
|
89 | }
|
90 | });
|
91 |
|
92 | _defineProperty(this, "_onPageScrollStateChanged", e => {
|
93 | if (this.props.onPageScrollStateChanged) {
|
94 | this.props.onPageScrollStateChanged(e);
|
95 | }
|
96 |
|
97 | this.isScrolling = e.nativeEvent.pageScrollState === 'dragging';
|
98 | });
|
99 |
|
100 | _defineProperty(this, "_onPageSelected", e => {
|
101 | if (this.props.onPageSelected) {
|
102 | this.props.onPageSelected(e);
|
103 | }
|
104 | });
|
105 |
|
106 | _defineProperty(this, "setPage", selectedPage => {
|
107 | _reactNative.UIManager.dispatchViewManagerCommand(_reactNative.default.findNodeHandle(this), (0, _ViewPagerNative.getViewManagerConfig)().Commands.setPage, [selectedPage]);
|
108 | });
|
109 |
|
110 | _defineProperty(this, "setPageWithoutAnimation", selectedPage => {
|
111 | _reactNative.UIManager.dispatchViewManagerCommand(_reactNative.default.findNodeHandle(this), (0, _ViewPagerNative.getViewManagerConfig)().Commands.setPageWithoutAnimation, [selectedPage]);
|
112 | });
|
113 |
|
114 | _defineProperty(this, "setScrollEnabled", scrollEnabled => {
|
115 | _reactNative.UIManager.dispatchViewManagerCommand(_reactNative.default.findNodeHandle(this), (0, _ViewPagerNative.getViewManagerConfig)().Commands.setScrollEnabled, [scrollEnabled]);
|
116 | });
|
117 |
|
118 | _defineProperty(this, "_onMoveShouldSetResponderCapture", () => {
|
119 | return this.isScrolling;
|
120 | });
|
121 | }
|
122 |
|
123 | componentDidMount() {
|
124 |
|
125 | if (_reactNative.Platform.OS === 'android') {
|
126 | if (this.props.initialPage != null) {
|
127 | this.setPageWithoutAnimation(this.props.initialPage);
|
128 | }
|
129 | }
|
130 | }
|
131 |
|
132 | render() {
|
133 | return _react.default.createElement(_ViewPagerNative.ViewpagerViewManager, _extends({}, this.props, {
|
134 | ref: this.viewPager
|
135 |
|
136 | ,
|
137 | style: this.props.style,
|
138 | onPageScroll: this._onPageScroll,
|
139 | onPageScrollStateChanged: this._onPageScrollStateChanged,
|
140 | onPageSelected: this._onPageSelected,
|
141 | onMoveShouldSetResponderCapture: this._onMoveShouldSetResponderCapture,
|
142 | children: (0, _utils.childrenWithOverriddenStyle)(this.props.children)
|
143 | }));
|
144 | }
|
145 |
|
146 | }
|
147 |
|
148 | exports.ViewPager = ViewPager;
|
149 |
|
\ | No newline at end of file |