react-alice-carousel
Advanced tools
Comparing version 1.19.2 to 1.19.3
@@ -64,376 +64,15 @@ "use strict"; | ||
_this._handleOnWindowResize = function (e) { | ||
var shouldHandleResizeEvent = _this.props.shouldHandleResizeEvent; | ||
var currentDimensions = Utils.getElementDimensions(_this.rootComponent); | ||
var shouldProcessEvent = shouldHandleResizeEvent || Utils.shouldHandleResizeEvent; | ||
_initialiseProps.call(_assertThisInitialized(_this)); | ||
if (shouldProcessEvent(e, _this.rootComponentDimensions, currentDimensions)) { | ||
_this.rootComponentDimensions = currentDimensions; | ||
_this._disableAnimation(); | ||
_this._pause(); | ||
var _this$state = _this.state, | ||
currentIndex = _this$state.currentIndex, | ||
isAutoPlaying = _this$state.isAutoPlaying; | ||
var isAnimationCanceled = _this._isSwipeAnimationProcessing(); | ||
var initialProps = Utils.preserveProps(_this.props, { | ||
startIndex: currentIndex | ||
}); | ||
var currState = Utils.calculateInitialProps(initialProps, _this.stageComponent); | ||
var translate3d = Utils.getTranslate3dPosition(currState.currentIndex, currState); | ||
var nextState = _objectSpread({}, currState, { | ||
translate3d: translate3d, | ||
isAnimationCanceled: isAnimationCanceled, | ||
isAutoPlaying: isAutoPlaying, | ||
initialStageHeight: 0 | ||
}); | ||
if (isAnimationCanceled) Utils.animate(_this.stageComponent, { | ||
position: translate3d | ||
}); | ||
_this.setState(nextState, function () { | ||
_this._resetAllIntermediateProps(); | ||
isAutoPlaying && _this._play(); | ||
_this._onResized(); | ||
}); | ||
} | ||
}; | ||
_this._handleOnAnimationCanceled = function () { | ||
_this._resetAllIntermediateProps(); | ||
_this.setState({ | ||
isAnimationCanceled: false | ||
}); | ||
}; | ||
_this._handleOnKeyUp = function (e) { | ||
switch (e.code) { | ||
case 'Space': | ||
return _this.props.autoPlay && _this._playPauseToggle(); | ||
case 'ArrowLeft': | ||
return _this.slidePrev(); | ||
case 'ArrowRight': | ||
return _this.slideNext(); | ||
} | ||
}; | ||
_this._handleOnMouseEnter = function () { | ||
if (_this.props.stopAutoPlayOnHover && _this.state.isAutoPlaying) { | ||
_this.isHovered = true; | ||
_this._pause(); | ||
} | ||
}; | ||
_this._handleOnMouseLeave = function () { | ||
if (_this.state.isAutoPlaying) { | ||
_this.isHovered = false; | ||
_this._play(); | ||
} | ||
}; | ||
_this._onSlideToIndexChange = function (currentIndex, slideToIndex) { | ||
if (slideToIndex === currentIndex + 1) { | ||
_this.slideNext(); | ||
} else if (slideToIndex === currentIndex - 1) { | ||
_this.slidePrev(); | ||
} else { | ||
_this.slideTo(slideToIndex); | ||
} | ||
}; | ||
_this._onInactiveItem = function () { | ||
_this._onSlideChange(); | ||
_this._onSlideChanged(); | ||
}; | ||
_this._getFadeOutAnimationState = function (shouldRecalculate) { | ||
if (shouldRecalculate || _this._isFadeOutAnimationAllowed()) { | ||
return { | ||
fadeoutAnimationProcessing: false | ||
}; | ||
} | ||
return {}; | ||
}; | ||
_this._setRootComponentRef = function (node) { | ||
return _this.rootComponent = node; | ||
}; | ||
_this._setStageComponentRef = function (node) { | ||
return _this.stageComponent = node; | ||
}; | ||
_this._allowAnimation = function () { | ||
return _this.allowAnimation = true; | ||
}; | ||
_this._disableAnimation = function () { | ||
return _this.allowAnimation = false; | ||
}; | ||
_this._skipSlidePositionRecalculation = function () { | ||
if (_this._isFadeOutAnimationAllowed()) { | ||
return _this._resetFadeOutAnimationState(); | ||
} | ||
_this._onSlideChanged(); | ||
}; | ||
_this._updateSlidePosition = function () { | ||
_this._updateSlidePositionIntervalId = setTimeout(function () { | ||
if (_this._shouldRecalculatePosition()) { | ||
_this._recalculateSlidePosition(); | ||
} else if (_this._isFadeOutAnimationAllowed()) { | ||
_this._resetFadeOutAnimationState(); | ||
} else { | ||
_this._onSlideChanged(); | ||
} | ||
}, _this.state.duration); | ||
}; | ||
_this._resetFadeOutAnimationState = function () { | ||
_this.setState({ | ||
fadeoutAnimationProcessing: false | ||
}, _this._onSlideChanged); | ||
}; | ||
_this._resetAllIntermediateProps = function () { | ||
_this.prevSwipPosition = 0; | ||
_this.swipingStarted = false; | ||
_this._stopSwipeAnimation(); | ||
_this._resetAnimationProps(); | ||
_this._resetSwipePositionProps(); | ||
_this._clearUpdateSlidePositionIntervalId(); | ||
_this._allowAnimation(); | ||
}; | ||
_this._recalculateSlidePosition = function () { | ||
var style = Utils.getDefaultStyles(); | ||
var currentIndex = Utils.recalculateCurrentSlideIndex(_this.state); | ||
var translate3d = Utils.recalculateTranslatePosition(_this.state); | ||
_this.setState(_objectSpread({ | ||
currentIndex: currentIndex, | ||
translate3d: translate3d, | ||
style: style | ||
}, _this._getFadeOutAnimationState()), function () { | ||
return _this._onSlideChanged(); | ||
}); | ||
}; | ||
_this._getEventObject = function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state; | ||
var itemsInSlide = state.items, | ||
item = state.currentIndex; | ||
var _Utils$itemInfo = Utils.itemInfo(state), | ||
isNextSlideDisabled = _Utils$itemInfo.isNextSlideDisabled, | ||
isPrevSlideDisabled = _Utils$itemInfo.isPrevSlideDisabled; | ||
var slide = Utils.getActiveSlideIndex(isNextSlideDisabled, state); | ||
return { | ||
item: item, | ||
slide: slide, | ||
itemsInSlide: itemsInSlide, | ||
isNextSlideDisabled: isNextSlideDisabled, | ||
isPrevSlideDisabled: isPrevSlideDisabled | ||
}; | ||
}; | ||
_this.setAnimationPropsOnDotClick = function (itemIndex) { | ||
var _this$state2 = _this.state, | ||
currentIndex = _this$state2.currentIndex, | ||
itemWidth = _this$state2.itemWidth; | ||
var fadeOutIndex = currentIndex + 1; | ||
var fadeOutOffset = Utils.getFadeOutOffsetOnDotClick(itemIndex, currentIndex, itemWidth); | ||
_this._setAnimationProps({ | ||
fadeOutIndex: fadeOutIndex, | ||
fadeOutOffset: fadeOutOffset, | ||
allowFadeOutAnimation: true | ||
}); | ||
}; | ||
_this._pause = function () { | ||
_this._clearAutoPlayInterval(); | ||
}; | ||
_this._playPauseToggle = function () { | ||
var isAutoPlaying = _this.state.isAutoPlaying; | ||
_this.hasUserAction = true; | ||
_this.setState({ | ||
isAutoPlaying: !isAutoPlaying, | ||
isAutoplayCanceledOnAction: true | ||
}, function () { | ||
isAutoPlaying ? _this._pause() : _this._play(); | ||
}); | ||
}; | ||
_this._getIntermediateStateProps = function (duration, shouldSkipRecalculation) { | ||
var transitionTimingFunction = _this.props.transitionTimingFunction; | ||
var condition = !shouldSkipRecalculation && _this._isFadeOutAnimationAllowed(); | ||
return Utils.getIntermediateTransitionProps(condition, duration, transitionTimingFunction); | ||
}; | ||
_this._startSwipeAnimation = function () { | ||
_this.swipeAnimation = true; | ||
}; | ||
_this._stopSwipeAnimation = function () { | ||
_this.swipeAnimation = false; | ||
_this.touchEndAnimation = false; | ||
_this.touchEndTimeoutId = null; | ||
}; | ||
_this._setAnimationProps = function (newProps) { | ||
var prevProps = _this.animationProps || {}; | ||
_this.animationProps = _objectSpread({}, prevProps, {}, newProps); | ||
}; | ||
_this._resetAnimationProps = function () { | ||
_this.animationProps = {}; | ||
}; | ||
_this._setSwipePositionProps = function (newProps) { | ||
var prevProps = _this.swipePosition || {}; | ||
_this.swipePosition = _objectSpread({}, prevProps, {}, newProps); | ||
}; | ||
_this._resetSwipePositionProps = function () { | ||
_this.swipePosition = {}; | ||
}; | ||
_this._getTranslateXPosition = function (deltaX) { | ||
var translate3d = _this.state.translate3d; | ||
var lastSwipePosition = _this.swipePosition.lastSwipePosition; | ||
var position = lastSwipePosition || translate3d; | ||
if (_this.touchEndAnimation) { | ||
_this.touchEndAnimation = false; | ||
var translateX = Utils.getTranslateX(_this.stageComponent); | ||
if (translateX) { | ||
return translateX; | ||
} | ||
} | ||
return position - Math.floor(deltaX); | ||
}; | ||
_this._onTouchEnd = function () { | ||
if (!_this.swipingStarted || _this._isSwipeDisabled()) return; | ||
_this.swipingStarted = false; | ||
_this.prevSwipPosition = 0; | ||
_this._setSwipePositionProps({ | ||
lastSwipePosition: _this.swipePosition.position | ||
}); | ||
_this._beforeTouchEnd(); | ||
}; | ||
_this._isClickDisabled = function (itemIndex) { | ||
var _this$state3 = _this.state, | ||
currentIndex = _this$state3.currentIndex, | ||
isAnimationCanceled = _this$state3.isAnimationCanceled; | ||
return currentIndex === itemIndex || isAnimationCanceled || !_this.allowAnimation || _this.swipeAnimation; | ||
}; | ||
_this._isFadeOutAnimationAllowed = function () { | ||
var _this$state4 = _this.state, | ||
stagePadding = _this$state4.stagePadding, | ||
items = _this$state4.items; | ||
var hasNoStagePadding = !(stagePadding.paddingLeft || stagePadding.paddingRight); | ||
return _this.props.fadeOutAnimation && items === 1 && hasNoStagePadding; | ||
}; | ||
_this._isSwipeDisabled = function () { | ||
var _this$state5 = _this.state, | ||
isAnimationCanceled = _this$state5.isAnimationCanceled, | ||
fadeoutAnimationProcessing = _this$state5.fadeoutAnimationProcessing; | ||
return _this.props.swipeDisabled || fadeoutAnimationProcessing || isAnimationCanceled; | ||
}; | ||
_this._isSwipeAnimationLastFrame = function () { | ||
return !_this.swipingStarted; | ||
}; | ||
_this._isSwipeAnimationProcessing = function () { | ||
return _this.touchEndTimeoutId; | ||
}; | ||
_this._shouldRecalculatePosition = function () { | ||
var _this$state6 = _this.state, | ||
slides = _this$state6.slides, | ||
currentIndex = _this$state6.currentIndex; | ||
return currentIndex < 0 || currentIndex >= slides.length; | ||
}; | ||
_this._setAnimationPropsOnClick = function (direction) { | ||
var _this$state7 = _this.state, | ||
currentIndex = _this$state7.currentIndex, | ||
itemWidth = _this$state7.itemWidth; | ||
var fadeOutIndex = Utils.getFadeOutIndexOnClick(currentIndex); | ||
var fadeOutOffset = Utils.getFadeOutOffsetOnClick(direction, itemWidth); | ||
_this._setAnimationProps({ | ||
fadeOutIndex: fadeOutIndex, | ||
fadeOutOffset: fadeOutOffset, | ||
allowFadeOutAnimation: true | ||
}); | ||
}; | ||
_this._renderSlideInfo = function () { | ||
var _this$state8 = _this.state, | ||
currentIndex = _this$state8.currentIndex, | ||
slides = _this$state8.slides; | ||
return _react["default"].createElement(Views.SlideInfo, { | ||
slidesLength: slides.length, | ||
currentIndex: currentIndex | ||
}); | ||
}; | ||
_this._renderStageItem = function (item, i) { | ||
var style = Utils.itemStyles(i, _this.state, _this.animationProps); | ||
var className = Utils.itemClassName(i, _this.state, _this.animationProps); | ||
return _react["default"].createElement(Views.StageItem, { | ||
styles: style, | ||
className: className, | ||
key: "stage-item-".concat(i), | ||
item: item | ||
}); | ||
}; | ||
var slides = Utils.getSlides(props); | ||
var clones = Utils.cloneCarouselItems(slides); | ||
_this.state = { | ||
clones: [], | ||
stagePadding: {}, | ||
clones: clones, | ||
currentIndex: 1, | ||
duration: props.duration, | ||
initialStageHeight: 0, | ||
isAutoPlaying: false, | ||
isAutoplayCanceledOnAction: false, | ||
duration: props.duration, | ||
slides: Utils.getSlides(props), | ||
slides: slides, | ||
stagePadding: {}, | ||
style: Utils.getDefaultStyles() | ||
@@ -622,5 +261,5 @@ }; | ||
var _this$state9 = this.state, | ||
isAutoPlaying = _this$state9.isAutoPlaying, | ||
isAutoplayCanceledOnAction = _this$state9.isAutoplayCanceledOnAction; | ||
var _this$state = this.state, | ||
isAutoPlaying = _this$state.isAutoPlaying, | ||
isAutoplayCanceledOnAction = _this$state.isAutoplayCanceledOnAction; | ||
var _this$props = this.props, | ||
@@ -760,8 +399,8 @@ disableAutoPlayOnAction = _this$props.disableAutoPlayOnAction, | ||
this.touchEndTimeoutId && clearTimeout(this.touchEndTimeoutId); | ||
var _this$state10 = this.state, | ||
slides = _this$state10.slides, | ||
items = _this$state10.items, | ||
itemWidth = _this$state10.itemWidth, | ||
infinite = _this$state10.infinite, | ||
stagePadding = _this$state10.stagePadding; | ||
var _this$state2 = this.state, | ||
slides = _this$state2.slides, | ||
items = _this$state2.items, | ||
itemWidth = _this$state2.itemWidth, | ||
infinite = _this$state2.infinite, | ||
stagePadding = _this$state2.stagePadding; | ||
var slidesLength = slides.length; | ||
@@ -834,7 +473,7 @@ var direction = Utils.getSwipeDirection(this.prevSwipPosition, deltaX); | ||
var transitionTimingFunction = this.props.transitionTimingFunction; | ||
var _this$state11 = this.state, | ||
itemWidth = _this$state11.itemWidth, | ||
items = _this$state11.items, | ||
duration = _this$state11.duration, | ||
infinite = _this$state11.infinite; | ||
var _this$state3 = this.state, | ||
itemWidth = _this$state3.itemWidth, | ||
items = _this$state3.items, | ||
duration = _this$state3.duration, | ||
infinite = _this$state3.infinite; | ||
var swipeIndex = Utils.calculateSwipeIndex(itemWidth, position, direction); | ||
@@ -881,7 +520,7 @@ var currentIndex = Utils.getSwipeIndexOnBeforeTouchEnd(swipeIndex, items); | ||
var transitionTimingFunction = this.props.transitionTimingFunction; | ||
var _this$state12 = this.state, | ||
items = _this$state12.items, | ||
itemWidth = _this$state12.itemWidth, | ||
duration = _this$state12.duration, | ||
slides = _this$state12.slides; | ||
var _this$state4 = this.state, | ||
items = _this$state4.items, | ||
itemWidth = _this$state4.itemWidth, | ||
duration = _this$state4.duration, | ||
slides = _this$state4.slides; | ||
var position = Utils.getTranslate3dPosition(currentIndex, { | ||
@@ -928,4 +567,4 @@ itemWidth: itemWidth, | ||
value: function _renderPrevButton() { | ||
var _Utils$itemInfo2 = Utils.itemInfo(this.state), | ||
isPrevSlideDisabled = _Utils$itemInfo2.isPrevSlideDisabled; | ||
var _Utils$itemInfo = Utils.itemInfo(this.state), | ||
isPrevSlideDisabled = _Utils$itemInfo.isPrevSlideDisabled; | ||
@@ -941,4 +580,4 @@ return _react["default"].createElement(Views.PrevNextButton, { | ||
value: function _renderNextButton() { | ||
var _Utils$itemInfo3 = Utils.itemInfo(this.state), | ||
isNextSlideDisabled = _Utils$itemInfo3.isNextSlideDisabled; | ||
var _Utils$itemInfo2 = Utils.itemInfo(this.state), | ||
isNextSlideDisabled = _Utils$itemInfo2.isNextSlideDisabled; | ||
@@ -971,6 +610,6 @@ return _react["default"].createElement(Views.PrevNextButton, { | ||
value: function render() { | ||
var _this$state13 = this.state, | ||
style = _this$state13.style, | ||
translate3d = _this$state13.translate3d, | ||
clones = _this$state13.clones; | ||
var _this$state5 = this.state, | ||
style = _this$state5.style, | ||
translate3d = _this$state5.translate3d, | ||
clones = _this$state5.clones; | ||
var wrapperStyles = Utils.getWrapperStyles(this.stageComponent, this.props, this.state); | ||
@@ -1002,3 +641,373 @@ var stageStyles = Utils.getStageStyles({ | ||
exports["default"] = AliceCarousel; | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this7 = this; | ||
this._handleOnWindowResize = function (e) { | ||
var shouldHandleResizeEvent = _this7.props.shouldHandleResizeEvent; | ||
var currentDimensions = Utils.getElementDimensions(_this7.rootComponent); | ||
var shouldProcessEvent = shouldHandleResizeEvent || Utils.shouldHandleResizeEvent; | ||
if (shouldProcessEvent(e, _this7.rootComponentDimensions, currentDimensions)) { | ||
_this7.rootComponentDimensions = currentDimensions; | ||
_this7._disableAnimation(); | ||
_this7._pause(); | ||
var _this7$state = _this7.state, | ||
currentIndex = _this7$state.currentIndex, | ||
isAutoPlaying = _this7$state.isAutoPlaying; | ||
var isAnimationCanceled = _this7._isSwipeAnimationProcessing(); | ||
var initialProps = Utils.preserveProps(_this7.props, { | ||
startIndex: currentIndex | ||
}); | ||
var currState = Utils.calculateInitialProps(initialProps, _this7.stageComponent); | ||
var translate3d = Utils.getTranslate3dPosition(currState.currentIndex, currState); | ||
var nextState = _objectSpread({}, currState, { | ||
translate3d: translate3d, | ||
isAnimationCanceled: isAnimationCanceled, | ||
isAutoPlaying: isAutoPlaying, | ||
initialStageHeight: 0 | ||
}); | ||
if (isAnimationCanceled) Utils.animate(_this7.stageComponent, { | ||
position: translate3d | ||
}); | ||
_this7.setState(nextState, function () { | ||
_this7._resetAllIntermediateProps(); | ||
isAutoPlaying && _this7._play(); | ||
_this7._onResized(); | ||
}); | ||
} | ||
}; | ||
this._handleOnAnimationCanceled = function () { | ||
_this7._resetAllIntermediateProps(); | ||
_this7.setState({ | ||
isAnimationCanceled: false | ||
}); | ||
}; | ||
this._handleOnKeyUp = function (e) { | ||
switch (e.code) { | ||
case 'Space': | ||
return _this7.props.autoPlay && _this7._playPauseToggle(); | ||
case 'ArrowLeft': | ||
return _this7.slidePrev(); | ||
case 'ArrowRight': | ||
return _this7.slideNext(); | ||
} | ||
}; | ||
this._handleOnMouseEnter = function () { | ||
if (_this7.props.stopAutoPlayOnHover && _this7.state.isAutoPlaying) { | ||
_this7.isHovered = true; | ||
_this7._pause(); | ||
} | ||
}; | ||
this._handleOnMouseLeave = function () { | ||
if (_this7.state.isAutoPlaying) { | ||
_this7.isHovered = false; | ||
_this7._play(); | ||
} | ||
}; | ||
this._onSlideToIndexChange = function (currentIndex, slideToIndex) { | ||
if (slideToIndex === currentIndex + 1) { | ||
_this7.slideNext(); | ||
} else if (slideToIndex === currentIndex - 1) { | ||
_this7.slidePrev(); | ||
} else { | ||
_this7.slideTo(slideToIndex); | ||
} | ||
}; | ||
this._onInactiveItem = function () { | ||
_this7._onSlideChange(); | ||
_this7._onSlideChanged(); | ||
}; | ||
this._getFadeOutAnimationState = function (shouldRecalculate) { | ||
if (shouldRecalculate || _this7._isFadeOutAnimationAllowed()) { | ||
return { | ||
fadeoutAnimationProcessing: false | ||
}; | ||
} | ||
return {}; | ||
}; | ||
this._setRootComponentRef = function (node) { | ||
return _this7.rootComponent = node; | ||
}; | ||
this._setStageComponentRef = function (node) { | ||
return _this7.stageComponent = node; | ||
}; | ||
this._allowAnimation = function () { | ||
return _this7.allowAnimation = true; | ||
}; | ||
this._disableAnimation = function () { | ||
return _this7.allowAnimation = false; | ||
}; | ||
this._skipSlidePositionRecalculation = function () { | ||
if (_this7._isFadeOutAnimationAllowed()) { | ||
return _this7._resetFadeOutAnimationState(); | ||
} | ||
_this7._onSlideChanged(); | ||
}; | ||
this._updateSlidePosition = function () { | ||
_this7._updateSlidePositionIntervalId = setTimeout(function () { | ||
if (_this7._shouldRecalculatePosition()) { | ||
_this7._recalculateSlidePosition(); | ||
} else if (_this7._isFadeOutAnimationAllowed()) { | ||
_this7._resetFadeOutAnimationState(); | ||
} else { | ||
_this7._onSlideChanged(); | ||
} | ||
}, _this7.state.duration); | ||
}; | ||
this._resetFadeOutAnimationState = function () { | ||
_this7.setState({ | ||
fadeoutAnimationProcessing: false | ||
}, _this7._onSlideChanged); | ||
}; | ||
this._resetAllIntermediateProps = function () { | ||
_this7.prevSwipPosition = 0; | ||
_this7.swipingStarted = false; | ||
_this7._stopSwipeAnimation(); | ||
_this7._resetAnimationProps(); | ||
_this7._resetSwipePositionProps(); | ||
_this7._clearUpdateSlidePositionIntervalId(); | ||
_this7._allowAnimation(); | ||
}; | ||
this._recalculateSlidePosition = function () { | ||
var style = Utils.getDefaultStyles(); | ||
var currentIndex = Utils.recalculateCurrentSlideIndex(_this7.state); | ||
var translate3d = Utils.recalculateTranslatePosition(_this7.state); | ||
_this7.setState(_objectSpread({ | ||
currentIndex: currentIndex, | ||
translate3d: translate3d, | ||
style: style | ||
}, _this7._getFadeOutAnimationState()), function () { | ||
return _this7._onSlideChanged(); | ||
}); | ||
}; | ||
this._getEventObject = function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this7.state; | ||
var itemsInSlide = state.items, | ||
item = state.currentIndex; | ||
var _Utils$itemInfo3 = Utils.itemInfo(state), | ||
isNextSlideDisabled = _Utils$itemInfo3.isNextSlideDisabled, | ||
isPrevSlideDisabled = _Utils$itemInfo3.isPrevSlideDisabled; | ||
var slide = Utils.getActiveSlideIndex(isNextSlideDisabled, state); | ||
return { | ||
item: item, | ||
slide: slide, | ||
itemsInSlide: itemsInSlide, | ||
isNextSlideDisabled: isNextSlideDisabled, | ||
isPrevSlideDisabled: isPrevSlideDisabled | ||
}; | ||
}; | ||
this.setAnimationPropsOnDotClick = function (itemIndex) { | ||
var _this7$state2 = _this7.state, | ||
currentIndex = _this7$state2.currentIndex, | ||
itemWidth = _this7$state2.itemWidth; | ||
var fadeOutIndex = currentIndex + 1; | ||
var fadeOutOffset = Utils.getFadeOutOffsetOnDotClick(itemIndex, currentIndex, itemWidth); | ||
_this7._setAnimationProps({ | ||
fadeOutIndex: fadeOutIndex, | ||
fadeOutOffset: fadeOutOffset, | ||
allowFadeOutAnimation: true | ||
}); | ||
}; | ||
this._pause = function () { | ||
_this7._clearAutoPlayInterval(); | ||
}; | ||
this._playPauseToggle = function () { | ||
var isAutoPlaying = _this7.state.isAutoPlaying; | ||
_this7.hasUserAction = true; | ||
_this7.setState({ | ||
isAutoPlaying: !isAutoPlaying, | ||
isAutoplayCanceledOnAction: true | ||
}, function () { | ||
isAutoPlaying ? _this7._pause() : _this7._play(); | ||
}); | ||
}; | ||
this._getIntermediateStateProps = function (duration, shouldSkipRecalculation) { | ||
var transitionTimingFunction = _this7.props.transitionTimingFunction; | ||
var condition = !shouldSkipRecalculation && _this7._isFadeOutAnimationAllowed(); | ||
return Utils.getIntermediateTransitionProps(condition, duration, transitionTimingFunction); | ||
}; | ||
this._startSwipeAnimation = function () { | ||
_this7.swipeAnimation = true; | ||
}; | ||
this._stopSwipeAnimation = function () { | ||
_this7.swipeAnimation = false; | ||
_this7.touchEndAnimation = false; | ||
_this7.touchEndTimeoutId = null; | ||
}; | ||
this._setAnimationProps = function (newProps) { | ||
var prevProps = _this7.animationProps || {}; | ||
_this7.animationProps = _objectSpread({}, prevProps, {}, newProps); | ||
}; | ||
this._resetAnimationProps = function () { | ||
_this7.animationProps = {}; | ||
}; | ||
this._setSwipePositionProps = function (newProps) { | ||
var prevProps = _this7.swipePosition || {}; | ||
_this7.swipePosition = _objectSpread({}, prevProps, {}, newProps); | ||
}; | ||
this._resetSwipePositionProps = function () { | ||
_this7.swipePosition = {}; | ||
}; | ||
this._getTranslateXPosition = function (deltaX) { | ||
var translate3d = _this7.state.translate3d; | ||
var lastSwipePosition = _this7.swipePosition.lastSwipePosition; | ||
var position = lastSwipePosition || translate3d; | ||
if (_this7.touchEndAnimation) { | ||
_this7.touchEndAnimation = false; | ||
var translateX = Utils.getTranslateX(_this7.stageComponent); | ||
if (translateX) { | ||
return translateX; | ||
} | ||
} | ||
return position - Math.floor(deltaX); | ||
}; | ||
this._onTouchEnd = function () { | ||
if (!_this7.swipingStarted || _this7._isSwipeDisabled()) return; | ||
_this7.swipingStarted = false; | ||
_this7.prevSwipPosition = 0; | ||
_this7._setSwipePositionProps({ | ||
lastSwipePosition: _this7.swipePosition.position | ||
}); | ||
_this7._beforeTouchEnd(); | ||
}; | ||
this._isClickDisabled = function (itemIndex) { | ||
var _this7$state3 = _this7.state, | ||
currentIndex = _this7$state3.currentIndex, | ||
isAnimationCanceled = _this7$state3.isAnimationCanceled; | ||
return currentIndex === itemIndex || isAnimationCanceled || !_this7.allowAnimation || _this7.swipeAnimation; | ||
}; | ||
this._isFadeOutAnimationAllowed = function () { | ||
var _this7$state4 = _this7.state, | ||
stagePadding = _this7$state4.stagePadding, | ||
items = _this7$state4.items; | ||
var hasNoStagePadding = !(stagePadding.paddingLeft || stagePadding.paddingRight); | ||
return _this7.props.fadeOutAnimation && items === 1 && hasNoStagePadding; | ||
}; | ||
this._isSwipeDisabled = function () { | ||
var _this7$state5 = _this7.state, | ||
isAnimationCanceled = _this7$state5.isAnimationCanceled, | ||
fadeoutAnimationProcessing = _this7$state5.fadeoutAnimationProcessing; | ||
return _this7.props.swipeDisabled || fadeoutAnimationProcessing || isAnimationCanceled; | ||
}; | ||
this._isSwipeAnimationLastFrame = function () { | ||
return !_this7.swipingStarted; | ||
}; | ||
this._isSwipeAnimationProcessing = function () { | ||
return _this7.touchEndTimeoutId; | ||
}; | ||
this._shouldRecalculatePosition = function () { | ||
var _this7$state6 = _this7.state, | ||
slides = _this7$state6.slides, | ||
currentIndex = _this7$state6.currentIndex; | ||
return currentIndex < 0 || currentIndex >= slides.length; | ||
}; | ||
this._setAnimationPropsOnClick = function (direction) { | ||
var _this7$state7 = _this7.state, | ||
currentIndex = _this7$state7.currentIndex, | ||
itemWidth = _this7$state7.itemWidth; | ||
var fadeOutIndex = Utils.getFadeOutIndexOnClick(currentIndex); | ||
var fadeOutOffset = Utils.getFadeOutOffsetOnClick(direction, itemWidth); | ||
_this7._setAnimationProps({ | ||
fadeOutIndex: fadeOutIndex, | ||
fadeOutOffset: fadeOutOffset, | ||
allowFadeOutAnimation: true | ||
}); | ||
}; | ||
this._renderSlideInfo = function () { | ||
var _this7$state8 = _this7.state, | ||
currentIndex = _this7$state8.currentIndex, | ||
slides = _this7$state8.slides; | ||
return _react["default"].createElement(Views.SlideInfo, { | ||
slidesLength: slides.length, | ||
currentIndex: currentIndex | ||
}); | ||
}; | ||
this._renderStageItem = function (item, i) { | ||
var style = Utils.itemStyles(i, _this7.state, _this7.animationProps); | ||
var className = Utils.itemClassName(i, _this7.state, _this7.animationProps); | ||
return _react["default"].createElement(Views.StageItem, { | ||
styles: style, | ||
className: className, | ||
key: "stage-item-".concat(i), | ||
item: item | ||
}); | ||
}; | ||
}; | ||
AliceCarousel.propTypes = _propTypes.propTypes; | ||
AliceCarousel.defaultProps = _propTypes.defaultProps; |
@@ -39,5 +39,12 @@ "use strict"; | ||
var itemStyles = function itemStyles(i, state, animationProps) { | ||
var fadeOutOffset = animationProps.fadeOutOffset; | ||
var itemWidth = state.itemWidth, | ||
duration = state.duration; | ||
var _ref = animationProps || {}, | ||
_ref$fadeOutOffset = _ref.fadeOutOffset, | ||
fadeOutOffset = _ref$fadeOutOffset === void 0 ? 0 : _ref$fadeOutOffset; | ||
var _ref2 = state || {}, | ||
_ref2$itemWidth = _ref2.itemWidth, | ||
itemWidth = _ref2$itemWidth === void 0 ? 0 : _ref2$itemWidth, | ||
_ref2$duration = _ref2.duration, | ||
duration = _ref2$duration === void 0 ? 0 : _ref2$duration; | ||
return Utils.isAnimatedItem(i, animationProps) ? { | ||
@@ -55,7 +62,7 @@ transform: "translateX(".concat(fadeOutOffset, "px)"), | ||
var getDefaultStyles = function getDefaultStyles(options) { | ||
var _ref = options || {}, | ||
_ref$duration = _ref.duration, | ||
duration = _ref$duration === void 0 ? 0 : _ref$duration, | ||
_ref$transitionTiming = _ref.transitionTimingFunction, | ||
transitionTimingFunction = _ref$transitionTiming === void 0 ? '' : _ref$transitionTiming; | ||
var _ref3 = options || {}, | ||
_ref3$duration = _ref3.duration, | ||
duration = _ref3$duration === void 0 ? 0 : _ref3$duration, | ||
_ref3$transitionTimin = _ref3.transitionTimingFunction, | ||
transitionTimingFunction = _ref3$transitionTimin === void 0 ? '' : _ref3$transitionTimin; | ||
@@ -62,0 +69,0 @@ return { |
{ | ||
"name": "react-alice-carousel", | ||
"version": "1.19.2", | ||
"version": "1.19.3", | ||
"description": "React image gallery, react slideshow carousel, react content rotator", | ||
@@ -5,0 +5,0 @@ "main": "./lib/react-alice-carousel", |
124605
2294