1371 lines
43 KiB
React
1371 lines
43 KiB
React
// Metro module 13225 (f13226).
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import _possibleConstructorReturn from "./_possibleConstructorReturn";
|
|
import _getPrototypeOf from "./_getPrototypeOf";
|
|
import _inherits from "./_inherits";
|
|
import * as _Module19 from "react";
|
|
import * as _Module17 from "react-native";
|
|
import { ScrollView, Platform, Easing, View } from "react-native";
|
|
import { ViewPropTypes } from "./Module8148";
|
|
import shallowCompare from "./shallowCompare";
|
|
import { stackScrollInterpolator, tinderScrollInterpolator, defaultScrollInterpolator, tinderAnimatedStyles, stackAnimatedStyles, shiftAnimatedStyles, defaultAnimatedStyles } from "./Module13228";
|
|
import Module4014 from "./Module4014";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
let Component2, c9172_13, isRTL;
|
|
let env9172 = {};
|
|
env9172[11] = function _isNativeReflectConstruct() {
|
|
let c20422_0;
|
|
try {
|
|
c20422_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
} catch ($e) {}
|
|
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
|
|
return !!c20422_0;
|
|
};
|
|
env9172[11] = _isNativeReflectConstruct2;
|
|
return _isNativeReflectConstruct2();
|
|
};
|
|
const { Animated: Animated2, FlatList, I18nManager } = _Module17;
|
|
Platform;
|
|
Component2 = FlatList ? Animated2.createAnimatedComponent(FlatList) : null;
|
|
c9172_13 = Animated2.createAnimatedComponent(ScrollView);
|
|
isRTL = I18nManager.isRTL;
|
|
const Carousel = function Carousel(a0) {
|
|
_classCallCheck(this, Carousel);
|
|
const r13 = [a0];
|
|
const r12 = _getPrototypeOf(Carousel);
|
|
const r24 = _possibleConstructorReturn(this, (0, env9172[11])() ? Reflect.construct(r12, r13, _getPrototypeOf(this).constructor) : r12.apply(this, r13));
|
|
r24.state = {
|
|
hideCarousel: true,
|
|
interpolators: []
|
|
};
|
|
const _activeItem = r24._getFirstItem(a0.firstItem);
|
|
r24._activeItem = _activeItem;
|
|
r24._previousActiveItem = _activeItem;
|
|
r24._previousFirstItem = _activeItem;
|
|
r24._previousItemsLength = _activeItem;
|
|
r24._mounted = false;
|
|
r24._positions = [];
|
|
r24._currentContentOffset = 0;
|
|
r24._canFireBeforeCallback = false;
|
|
r24._canFireCallback = false;
|
|
r24._scrollOffsetRef = null;
|
|
r24._onScrollTriggered = true;
|
|
r24._lastScrollDate = 0;
|
|
r24._scrollEnabled = a0.scrollEnabled !== false;
|
|
r24._initPositionsAndInterpolators = r24._initPositionsAndInterpolators.bind(r24);
|
|
r24._renderItem = r24._renderItem.bind(r24);
|
|
r24._onSnap = r24._onSnap.bind(r24);
|
|
r24._onLayout = r24._onLayout.bind(r24);
|
|
r24._onScroll = r24._onScroll.bind(r24);
|
|
r24._onScrollBeginDrag = a0.enableSnap ? r24._onScrollBeginDrag.bind(r24) : void 0;
|
|
r24._onScrollEnd = a0.enableSnap ? r24._onScrollEnd.bind(r24) : a0.autoplay ? r24._onScrollEnd.bind(r24) : void 0;
|
|
r24._onScrollEndDrag = a0.enableMomentum ? void 0 : r24._onScrollEndDrag.bind(r24);
|
|
r24._onMomentumScrollEnd = a0.enableMomentum ? r24._onMomentumScrollEnd.bind(r24) : void 0;
|
|
r24._onTouchStart = r24._onTouchStart.bind(r24);
|
|
r24._onTouchEnd = r24._onTouchEnd.bind(r24);
|
|
r24._onTouchRelease = r24._onTouchRelease.bind(r24);
|
|
r24._getKeyExtractor = r24._getKeyExtractor.bind(r24);
|
|
r24._setScrollHandler(a0);
|
|
r24._ignoreNextMomentum = false;
|
|
if (!ViewPropTypes) {
|
|
console.warn("react-native-snap-carousel: It is recommended to use at least version 0.44 of React Native with the plugin");
|
|
}
|
|
if (!(a0.vertical || a0.sliderWidth && a0.itemWidth)) {
|
|
console.error("react-native-snap-carousel: You need to specify both `sliderWidth` and `itemWidth` for horizontal carousels");
|
|
}
|
|
const vertical = a0.vertical;
|
|
if (!(vertical ? a0.sliderHeight && a0.itemHeight : !vertical)) {
|
|
console.error("react-native-snap-carousel: You need to specify both `sliderHeight` and `itemHeight` for vertical carousels");
|
|
}
|
|
if (a0.apparitionDelay && !a0.useScrollView) {
|
|
console.warn("react-native-snap-carousel: Using `apparitionDelay` on Android is not recommended since it can lead to rendering issues");
|
|
}
|
|
if (a0.customAnimationType || a0.customAnimationOptions) {
|
|
console.warn("react-native-snap-carousel: Props `customAnimationType` and `customAnimationOptions` have been renamed to `activeAnimationType` and `activeAnimationOptions`");
|
|
}
|
|
if (a0.onScrollViewScroll) {
|
|
console.error("react-native-snap-carousel: Prop `onScrollViewScroll` has been removed. Use `onScroll` instead");
|
|
}
|
|
return r24;
|
|
};
|
|
_inherits(Carousel, _Module19.Component);
|
|
const r184 = _createClass(Carousel, [{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
const props2 = this.props;
|
|
const { apparitionDelay, autoplay } = props2;
|
|
let c27419_3 = this._getFirstItem(props2.firstItem);
|
|
const apparitionCallback2 = () => {};
|
|
this._mounted = true;
|
|
this._initPositionsAndInterpolators();
|
|
requestAnimationFrame(() => {
|
|
if (this._mounted) {
|
|
this._snapToItem(c27419_3, false, false, true, false);
|
|
this._hackActiveSlideAnimation(c27419_3, "start", true);
|
|
if (apparitionDelay) {
|
|
this._apparitionTimeout = setTimeout(() => {
|
|
this.setState({
|
|
hideCarousel: false
|
|
});
|
|
if (autoplay) {
|
|
this.startAutoplay();
|
|
}
|
|
}, apparitionDelay);
|
|
} else {
|
|
this.setState({
|
|
hideCarousel: false
|
|
});
|
|
if (autoplay) {
|
|
this.startAutoplay();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "shouldComponentUpdate",
|
|
value: function shouldComponentUpdate(a0, a1) {
|
|
return this.props.shouldOptimizeUpdates === false || shallowCompare(this, a0, a1);
|
|
}
|
|
}, {
|
|
key: "componentDidUpdate",
|
|
value: function componentDidUpdate(a0) {
|
|
const interpolators = this.state.interpolators;
|
|
const props2 = this.props;
|
|
const { firstItem, itemHeight: itemHeight2, itemWidth, scrollEnabled, sliderHeight, sliderWidth } = props2;
|
|
const _previousItemsLength = this._getCustomDataLength(this.props);
|
|
if (_previousItemsLength) {
|
|
const _activeItem = this._getFirstItem(firstItem, this.props);
|
|
let _activeItem2 = this._activeItem ? this._activeItem : this._activeItem === 0 ? this._activeItem : _activeItem;
|
|
let r31 = sliderWidth && sliderWidth !== a0.sliderWidth;
|
|
const r32 = sliderHeight && sliderHeight !== a0.sliderHeight;
|
|
const r34 = itemWidth && itemWidth !== a0.itemWidth;
|
|
const r36 = itemHeight2 && itemHeight2 !== a0.itemHeight;
|
|
if (_activeItem2 > _previousItemsLength - 1) {
|
|
_activeItem2 = _previousItemsLength - 1;
|
|
}
|
|
if (scrollEnabled !== a0.scrollEnabled) {
|
|
this._setScrollEnabled(scrollEnabled);
|
|
}
|
|
L35: {
|
|
if (interpolators.length === _previousItemsLength && (!r31 && (!r32 && (!r34 && !r36)))) {
|
|
if (!(_activeItem !== this._previousFirstItem && _activeItem !== this._activeItem)) {
|
|
break L35;
|
|
}
|
|
this._activeItem = _activeItem;
|
|
this._previousFirstItem = _activeItem;
|
|
this._snapToItem(_activeItem, false, true, false, false);
|
|
} else {
|
|
this._activeItem = _activeItem2;
|
|
this._previousItemsLength = _previousItemsLength;
|
|
this._initPositionsAndInterpolators(this.props);
|
|
if (this._previousItemsLength > _previousItemsLength) {
|
|
this._hackActiveSlideAnimation(_activeItem2, null, true);
|
|
}
|
|
if (!r31) {
|
|
r31 = r32;
|
|
}
|
|
if (!r31) {
|
|
r31 = r34;
|
|
}
|
|
if (!r31) {
|
|
r31 = r36;
|
|
}
|
|
if (r31) {
|
|
this._snapToItem(_activeItem2, false, false, false, false);
|
|
}
|
|
}
|
|
}
|
|
if (this.props.onScroll !== a0.onScroll) {
|
|
this._setScrollHandler(this.props);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
this._mounted = false;
|
|
this.stopAutoplay();
|
|
clearTimeout(this._apparitionTimeout);
|
|
clearTimeout(this._hackSlideAnimationTimeout);
|
|
clearTimeout(this._enableAutoplayTimeout);
|
|
clearTimeout(this._autoplayTimeout);
|
|
clearTimeout(this._snapNoMomentumTimeout);
|
|
clearTimeout(this._edgeItemTimeout);
|
|
clearTimeout(this._lockScrollTimeout);
|
|
}
|
|
}, {
|
|
key: "realIndex",
|
|
get: function get() {
|
|
return this._activeItem;
|
|
}
|
|
}, {
|
|
key: "currentIndex",
|
|
get: function get() {
|
|
return this._getDataIndex(this._activeItem);
|
|
}
|
|
}, {
|
|
key: "currentScrollPosition",
|
|
get: function get() {
|
|
return this._currentContentOffset;
|
|
}
|
|
}, {
|
|
key: "_setScrollHandler",
|
|
value: function _setScrollHandler(a0) {
|
|
let r23;
|
|
const r7 = {
|
|
listener: this._onScroll,
|
|
useNativeDriver: true
|
|
};
|
|
this._scrollPos = new _Module17.Animated.Value(0);
|
|
const vertical = a0.vertical;
|
|
const r10 = {
|
|
nativeEvent: null
|
|
};
|
|
const nativeEvent = {
|
|
contentOffset: null
|
|
};
|
|
if (vertical) {
|
|
nativeEvent.contentOffset = {
|
|
y: this._scrollPos
|
|
};
|
|
r10.nativeEvent = nativeEvent;
|
|
r23 = [r10];
|
|
} else {
|
|
nativeEvent.contentOffset = {
|
|
x: this._scrollPos
|
|
};
|
|
r10.nativeEvent = nativeEvent;
|
|
r23 = [r10];
|
|
}
|
|
if (a0.onScroll && Array.isArray(a0.onScroll._argMapping)) {
|
|
r23.pop();
|
|
const [r39] = a0.onScroll._argMapping;
|
|
if (r39 && r39.nativeEvent && r39.nativeEvent.contentOffset) {
|
|
this._scrollPos = r39.nativeEvent.contentOffset.x || r39.nativeEvent.contentOffset.y || this._scrollPos;
|
|
}
|
|
r23.push.apply(r23, [...a0.onScroll._argMapping]);
|
|
}
|
|
this._onScrollHandler = _Module17.Animated.event(r23, r7);
|
|
}
|
|
}, {
|
|
key: "_needsScrollView",
|
|
value: function _needsScrollView() {
|
|
return this.props.useScrollView || !Component2 || this._shouldUseStackLayout() || this._shouldUseTinderLayout();
|
|
}
|
|
}, {
|
|
key: "_needsRTLAdaptations",
|
|
value: function _needsRTLAdaptations() {
|
|
const vertical = this.props.vertical;
|
|
return isRTL && !vertical;
|
|
}
|
|
}, {
|
|
key: "_canLockScroll",
|
|
value: function _canLockScroll() {
|
|
const props2 = this.props;
|
|
let scrollEnabled = props2.scrollEnabled;
|
|
const { enableMomentum, lockScrollWhileSnapping } = props2;
|
|
if (scrollEnabled) {
|
|
scrollEnabled = !enableMomentum;
|
|
}
|
|
if (scrollEnabled) {
|
|
scrollEnabled = lockScrollWhileSnapping;
|
|
}
|
|
return scrollEnabled;
|
|
}
|
|
}, {
|
|
key: "_enableLoop",
|
|
value: function _enableLoop() {
|
|
const props2 = this.props;
|
|
const data = props2.data;
|
|
let enableSnap = props2.enableSnap;
|
|
const loop = props2.loop;
|
|
if (enableSnap) {
|
|
enableSnap = loop;
|
|
}
|
|
if (enableSnap) {
|
|
enableSnap = data;
|
|
}
|
|
if (enableSnap) {
|
|
enableSnap = data.length;
|
|
}
|
|
if (enableSnap) {
|
|
enableSnap = data.length > 1;
|
|
}
|
|
return enableSnap;
|
|
}
|
|
}, {
|
|
key: "_shouldAnimateSlides",
|
|
value: function _shouldAnimateSlides(r3 = this.props) {
|
|
const { inactiveSlideOpacity, inactiveSlideScale, scrollInterpolator: scrollInterpolator2, slideInterpolatedStyle } = r3;
|
|
return inactiveSlideOpacity < 1 || inactiveSlideScale < 1 || !!scrollInterpolator2 || !!slideInterpolatedStyle || this._shouldUseShiftLayout() || this._shouldUseStackLayout() || this._shouldUseTinderLayout();
|
|
}
|
|
}, {
|
|
key: "_shouldUseCustomAnimation",
|
|
value: function _shouldUseCustomAnimation() {
|
|
return !!this.props.activeAnimationOptions && !this._shouldUseStackLayout() && !this._shouldUseTinderLayout();
|
|
}
|
|
}, {
|
|
key: "_shouldUseShiftLayout",
|
|
value: function _shouldUseShiftLayout() {
|
|
const props2 = this.props;
|
|
const inactiveSlideShift = props2.inactiveSlideShift;
|
|
return props2.layout === "default" && inactiveSlideShift !== 0;
|
|
}
|
|
}, {
|
|
key: "_shouldUseStackLayout",
|
|
value: function _shouldUseStackLayout() {
|
|
return this.props.layout === "stack";
|
|
}
|
|
}, {
|
|
key: "_shouldUseTinderLayout",
|
|
value: function _shouldUseTinderLayout() {
|
|
return this.props.layout === "tinder";
|
|
}
|
|
}, {
|
|
key: "_getCustomData",
|
|
value: function _getCustomData(r5 = this.props) {
|
|
let r7, r25;
|
|
const { data, loopClonesPerSide } = r5;
|
|
const r11 = data && data.length;
|
|
if (r11) {
|
|
if (this._enableLoop()) {
|
|
if (loopClonesPerSide > r11) {
|
|
const r26 = [];
|
|
const r9 = [];
|
|
const r28 = Math.floor(loopClonesPerSide / r11);
|
|
const r29 = loopClonesPerSide % r11;
|
|
const r31 = 0 < r28;
|
|
let r0 = 0;
|
|
if (r31) {
|
|
do {
|
|
r26.push.apply(r26, [...data]);
|
|
r9.push.apply(r9, [...data]);
|
|
r0 = r0 + 1;
|
|
} while (r0 < r28);
|
|
}
|
|
r26.unshift.apply(r26, [...data.slice(-r29)]);
|
|
r9.push.apply(r9, [...data.slice(0, r29)]);
|
|
r7 = r9;
|
|
r25 = r26;
|
|
} else {
|
|
const r23 = data.slice(-loopClonesPerSide);
|
|
r7 = data.slice(0, loopClonesPerSide);
|
|
r25 = r23;
|
|
}
|
|
return r25.concat(data, r7);
|
|
}
|
|
return data;
|
|
}
|
|
return [];
|
|
}
|
|
}, {
|
|
key: "_getCustomDataLength",
|
|
value: function _getCustomDataLength(r3 = this.props) {
|
|
const { data, loopClonesPerSide } = r3;
|
|
const r4 = data && data.length;
|
|
return r4 ? this._enableLoop() ? r4 + 2 * loopClonesPerSide : r4 : 0;
|
|
}
|
|
}, {
|
|
key: "_getCustomIndex",
|
|
value: function _getCustomIndex(a0, r3 = this.props) {
|
|
let r7;
|
|
L8: {
|
|
const r5 = this._getCustomDataLength(r3);
|
|
r7 = 0;
|
|
if (r5) {
|
|
if (!a0) {
|
|
r7 = 0;
|
|
if (a0 !== 0) {
|
|
break L8;
|
|
}
|
|
}
|
|
r7 = this._needsRTLAdaptations() ? r5 - a0 - 1 : a0;
|
|
}
|
|
}
|
|
return r7;
|
|
}
|
|
}, {
|
|
key: "_getDataIndex",
|
|
value: function _getDataIndex(a0) {
|
|
const props2 = this.props;
|
|
const { data, loopClonesPerSide } = props2;
|
|
const r7 = data && data.length;
|
|
if (this._enableLoop() && r7) {
|
|
if (a0 >= r7 + loopClonesPerSide) {
|
|
return loopClonesPerSide > r7 ? (a0 - loopClonesPerSide) % r7 : a0 - r7 - loopClonesPerSide;
|
|
}
|
|
if (a0 < loopClonesPerSide) {
|
|
if (loopClonesPerSide > r7) {
|
|
const r12 = [];
|
|
const r27 = Math.floor(loopClonesPerSide / r7);
|
|
const r28 = loopClonesPerSide % r7;
|
|
const r4 = 0 < r7;
|
|
let r0 = 0;
|
|
if (r4) {
|
|
do {
|
|
r12.push(r0);
|
|
r0 = r0 + 1;
|
|
} while (r0 < r7);
|
|
}
|
|
const r31 = [];
|
|
const r32 = 0 < r27;
|
|
let r33 = 0;
|
|
if (r32) {
|
|
do {
|
|
r31.push.apply(r31, [...r12]);
|
|
r33 = r33 + 1;
|
|
} while (r33 < r27);
|
|
}
|
|
r31.unshift.apply(r31, [...r12.slice(-r28)]);
|
|
return r31[a0];
|
|
}
|
|
return a0 + r7 - loopClonesPerSide;
|
|
}
|
|
return a0 - loopClonesPerSide;
|
|
}
|
|
return a0;
|
|
}
|
|
}, {
|
|
key: "_getPositionIndex",
|
|
value: function _getPositionIndex(a0) {
|
|
const props2 = this.props;
|
|
const { loop, loopClonesPerSide } = props2;
|
|
return loop ? a0 + loopClonesPerSide : a0;
|
|
}
|
|
}, {
|
|
key: "_getFirstItem",
|
|
value: function _getFirstItem(a0, r4 = this.props) {
|
|
const loopClonesPerSide = r4.loopClonesPerSide;
|
|
const r8 = this._getCustomDataLength(r4);
|
|
return r8 ? a0 > r8 - 1 ? 0 : a0 < 0 ? 0 : this._enableLoop() ? a0 + loopClonesPerSide : a0 : 0;
|
|
}
|
|
}, {
|
|
key: "_getWrappedRef",
|
|
value: function _getWrappedRef() {
|
|
let _carouselRef;
|
|
L11: {
|
|
L5: {
|
|
if (this._carouselRef) {
|
|
if (!(this._needsScrollView() && this._carouselRef.scrollTo)) {
|
|
if (this._needsScrollView()) {
|
|
break L5;
|
|
}
|
|
if (!this._carouselRef.scrollToOffset) {
|
|
break L5;
|
|
}
|
|
}
|
|
_carouselRef = this._carouselRef;
|
|
break L11;
|
|
}
|
|
}
|
|
_carouselRef = this._carouselRef && this._carouselRef.getNode && this._carouselRef.getNode();
|
|
}
|
|
return _carouselRef;
|
|
}
|
|
}, {
|
|
key: "_getScrollEnabled",
|
|
value: function _getScrollEnabled() {
|
|
return this._scrollEnabled;
|
|
}
|
|
}, {
|
|
key: "_setScrollEnabled",
|
|
value: function _setScrollEnabled(scrollEnabled = true) {
|
|
const r6 = this._getWrappedRef();
|
|
if (r6 && r6.setNativeProps) {
|
|
r6.setNativeProps({
|
|
scrollEnabled
|
|
});
|
|
this._scrollEnabled = scrollEnabled;
|
|
}
|
|
}
|
|
}, {
|
|
key: "_getKeyExtractor",
|
|
value: function _getKeyExtractor(a0, a1) {
|
|
const r4 = this._needsScrollView();
|
|
const concat = HermesInternal.concat;
|
|
return r4 ? concat.call("scrollview-item-", a1) : concat.call("flatlist-item-", a1);
|
|
}
|
|
}, {
|
|
key: "_getScrollOffset",
|
|
value: function _getScrollOffset(a0) {
|
|
const vertical = this.props.vertical;
|
|
return (a0 ? a0.nativeEvent : a0) && a0.nativeEvent.contentOffset && a0.nativeEvent.contentOffset[vertical ? "y" : "x"] || 0;
|
|
}
|
|
}, {
|
|
key: "_getContainerInnerMargin",
|
|
value: function _getContainerInnerMargin(r4 = false) {
|
|
let r15, r17;
|
|
L19: {
|
|
const props2 = this.props;
|
|
const { sliderWidth, sliderHeight, itemWidth, itemHeight: itemHeight2, vertical, activeSlideAlignment } = props2;
|
|
const r14 = activeSlideAlignment === "start";
|
|
if (r14) {
|
|
r15 = 0;
|
|
if (!r4) {
|
|
break L19;
|
|
}
|
|
}
|
|
const r2 = activeSlideAlignment === "end";
|
|
if (r2) {
|
|
r15 = 0;
|
|
if (r4) {
|
|
break L19;
|
|
}
|
|
}
|
|
L18: {
|
|
if (!(r2 && !r4) && !(r14 && r4)) {
|
|
if (vertical) {
|
|
r17 = (sliderHeight - itemHeight2) / 2;
|
|
break L18;
|
|
}
|
|
r17 = (sliderWidth - itemWidth) / 2;
|
|
} else {
|
|
r17 = vertical ? sliderHeight - itemHeight2 : sliderWidth - itemWidth;
|
|
}
|
|
}
|
|
r15 = r17;
|
|
}
|
|
return r15;
|
|
}
|
|
}, {
|
|
key: "_getViewportOffset",
|
|
value: function _getViewportOffset() {
|
|
const props2 = this.props;
|
|
const { sliderWidth, sliderHeight, itemWidth, itemHeight: itemHeight2, vertical, activeSlideAlignment } = props2;
|
|
return activeSlideAlignment === "start" ? vertical ? itemHeight2 / 2 : itemWidth / 2 : activeSlideAlignment === "end" ? vertical ? sliderHeight - itemHeight2 / 2 : sliderWidth - itemWidth / 2 : vertical ? sliderHeight / 2 : sliderWidth / 2;
|
|
}
|
|
}, {
|
|
key: "_getCenter",
|
|
value: function _getCenter(a0) {
|
|
return a0 + this._getViewportOffset() - this._getContainerInnerMargin();
|
|
}
|
|
}, {
|
|
key: "_getActiveItem",
|
|
value: function _getActiveItem(a0) {
|
|
const props2 = this.props;
|
|
let activeSlideOffset = props2.activeSlideOffset;
|
|
const swipeThreshold = props2.swipeThreshold;
|
|
const r13 = this._getCenter(a0);
|
|
if (!activeSlideOffset) {
|
|
activeSlideOffset = swipeThreshold;
|
|
}
|
|
const r5 = 0 < this._positions.length;
|
|
let r0 = 0;
|
|
if (r5) {
|
|
do {
|
|
const r17 = this._positions[r0];
|
|
const { start: start2, end } = r17;
|
|
const r19 = r13 + activeSlideOffset;
|
|
const r2 = r0;
|
|
if (r19 >= start2 && r13 - activeSlideOffset <= end) {
|
|
return r2;
|
|
}
|
|
r0 = r2 + 1;
|
|
} while (r0 < this._positions.length);
|
|
}
|
|
const r25 = this._positions.length - 1;
|
|
return this._positions[r25] ? r13 - activeSlideOffset > this._positions[r25].end ? r25 : 0 : 0;
|
|
}
|
|
}, {
|
|
key: "_initPositionsAndInterpolators",
|
|
value: function _initPositionsAndInterpolators(r5 = this.props) {
|
|
let c27420_0;
|
|
const props = r5;
|
|
c27420_0 = void 0;
|
|
const data = props.data;
|
|
let itemWidth = props.itemWidth;
|
|
const { itemHeight: itemHeight2, scrollInterpolator } = props;
|
|
if (props.vertical) {
|
|
itemWidth = itemHeight2;
|
|
}
|
|
const itemHeight = itemWidth;
|
|
if (data && data.length) {
|
|
const interpolators = [];
|
|
c27420_0 = interpolators;
|
|
this._positions = [];
|
|
this._getCustomData(props).forEach((item, index) => {
|
|
let r25;
|
|
const r7 = this._getCustomIndex(index, props);
|
|
this._positions[index] = {
|
|
start: index * itemHeight,
|
|
end: index * itemHeight + itemHeight
|
|
};
|
|
if (this._shouldAnimateSlides(props)) {
|
|
if (this._shouldUseCustomAnimation()) {
|
|
r25 = new _Module17.Animated.Value(r7 === this._activeItem ? 1 : 0);
|
|
} else {
|
|
let r33 = scrollInterpolator ? scrollInterpolator(r7, props) : this._shouldUseStackLayout() ? stackScrollInterpolator(r7, props) : this._shouldUseTinderLayout() ? tinderScrollInterpolator(r7, props) : void 0;
|
|
if (!((r33 ? r33.inputRange : r33) && r33.outputRange)) {
|
|
r33 = defaultScrollInterpolator(r7, props);
|
|
}
|
|
r25 = this._scrollPos.interpolate({
|
|
...r33,
|
|
extrapolate: "clamp"
|
|
});
|
|
}
|
|
} else {
|
|
r25 = new _Module17.Animated.Value(1);
|
|
}
|
|
c27420_0.push(r25);
|
|
});
|
|
this.setState({
|
|
interpolators
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "_getSlideAnimation",
|
|
value: function _getSlideAnimation(a0, a1) {
|
|
const interpolators = this.state.interpolators;
|
|
const props2 = this.props;
|
|
const { activeAnimationType, activeAnimationOptions } = props2;
|
|
const r7 = interpolators && interpolators[a0];
|
|
if (!r7 && r7 !== 0) {
|
|
return null;
|
|
}
|
|
const r8 = {
|
|
isInteraction: false,
|
|
useNativeDriver: true,
|
|
...activeAnimationOptions,
|
|
toValue: a1
|
|
};
|
|
return _Module17.Animated.parallel([_Module17.Animated.timing(r7, {
|
|
...r8,
|
|
easing: Easing.linear
|
|
}), _Module17.Animated[activeAnimationType].call(_Module17.Animated, r7, {
|
|
...r8
|
|
})]);
|
|
}
|
|
}, {
|
|
key: "_playCustomSlideAnimation",
|
|
value: function _playCustomSlideAnimation(a0, a1) {
|
|
const interpolators = this.state.interpolators;
|
|
const r7 = this._getCustomDataLength();
|
|
const r18 = this._getDataIndex(this._getCustomIndex(a0));
|
|
const r21 = this._getDataIndex(this._getCustomIndex(a1));
|
|
const r22 = [];
|
|
if (this._enableLoop()) {
|
|
const r4 = 0 < r7;
|
|
let r34 = 0;
|
|
if (r4) {
|
|
do {
|
|
const r36 = this._getDataIndex(r34);
|
|
const r0 = r34;
|
|
if (r36 === r18 && interpolators[r0]) {
|
|
r22.push(this._getSlideAnimation(r0, 0));
|
|
} else if (this._getDataIndex(r0) === r21 && interpolators[r0]) {
|
|
r22.push(this._getSlideAnimation(r0, 1));
|
|
}
|
|
r34 = r0 + 1;
|
|
} while (r34 < r7);
|
|
}
|
|
} else {
|
|
if (interpolators[a0]) {
|
|
r22.push(this._getSlideAnimation(a0, 0));
|
|
}
|
|
if (interpolators[a1]) {
|
|
r22.push(this._getSlideAnimation(a1, 1));
|
|
}
|
|
}
|
|
_Module17.Animated.parallel(r22, {
|
|
stopTogether: false
|
|
}).start();
|
|
}
|
|
}, {
|
|
key: "_hackActiveSlideAnimation",
|
|
value: function _hackActiveSlideAnimation(a0, a1, r6 = false) {
|
|
let start;
|
|
L19: {
|
|
start = void 0;
|
|
const data = this.props.data;
|
|
if (this._mounted && this._carouselRef && this._positions[a0]) {
|
|
if (!r6 && this._enableLoop()) {
|
|
break L19;
|
|
}
|
|
start = this._positions[a0] && this._positions[a0].start;
|
|
if (!start && start !== 0) {
|
|
break L19;
|
|
}
|
|
const r20 = data && data.length;
|
|
this._scrollTo(start + ((a1 ? "start" : r20 === 1 ? "start" : "end") === "start" ? -1 : 1), false);
|
|
clearTimeout(this._hackSlideAnimationTimeout);
|
|
this._hackSlideAnimationTimeout = setTimeout(() => {
|
|
this._scrollTo(start, false);
|
|
}, 50);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_lockScroll",
|
|
value: function _lockScroll() {
|
|
const lockScrollTimeoutDuration = this.props.lockScrollTimeoutDuration;
|
|
clearTimeout(this._lockScrollTimeout);
|
|
this._lockScrollTimeout = setTimeout(() => {
|
|
this._releaseScroll();
|
|
}, lockScrollTimeoutDuration);
|
|
this._setScrollEnabled(false);
|
|
}
|
|
}, {
|
|
key: "_releaseScroll",
|
|
value: function _releaseScroll() {
|
|
clearTimeout(this._lockScrollTimeout);
|
|
this._setScrollEnabled(true);
|
|
}
|
|
}, {
|
|
key: "_repositionScroll",
|
|
value: function _repositionScroll(a0) {
|
|
const props2 = this.props;
|
|
const { data, loopClonesPerSide } = props2;
|
|
const r4 = data && data.length;
|
|
L11: {
|
|
if (this._enableLoop() && r4) {
|
|
if (a0 >= loopClonesPerSide && a0 < r4 + loopClonesPerSide) {
|
|
break L11;
|
|
}
|
|
this._snapToItem(a0 >= r4 + loopClonesPerSide ? a0 - r4 : a0 < loopClonesPerSide ? a0 + r4 : a0, false, false, false, false);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_scrollTo",
|
|
value: function _scrollTo(a0, animated = true) {
|
|
const vertical = this.props.vertical;
|
|
const r4 = this._getWrappedRef();
|
|
if (this._mounted && r4) {
|
|
const r18 = {
|
|
...this._needsScrollView() ? {
|
|
x: vertical ? 0 : a0,
|
|
y: vertical ? a0 : 0
|
|
} : {
|
|
offset: a0
|
|
},
|
|
animated
|
|
};
|
|
if (this._needsScrollView()) {
|
|
r4.scrollTo(r18);
|
|
} else {
|
|
r4.scrollToOffset(r18);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onScroll",
|
|
value: function _onScroll(a0) {
|
|
const props2 = this.props;
|
|
const { callbackOffsetMargin, enableMomentum, onScroll } = props2;
|
|
const _currentContentOffset = a0 ? this._getScrollOffset(a0) : this._currentContentOffset;
|
|
const _activeItem = this._getActiveItem(_currentContentOffset);
|
|
const _itemToSnapTo = this._itemToSnapTo;
|
|
let r17 = _currentContentOffset >= this._scrollOffsetRef - callbackOffsetMargin && _currentContentOffset <= this._scrollOffsetRef + callbackOffsetMargin;
|
|
this._currentContentOffset = _currentContentOffset;
|
|
this._onScrollTriggered = true;
|
|
this._lastScrollDate = Date.now();
|
|
if (this._activeItem !== _activeItem && this._shouldUseCustomAnimation()) {
|
|
this._playCustomSlideAnimation(this._activeItem, _activeItem);
|
|
}
|
|
const r28 = _activeItem === _itemToSnapTo;
|
|
if (enableMomentum) {
|
|
clearTimeout(this._snapNoMomentumTimeout);
|
|
if (this._activeItem !== _activeItem) {
|
|
this._activeItem = _activeItem;
|
|
}
|
|
if (r28) {
|
|
if (this._canFireBeforeCallback) {
|
|
this._onBeforeSnap(this._getDataIndex(_activeItem));
|
|
}
|
|
if (r17) {
|
|
r17 = this._canFireCallback;
|
|
}
|
|
if (r17) {
|
|
this._onSnap(this._getDataIndex(_activeItem));
|
|
}
|
|
}
|
|
} else if (this._activeItem !== _activeItem && r28) {
|
|
if (this._canFireBeforeCallback) {
|
|
this._onBeforeSnap(this._getDataIndex(_activeItem));
|
|
}
|
|
if (r17) {
|
|
this._activeItem = _activeItem;
|
|
if (this._canLockScroll()) {
|
|
this._releaseScroll();
|
|
}
|
|
if (this._canFireCallback) {
|
|
this._onSnap(this._getDataIndex(_activeItem));
|
|
}
|
|
}
|
|
}
|
|
if (_activeItem === this._itemToSnapTo && _currentContentOffset === this._scrollOffsetRef) {
|
|
this._repositionScroll(_activeItem);
|
|
}
|
|
if (typeof onScroll === "function" ? a0 : typeof onScroll === "function") {
|
|
onScroll(a0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onStartShouldSetResponderCapture",
|
|
value: function _onStartShouldSetResponderCapture(a0) {
|
|
const onStartShouldSetResponderCapture = this.props.onStartShouldSetResponderCapture;
|
|
if (onStartShouldSetResponderCapture) {
|
|
onStartShouldSetResponderCapture(a0);
|
|
}
|
|
return this._getScrollEnabled();
|
|
}
|
|
}, {
|
|
key: "_onTouchStart",
|
|
value: function _onTouchStart() {
|
|
const onTouchStart = this.props.onTouchStart;
|
|
if (this._getScrollEnabled() !== false && this._autoplaying) {
|
|
this.pauseAutoPlay();
|
|
}
|
|
if (onTouchStart) {
|
|
onTouchStart();
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onTouchEnd",
|
|
value: function _onTouchEnd() {
|
|
const onTouchEnd = this.props.onTouchEnd;
|
|
if (this._getScrollEnabled() !== false && this._autoplay && !this._autoplaying) {
|
|
this.startAutoplay();
|
|
}
|
|
if (onTouchEnd) {
|
|
onTouchEnd();
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onScrollBeginDrag",
|
|
value: function _onScrollBeginDrag(a0) {
|
|
const onScrollBeginDrag = this.props.onScrollBeginDrag;
|
|
if (this._getScrollEnabled()) {
|
|
this._scrollStartOffset = this._getScrollOffset(a0);
|
|
this._scrollStartActive = this._getActiveItem(this._scrollStartOffset);
|
|
this._ignoreNextMomentum = false;
|
|
if (onScrollBeginDrag) {
|
|
onScrollBeginDrag(a0);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onScrollEndDrag",
|
|
value: function _onScrollEndDrag(a0) {
|
|
const onScrollEndDrag = this.props.onScrollEndDrag;
|
|
if (this._carouselRef && this._onScrollEnd) {
|
|
this._onScrollEnd();
|
|
}
|
|
if (onScrollEndDrag) {
|
|
onScrollEndDrag(a0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onMomentumScrollEnd",
|
|
value: function _onMomentumScrollEnd(a0) {
|
|
const onMomentumScrollEnd = this.props.onMomentumScrollEnd;
|
|
if (this._carouselRef && this._onScrollEnd) {
|
|
this._onScrollEnd();
|
|
}
|
|
if (onMomentumScrollEnd) {
|
|
onMomentumScrollEnd(a0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onScrollEnd",
|
|
value: function _onScrollEnd(a0) {
|
|
const props2 = this.props;
|
|
const { autoplayDelay, enableSnap } = props2;
|
|
if (this._ignoreNextMomentum) {
|
|
this._ignoreNextMomentum = false;
|
|
} else if (this._currentContentOffset !== this._scrollEndOffset) {
|
|
this._scrollEndOffset = this._currentContentOffset;
|
|
this._scrollEndActive = this._getActiveItem(this._scrollEndOffset);
|
|
if (enableSnap) {
|
|
this._snapScroll(this._scrollEndOffset - this._scrollStartOffset);
|
|
}
|
|
if (this._autoplay && !this._autoplaying) {
|
|
clearTimeout(this._enableAutoplayTimeout);
|
|
this._enableAutoplayTimeout = setTimeout(() => {
|
|
this.startAutoplay();
|
|
}, autoplayDelay + 50);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onTouchRelease",
|
|
value: function _onTouchRelease(a0) {
|
|
this.props.enableMomentum;
|
|
}
|
|
}, {
|
|
key: "_onLayout",
|
|
value: function _onLayout(a0) {
|
|
const onLayout = this.props.onLayout;
|
|
if (this._onLayoutInitDone) {
|
|
this._initPositionsAndInterpolators();
|
|
this._snapToItem(this._activeItem, false, false, false, false);
|
|
} else {
|
|
this._onLayoutInitDone = true;
|
|
}
|
|
if (onLayout) {
|
|
onLayout(a0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_snapScroll",
|
|
value: function _snapScroll(a0) {
|
|
const swipeThreshold = this.props.swipeThreshold;
|
|
if (!this._scrollEndActive) {
|
|
this._scrollEndActive;
|
|
}
|
|
L12: {
|
|
if (this._scrollStartActive !== this._scrollEndActive) {
|
|
this._snapToItem(this._scrollEndActive);
|
|
} else if (a0 > 0) {
|
|
if (a0 > swipeThreshold) {
|
|
this._snapToItem(this._scrollStartActive + 1);
|
|
} else {
|
|
this._snapToItem(this._scrollEndActive);
|
|
}
|
|
} else {
|
|
if (a0 < 0 && a0 < -swipeThreshold) {
|
|
this._snapToItem(this._scrollStartActive - 1);
|
|
break L12;
|
|
}
|
|
this._snapToItem(this._scrollEndActive);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_snapToItem",
|
|
value: function _snapToItem(a0) {
|
|
let _previousActiveItem = a0;
|
|
let c27424_1 = a0;
|
|
let r12 = arguments[1];
|
|
if (r12 === void 0) {
|
|
r12 = true;
|
|
}
|
|
let r13 = arguments[2];
|
|
if (r13 === void 0) {
|
|
r13 = true;
|
|
}
|
|
let r8 = arguments[3];
|
|
if (r8 === void 0) {
|
|
r8 = false;
|
|
}
|
|
let c27424_0 = r8;
|
|
let r14 = arguments[4];
|
|
if (r14 === void 0) {
|
|
r14 = true;
|
|
}
|
|
const props2 = this.props;
|
|
const { enableMomentum, onSnapToItem, onBeforeSnapToItem } = props2;
|
|
const r18 = this._getCustomDataLength();
|
|
const r16 = this._getWrappedRef();
|
|
if (r18 && r16) {
|
|
L18: {
|
|
if (a0 && !(a0 < 0)) {
|
|
if (!(r18 > 0 && a0 >= r18)) {
|
|
break L18;
|
|
}
|
|
const r21 = r18 - 1;
|
|
c27424_1 = r21;
|
|
_previousActiveItem = r21;
|
|
} else {
|
|
c27424_1 = 0;
|
|
_previousActiveItem = 0;
|
|
}
|
|
}
|
|
if (_previousActiveItem !== this._previousActiveItem) {
|
|
this._previousActiveItem = _previousActiveItem;
|
|
if (r14) {
|
|
r14 = this._canLockScroll();
|
|
}
|
|
if (r14) {
|
|
this._lockScroll();
|
|
}
|
|
if (r13) {
|
|
if (onBeforeSnapToItem) {
|
|
this._canFireBeforeCallback = true;
|
|
}
|
|
if (onSnapToItem) {
|
|
this._canFireCallback = true;
|
|
}
|
|
}
|
|
}
|
|
this._itemToSnapTo = _previousActiveItem;
|
|
this._scrollOffsetRef = this._positions[_previousActiveItem] && this._positions[_previousActiveItem].start;
|
|
this._onScrollTriggered = false;
|
|
if (this._scrollOffsetRef || this._scrollOffsetRef === 0) {
|
|
this._scrollTo(this._scrollOffsetRef, r12);
|
|
this._scrollEndOffset = this._currentContentOffset;
|
|
if (enableMomentum) {
|
|
if (!r8) {
|
|
this._ignoreNextMomentum = true;
|
|
}
|
|
if (!(_previousActiveItem !== 0 && _previousActiveItem !== r18 - 1)) {
|
|
clearTimeout(this._edgeItemTimeout);
|
|
this._edgeItemTimeout = setTimeout(() => {
|
|
if (!(c27424_0 || c27424_1 !== this._activeItem || this._onScrollTriggered)) {
|
|
this._onScroll();
|
|
}
|
|
}, 250);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onBeforeSnap",
|
|
value: function _onBeforeSnap(a0) {
|
|
const onBeforeSnapToItem = this.props.onBeforeSnapToItem;
|
|
if (this._carouselRef) {
|
|
this._canFireBeforeCallback = false;
|
|
if (onBeforeSnapToItem) {
|
|
onBeforeSnapToItem(a0);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_onSnap",
|
|
value: function _onSnap(a0) {
|
|
const onSnapToItem = this.props.onSnapToItem;
|
|
if (this._carouselRef) {
|
|
this._canFireCallback = false;
|
|
if (onSnapToItem) {
|
|
onSnapToItem(a0);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "startAutoplay",
|
|
value: function startAutoplay() {
|
|
const props2 = this.props;
|
|
const { autoplayInterval, autoplayDelay } = props2;
|
|
this._autoplay = true;
|
|
if (!this._autoplaying) {
|
|
clearTimeout(this._autoplayTimeout);
|
|
this._autoplayTimeout = setTimeout(() => {
|
|
this._autoplaying = true;
|
|
this._autoplayInterval = setInterval(() => {
|
|
if (this._autoplaying) {
|
|
this.snapToNext();
|
|
}
|
|
}, autoplayInterval);
|
|
}, autoplayDelay);
|
|
}
|
|
}
|
|
}, {
|
|
key: "pauseAutoPlay",
|
|
value: function pauseAutoPlay() {
|
|
this._autoplaying = false;
|
|
clearTimeout(this._autoplayTimeout);
|
|
clearTimeout(this._enableAutoplayTimeout);
|
|
clearInterval(this._autoplayInterval);
|
|
}
|
|
}, {
|
|
key: "stopAutoplay",
|
|
value: function stopAutoplay() {
|
|
this._autoplay = false;
|
|
this.pauseAutoPlay();
|
|
}
|
|
}, {
|
|
key: "snapToItem",
|
|
value: function snapToItem(a0, r8 = true, r7 = true) {
|
|
const r9 = this._getPositionIndex((a0 ? a0 < 0 : !a0) ? 0 : a0);
|
|
if (r9 !== this._activeItem) {
|
|
this._snapToItem(r9, r8, r7);
|
|
}
|
|
}
|
|
}, {
|
|
key: "snapToNext",
|
|
value: function snapToNext(r7 = true, r6 = true) {
|
|
const r8 = this._getCustomDataLength();
|
|
let r9 = this._activeItem + 1;
|
|
if (r9 > r8 - 1) {
|
|
const r12 = this._enableLoop();
|
|
r9 = 0;
|
|
if (!r12) {
|
|
return void 0;
|
|
}
|
|
}
|
|
this._snapToItem(r9, r7, r6);
|
|
}
|
|
}, {
|
|
key: "snapToPrev",
|
|
value: function snapToPrev(r8 = true, r7 = true) {
|
|
const r10 = this._getCustomDataLength();
|
|
let r0 = this._activeItem - 1;
|
|
if (r0 < 0) {
|
|
if (!this._enableLoop()) {
|
|
return void 0;
|
|
}
|
|
r0 = r10 - 1;
|
|
}
|
|
this._snapToItem(r0, r8, r7);
|
|
}
|
|
}, {
|
|
key: "triggerRenderingHack",
|
|
value: function triggerRenderingHack(a0) {
|
|
L8: {
|
|
if (!(Date.now() - this._lastScrollDate < 500)) {
|
|
const _currentContentOffset = this._currentContentOffset;
|
|
if (!_currentContentOffset && _currentContentOffset !== 0) {
|
|
break L8;
|
|
}
|
|
this._scrollTo(_currentContentOffset + (a0 ? a0 : _currentContentOffset === 0 ? 1 : -1), false);
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "_getSlideInterpolatedStyle",
|
|
value: function _getSlideInterpolatedStyle(a0, a1) {
|
|
const props2 = this.props;
|
|
const { layoutCardOffset, slideInterpolatedStyle } = props2;
|
|
return slideInterpolatedStyle ? slideInterpolatedStyle(a0, a1, this.props) : this._shouldUseTinderLayout() ? tinderAnimatedStyles(a0, a1, this.props, layoutCardOffset) : this._shouldUseStackLayout() ? stackAnimatedStyles(a0, a1, this.props, layoutCardOffset) : this._shouldUseShiftLayout() ? shiftAnimatedStyles(a0, a1, this.props) : defaultAnimatedStyles(a0, a1, this.props);
|
|
}
|
|
}, {
|
|
key: "_renderItem",
|
|
value: function _renderItem({ item, index }) {
|
|
const interpolators = this.state.interpolators;
|
|
const props2 = this.props;
|
|
const { hasParallaxImages, itemWidth, itemHeight: itemHeight2, keyExtractor, renderItem, sliderHeight, sliderWidth, slideStyle, vertical } = props2;
|
|
const r18 = interpolators && interpolators[index];
|
|
if (!r18 && r18 !== 0) {
|
|
return null;
|
|
}
|
|
const r6 = this._shouldAnimateSlides();
|
|
const Component = r6 ? _Module17.Animated.View : View;
|
|
const r26 = r6 ? this._getSlideInterpolatedStyle(index, r18) : {};
|
|
const r29 = hasParallaxImages ? {
|
|
scrollPosition: this._scrollPos,
|
|
carouselRef: this._carouselRef,
|
|
vertical,
|
|
sliderWidth,
|
|
sliderHeight,
|
|
itemWidth,
|
|
itemHeight: itemHeight2
|
|
} : void 0;
|
|
return <Component style={[vertical ? {
|
|
height: itemHeight2
|
|
} : {
|
|
width: itemWidth
|
|
}, slideStyle, r26]} pointerEvents="box-none" {...this._needsScrollView() ? {
|
|
key: keyExtractor ? keyExtractor(item, index) : this._getKeyExtractor(item, index)
|
|
} : {}}>
|
|
{renderItem({
|
|
item,
|
|
index
|
|
}, r29)}
|
|
</Component>;
|
|
}
|
|
}, {
|
|
key: "_getComponentOverridableProps",
|
|
value: function _getComponentOverridableProps() {
|
|
let r29;
|
|
const props2 = this.props;
|
|
const { enableMomentum, itemWidth, itemHeight: itemHeight2, loopClonesPerSide, sliderWidth, sliderHeight } = props2;
|
|
const r20 = Math.ceil(props2.vertical ? sliderHeight / itemHeight2 : sliderWidth / itemWidth) + 1;
|
|
const r2 = 2 * (this._enableLoop() ? loopClonesPerSide : 2);
|
|
if (this._needsScrollView()) {
|
|
r29 = {};
|
|
} else {
|
|
const initialNumToRender = r20 + r2;
|
|
const maxToRenderPerBatch = 1 + 2 * initialNumToRender;
|
|
r29 = {
|
|
initialNumToRender,
|
|
maxToRenderPerBatch,
|
|
windowSize: maxToRenderPerBatch
|
|
};
|
|
}
|
|
return {
|
|
decelerationRate: enableMomentum ? 0.9 : "fast",
|
|
showsHorizontalScrollIndicator: false,
|
|
showsVerticalScrollIndicator: false,
|
|
overScrollMode: "never",
|
|
automaticallyAdjustContentInsets: false,
|
|
directionalLockEnabled: true,
|
|
pinchGestureEnabled: false,
|
|
scrollsToTop: false,
|
|
removeClippedSubviews: !this._needsScrollView(),
|
|
inverted: this._needsRTLAdaptations(),
|
|
...r29
|
|
};
|
|
}
|
|
}, {
|
|
key: "_getComponentStaticProps",
|
|
value: function _getComponentStaticProps() {
|
|
let r37;
|
|
const hideCarousel = this.state.hideCarousel;
|
|
const props2 = this.props;
|
|
let containerCustomStyle = props2.containerCustomStyle;
|
|
let contentContainerCustomStyle = props2.contentContainerCustomStyle;
|
|
let keyExtractor = props2.keyExtractor;
|
|
const { sliderWidth, sliderHeight, style, vertical } = props2;
|
|
if (!containerCustomStyle) {
|
|
containerCustomStyle = style;
|
|
}
|
|
if (!containerCustomStyle) {
|
|
containerCustomStyle = {};
|
|
}
|
|
const style2 = [containerCustomStyle, hideCarousel ? {
|
|
opacity: 0
|
|
} : {}, vertical ? {
|
|
height: sliderHeight,
|
|
flexDirection: "column"
|
|
} : {
|
|
width: sliderWidth,
|
|
flexDirection: this._needsRTLAdaptations() ? "row-reverse" : "row"
|
|
}];
|
|
const contentContainerStyle = [vertical ? {
|
|
paddingTop: this._getContainerInnerMargin(),
|
|
paddingBottom: this._getContainerInnerMargin(true)
|
|
} : {
|
|
paddingLeft: this._getContainerInnerMargin(),
|
|
paddingRight: this._getContainerInnerMargin(true)
|
|
}, ,];
|
|
if (!contentContainerCustomStyle) {
|
|
contentContainerCustomStyle = {};
|
|
}
|
|
contentContainerStyle[1] = contentContainerCustomStyle;
|
|
if (this._needsScrollView()) {
|
|
r37 = {};
|
|
} else {
|
|
if (!keyExtractor) {
|
|
keyExtractor = this._getKeyExtractor;
|
|
}
|
|
r37 = {
|
|
renderItem: this._renderItem,
|
|
numColumns: 1,
|
|
keyExtractor
|
|
};
|
|
}
|
|
return {
|
|
ref: (a0) => {
|
|
this._carouselRef = a0;
|
|
return a0;
|
|
},
|
|
data: this._getCustomData(),
|
|
style: style2,
|
|
contentContainerStyle,
|
|
horizontal: !vertical,
|
|
scrollEventThrottle: 1,
|
|
onScroll: this._onScrollHandler,
|
|
onScrollBeginDrag: this._onScrollBeginDrag,
|
|
onScrollEndDrag: this._onScrollEndDrag,
|
|
onMomentumScrollEnd: this._onMomentumScrollEnd,
|
|
onResponderRelease: this._onTouchRelease,
|
|
onStartShouldSetResponderCapture: this._onStartShouldSetResponderCapture,
|
|
onTouchStart: this._onTouchStart,
|
|
onTouchEnd: this._onScrollEnd,
|
|
onLayout: this._onLayout,
|
|
...r37
|
|
};
|
|
}
|
|
}, {
|
|
key: "render",
|
|
value: function render() {
|
|
let r29;
|
|
const props2 = this.props;
|
|
const { data, renderItem } = props2;
|
|
let UseScrollView = props2.useScrollView;
|
|
if (data && renderItem) {
|
|
const r6 = {
|
|
...this._getComponentOverridableProps(),
|
|
...this.props,
|
|
...this._getComponentStaticProps()
|
|
};
|
|
if (typeof UseScrollView !== "function") {
|
|
UseScrollView = c9172_13;
|
|
}
|
|
const r8 = this._needsScrollView();
|
|
const r23 = {};
|
|
if (r8) {
|
|
HermesBuiltin.copyDataProperties(r23, r6);
|
|
r23.children = this._getCustomData().map((a0, a1) => this._renderItem({
|
|
item: a0,
|
|
index: a1
|
|
}));
|
|
r29 = <UseScrollView {...r23} />;
|
|
} else {
|
|
HermesBuiltin.copyDataProperties(r23, r6);
|
|
r29 = <Component2 {...r23} />;
|
|
}
|
|
return r29;
|
|
}
|
|
return null;
|
|
}
|
|
}]);
|
|
r184.propTypes = {
|
|
data: Module4014.array.isRequired,
|
|
renderItem: Module4014.func.isRequired,
|
|
itemWidth: Module4014.number,
|
|
itemHeight: Module4014.number,
|
|
sliderWidth: Module4014.number,
|
|
sliderHeight: Module4014.number,
|
|
activeAnimationType: Module4014.string,
|
|
activeAnimationOptions: Module4014.object,
|
|
activeSlideAlignment: Module4014.oneOf(["center", "end", "start"]),
|
|
activeSlideOffset: Module4014.number,
|
|
apparitionDelay: Module4014.number,
|
|
autoplay: Module4014.bool,
|
|
autoplayDelay: Module4014.number,
|
|
autoplayInterval: Module4014.number,
|
|
callbackOffsetMargin: Module4014.number,
|
|
containerCustomStyle: ViewPropTypes.style,
|
|
contentContainerCustomStyle: ViewPropTypes.style,
|
|
enableMomentum: Module4014.bool,
|
|
enableSnap: Module4014.bool,
|
|
firstItem: Module4014.number,
|
|
hasParallaxImages: Module4014.bool,
|
|
inactiveSlideOpacity: Module4014.number,
|
|
inactiveSlideScale: Module4014.number,
|
|
inactiveSlideShift: Module4014.number,
|
|
layout: Module4014.oneOf(["default", "stack", "tinder"]),
|
|
layoutCardOffset: Module4014.number,
|
|
lockScrollTimeoutDuration: Module4014.number,
|
|
lockScrollWhileSnapping: Module4014.bool,
|
|
loop: Module4014.bool,
|
|
loopClonesPerSide: Module4014.number,
|
|
scrollEnabled: Module4014.bool,
|
|
scrollInterpolator: Module4014.func,
|
|
slideInterpolatedStyle: Module4014.func,
|
|
slideStyle: ViewPropTypes.style,
|
|
shouldOptimizeUpdates: Module4014.bool,
|
|
swipeThreshold: Module4014.number,
|
|
useScrollView: Module4014.oneOfType([Module4014.bool, Module4014.func]),
|
|
vertical: Module4014.bool,
|
|
onBeforeSnapToItem: Module4014.func,
|
|
onSnapToItem: Module4014.func
|
|
};
|
|
r184.defaultProps = {
|
|
activeAnimationType: "timing",
|
|
activeAnimationOptions: null,
|
|
activeSlideAlignment: "center",
|
|
activeSlideOffset: 20,
|
|
apparitionDelay: 0,
|
|
autoplay: false,
|
|
autoplayDelay: 1000,
|
|
autoplayInterval: 3000,
|
|
callbackOffsetMargin: 5,
|
|
containerCustomStyle: {},
|
|
contentContainerCustomStyle: {},
|
|
enableMomentum: false,
|
|
enableSnap: true,
|
|
firstItem: 0,
|
|
hasParallaxImages: false,
|
|
inactiveSlideOpacity: 0.7,
|
|
inactiveSlideScale: 0.9,
|
|
inactiveSlideShift: 0,
|
|
layout: "default",
|
|
lockScrollTimeoutDuration: 1000,
|
|
lockScrollWhileSnapping: false,
|
|
loop: false,
|
|
loopClonesPerSide: 3,
|
|
scrollEnabled: true,
|
|
slideStyle: {},
|
|
shouldOptimizeUpdates: true,
|
|
swipeThreshold: 20,
|
|
useScrollView: !Component2,
|
|
vertical: false
|
|
};
|
|
export default r184;
|