Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-multi-carousel

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-multi-carousel - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

2

lib/Carousel.d.ts

@@ -59,5 +59,5 @@ import * as React from "react";

renderDotsList(): React.ReactElement<any> | null;
renderCarouselItems(): any;
renderCarouselItems(): JSX.Element;
render(): React.ReactNode;
}
export default Carousel;

@@ -1,1 +0,1 @@

"use strict";var __extends=this&&this.__extends||function(){var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};return function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),utils_1=require("./utils"),Dots_1=require("./Dots"),Arrows_1=require("./Arrows"),CarouselItems_1=require("./CarouselItems"),defaultTransitionDuration=400,defaultTransition="transform 400ms ease-in-out",Carousel=function(i){function t(t){var e=i.call(this,t)||this;return e.containerRef=React.createRef(),e.state={itemWidth:0,slidesToShow:0,currentSlide:0,clones:React.Children.toArray(t.children),totalItems:React.Children.count(t.children),deviceType:"",domLoaded:!1,transform:0,containerWidth:0},e.onResize=e.onResize.bind(e),e.handleDown=e.handleDown.bind(e),e.handleMove=e.handleMove.bind(e),e.handleOut=e.handleOut.bind(e),e.onKeyUp=e.onKeyUp.bind(e),e.handleEnter=e.handleEnter.bind(e),e.setIsInThrottle=e.setIsInThrottle.bind(e),e.next=utils_1.throttle(e.next.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.previous=utils_1.throttle(e.previous.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.goToSlide=utils_1.throttle(e.goToSlide.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.onMove=!1,e.initialX=0,e.lastX=0,e.isAnimationAllowed=!1,e.direction="",e.initialY=0,e.isInThrottle=!1,e}return __extends(t,i),t.prototype.setIsInThrottle=function(t){void 0===t&&(t=!1),this.isInThrottle=t},t.prototype.componentDidMount=function(){this.setState({domLoaded:!0}),this.setItemsToShow(),window.addEventListener("resize",this.onResize),this.onResize(!0),this.props.keyBoardControl&&window.addEventListener("keyup",this.onKeyUp),this.props.autoPlay&&this.props.autoPlaySpeed&&(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed))},t.prototype.setClones=function(t,e,i){var o=this;this.isAnimationAllowed=!1;var s=React.Children.toArray(this.props.children),n=utils_1.getClones(this.state.slidesToShow,s),r=n.clones,a=n.initialSlide;utils_1.notEnoughChildren(this.state,this.props,t)||this.setState({clones:r,totalItems:r.length,currentSlide:i?this.state.currentSlide:a},function(){o.correctItemsPosition(e||o.state.itemWidth)})},t.prototype.setItemsToShow=function(r){var a=this,h=this.props.responsive;Object.keys(h).forEach(function(t){var e=h[t],i=e.breakpoint,o=e.items,s=i.max,n=i.min;window.innerWidth>=n&&window.innerWidth<=s&&(a.setState({slidesToShow:o,deviceType:t}),a.setContainerAndItemWidth(o,r))})},t.prototype.setContainerAndItemWidth=function(t,e){var i=this;if(this.containerRef&&this.containerRef.current){var o=this.containerRef.current.offsetWidth,s=utils_1.getItemClientSideWidth(this.props,t,o);this.setState({containerWidth:o,itemWidth:s},function(){i.props.infinite&&i.setClones(t,s,e)}),e&&this.correctItemsPosition(s)}},t.prototype.correctItemsPosition=function(t,e){e&&(this.isAnimationAllowed=!0),!e&&this.isAnimationAllowed&&(this.isAnimationAllowed=!1),this.setState({transform:-t*this.state.currentSlide})},t.prototype.onResize=function(t){var e;e=!!this.props.infinite&&("boolean"!=typeof t||!t),this.setItemsToShow(e)},t.prototype.componentDidUpdate=function(t,e){var i=this,o=t.keyBoardControl,s=t.autoPlay,n=e.containerWidth,r=e.domLoaded;this.containerRef&&this.containerRef.current&&this.containerRef.current.offsetWidth!==n&&setTimeout(function(){i.setItemsToShow(!0)},this.props.transitionDuration||defaultTransitionDuration),o&&!this.props.keyBoardControl&&window.removeEventListener("keyup",this.onKeyUp),s&&!this.props.autoPlay&&this.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0),s||!this.props.autoPlay||this.autoPlay||(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed)),this.props.infinite&&this.correctClonesPosition({domLoaded:r})},t.prototype.correctClonesPosition=function(t){var e=this,i=t.domLoaded,o=React.Children.toArray(this.props.children),s=utils_1.checkClonesPosition(this.state,o,this.props),n=s.isReachingTheEnd,r=s.isReachingTheStart,a=s.nextSlide,h=s.nextPosition;this.state.domLoaded&&i&&(n||r)&&(this.isAnimationAllowed=!1,setTimeout(function(){e.setState({transform:h,currentSlide:a})},this.props.transitionDuration||defaultTransitionDuration))},t.prototype.next=function(t){var e=this;void 0===t&&(t=0);var i=this.props,o=i.afterChange,s=i.beforeChange;if(!utils_1.notEnoughChildren(this.state,this.props)){var n=utils_1.populateNextSlides(this.state,this.props,t),r=n.nextSlides,a=n.nextPosition,h=this.state.currentSlide;void 0!==r&&void 0!==a&&("function"==typeof s&&s(r,this.getState()),this.isAnimationAllowed=!0,this.setState({transform:a,currentSlide:r},function(){"function"==typeof o&&setTimeout(function(){o(h,e.getState())},e.props.transitionDuration||defaultTransitionDuration)}))}},t.prototype.previous=function(t){var e=this;void 0===t&&(t=0);var i=this.props,o=i.afterChange,s=i.beforeChange;if(!utils_1.notEnoughChildren(this.state,this.props)){var n=utils_1.populatePreviousSlides(this.state,this.props,t),r=n.nextSlides,a=n.nextPosition;if(void 0!==r&&void 0!==a){var h=this.state.currentSlide;"function"==typeof s&&s(r,this.getState()),this.isAnimationAllowed=!0,this.setState({transform:a,currentSlide:r},function(){"function"==typeof o&&setTimeout(function(){o(h,e.getState())},e.props.transitionDuration||defaultTransitionDuration)})}}},t.prototype.componentWillUnmount=function(){window.removeEventListener("resize",this.onResize),this.props.keyBoardControl&&window.removeEventListener("keyup",this.onKeyUp),this.props.autoPlay&&this.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0)},t.prototype.resetMoveStatus=function(){this.onMove=!1,this.initialX=0,this.lastX=0,this.direction="",this.initialY=0},t.prototype.handleDown=function(t){if(!(t.touches&&!this.props.swipeable||!t.touches&&!this.props.draggable||this.isInThrottle)){var e=t.touches?t.touches[0]:t,i=e.clientX,o=e.clientY;this.onMove=!0,this.initialX=i,this.initialY=o,this.lastX=i,this.isAnimationAllowed=!1}},t.prototype.handleMove=function(t){if(!(t.touches&&!this.props.swipeable||t&&!t.touches&&!this.props.draggable||utils_1.notEnoughChildren(this.state,this.props))){var e=t.touches?t.touches[0]:t,i=e.clientX,o=e.clientY,s=this.initialX-i,n=this.initialY-o;if(t.touches&&this.autoPlay&&this.props.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0),this.onMove){if(!(Math.abs(s)>Math.abs(n)))return;var r=utils_1.populateSlidesOnMouseTouchMove(this.state,this.props,this.initialX,this.lastX,i),a=r.direction,h=r.nextPosition,l=r.canContinue;a&&(this.direction=a,l&&void 0!==h&&this.setState({transform:h})),this.lastX=i}}},t.prototype.handleOut=function(t){this.props.autoPlay&&!this.autoPlay&&(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed));var e="touchend"===t.type&&!this.props.swipeable,i=("mouseleave"===t.type||"mouseup"===t.type)&&!this.props.draggable;if(!e&&!i&&this.onMove){if("right"===this.direction)if(this.initialX-this.lastX>=this.props.minimumTouchDrag){var o=Math.round((this.initialX-this.lastX)/this.state.itemWidth);this.next(o)}else this.correctItemsPosition(this.state.itemWidth,!0);if("left"===this.direction)if(this.lastX-this.initialX>this.props.minimumTouchDrag){o=Math.round((this.lastX-this.initialX)/this.state.itemWidth);this.previous(o)}else this.correctItemsPosition(this.state.itemWidth,!0);this.resetMoveStatus()}},t.prototype.onKeyUp=function(t){switch(t.keyCode){case 37:return this.previous();case 39:return this.next()}},t.prototype.handleEnter=function(){this.autoPlay&&this.props.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0)},t.prototype.goToSlide=function(t){var e=this;if(!this.isInThrottle){var i=this.state.itemWidth,o=this.props,s=o.afterChange,n=o.beforeChange,r=this.state.currentSlide;"function"==typeof n&&n(t,this.getState()),this.isAnimationAllowed=!0,this.setState({currentSlide:t,transform:-i*t},function(){e.props.infinite&&e.correctClonesPosition({domLoaded:!0}),"function"==typeof s&&setTimeout(function(){s(r,e.getState())},e.props.transitionDuration||defaultTransitionDuration)})}},t.prototype.getState=function(){return __assign({},this.state,{onMove:this.onMove,direction:this.direction})},t.prototype.renderLeftArrow=function(){var t=this,e=this.props.customLeftArrow;return React.createElement(Arrows_1.LeftArrow,{customLeftArrow:e,getState:function(){return t.getState()},previous:this.previous})},t.prototype.renderRightArrow=function(){var t=this,e=this.props.customRightArrow;return React.createElement(Arrows_1.RightArrow,{customRightArrow:e,getState:function(){return t.getState()},next:this.next})},t.prototype.renderButtonGroups=function(){var e=this,t=this.props.customButtonGroup;return t?React.cloneElement(t,{previous:function(){return e.previous()},next:function(){return e.next()},goToSlide:function(t){return e.goToSlide(t)},carouselState:this.getState()}):null},t.prototype.renderDotsList=function(){var t=this;return React.createElement(Dots_1.default,{state:this.state,props:this.props,goToSlide:this.goToSlide,getState:function(){return t.getState()}})},t.prototype.renderCarouselItems=function(){var t=React.Children.toArray(this.props.children),e=utils_1.getClones(this.state.slidesToShow,t).clones;return React.createElement(CarouselItems_1.default,{clones:e,goToSlide:this.goToSlide,state:this.state,props:this.props})},t.prototype.render=function(){var t=this.props,e=t.deviceType,i=t.arrows,o=t.removeArrowOnDeviceType,s=t.infinite,n=t.containerClass,r=t.sliderClass,a=t.customTransition,h=t.partialVisbile,l=t.centerMode,u=t.additionalTransfrom,p=t.renderDotsOutside,d=t.className;utils_1.throwError(this.state,this.props);var c=utils_1.getInitialState(this.state,this.props),f=c.shouldRenderOnSSR,m=c.paritialVisibilityGutter,v=c.shouldRenderAtAll,y=utils_1.isInLeftEnd(this.state),S=utils_1.isInRightEnd(this.state),g=i&&!(o&&(e&&-1<o.indexOf(e)||this.state.deviceType&&-1<o.indexOf(this.state.deviceType)))&&!utils_1.notEnoughChildren(this.state,this.props)&&v,w=!s&&y,T=!s&&S,_=h?utils_1.getTransformForPartialVsibile(this.state,m,this.props):l?utils_1.getTransformForCenterMode(this.state,this.props):this.state.transform;return React.createElement(React.Fragment,null,React.createElement("div",{className:"react-multi-carousel-list "+n+" "+d,ref:this.containerRef},React.createElement("ul",{className:"react-multi-carousel-track "+r,style:{transition:this.isAnimationAllowed?a||defaultTransition:"none",overflow:f?"hidden":"unset",transform:"translate3d("+(_+u)+"px,0,0)"},onMouseMove:this.handleMove,onMouseDown:this.handleDown,onMouseUp:this.handleOut,onMouseEnter:this.handleEnter,onMouseLeave:this.handleOut,onTouchStart:this.handleDown,onTouchMove:this.handleMove,onTouchEnd:this.handleOut},this.renderCarouselItems()),g&&!w&&this.renderLeftArrow(),g&&!T&&this.renderRightArrow(),v&&this.renderButtonGroups(),v&&!p&&this.renderDotsList()),v&&p&&this.renderDotsList())},t.defaultProps={slidesToSlide:1,infinite:!1,draggable:!0,swipeable:!0,arrows:!0,containerClass:"",sliderClass:"",itemClass:"",keyBoardControl:!0,autoPlaySpeed:3e3,showDots:!1,renderDotsOutside:!1,minimumTouchDrag:80,dotListClass:"",focusOnSelect:!1,centerMode:!1,additionalTransfrom:0},t}(React.Component);exports.default=Carousel;
"use strict";var __extends=this&&this.__extends||function(){var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};return function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),utils_1=require("./utils"),Dots_1=require("./Dots"),Arrows_1=require("./Arrows"),CarouselItems_1=require("./CarouselItems"),defaultTransitionDuration=400,defaultTransition="transform 400ms ease-in-out",Carousel=function(i){function t(t){var e=i.call(this,t)||this;return e.containerRef=React.createRef(),e.state={itemWidth:0,slidesToShow:0,currentSlide:0,totalItems:React.Children.count(t.children),deviceType:"",domLoaded:!1,transform:0,containerWidth:0},e.onResize=e.onResize.bind(e),e.handleDown=e.handleDown.bind(e),e.handleMove=e.handleMove.bind(e),e.handleOut=e.handleOut.bind(e),e.onKeyUp=e.onKeyUp.bind(e),e.handleEnter=e.handleEnter.bind(e),e.setIsInThrottle=e.setIsInThrottle.bind(e),e.next=utils_1.throttle(e.next.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.previous=utils_1.throttle(e.previous.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.goToSlide=utils_1.throttle(e.goToSlide.bind(e),t.transitionDuration||defaultTransitionDuration,e.setIsInThrottle),e.onMove=!1,e.initialX=0,e.lastX=0,e.isAnimationAllowed=!1,e.direction="",e.initialY=0,e.isInThrottle=!1,e}return __extends(t,i),t.prototype.setIsInThrottle=function(t){void 0===t&&(t=!1),this.isInThrottle=t},t.prototype.componentDidMount=function(){this.setState({domLoaded:!0}),this.setItemsToShow(),window.addEventListener("resize",this.onResize),this.onResize(!0),this.props.keyBoardControl&&window.addEventListener("keyup",this.onKeyUp),this.props.autoPlay&&this.props.autoPlaySpeed&&(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed))},t.prototype.setClones=function(t,e,i){var o=this;this.isAnimationAllowed=!1;var s=React.Children.toArray(this.props.children),n=utils_1.getInitialSlideInInifteMode(t||this.state.slidesToShow,s),r=utils_1.getClones(this.state.slidesToShow,s);utils_1.notEnoughChildren(this.state,this.props,t)||this.setState({totalItems:r.length,currentSlide:i?this.state.currentSlide:n},function(){o.correctItemsPosition(e||o.state.itemWidth)})},t.prototype.setItemsToShow=function(r){var a=this,h=this.props.responsive;Object.keys(h).forEach(function(t){var e=h[t],i=e.breakpoint,o=e.items,s=i.max,n=i.min;window.innerWidth>=n&&window.innerWidth<=s&&(a.setState({slidesToShow:o,deviceType:t}),a.setContainerAndItemWidth(o,r))})},t.prototype.setContainerAndItemWidth=function(t,e){var i=this;if(this.containerRef&&this.containerRef.current){var o=this.containerRef.current.offsetWidth,s=utils_1.getItemClientSideWidth(this.props,t,o);this.setState({containerWidth:o,itemWidth:s},function(){i.props.infinite&&i.setClones(t,s,e)}),e&&this.correctItemsPosition(s)}},t.prototype.correctItemsPosition=function(t,e){e&&(this.isAnimationAllowed=!0),!e&&this.isAnimationAllowed&&(this.isAnimationAllowed=!1),this.setState({transform:-t*this.state.currentSlide})},t.prototype.onResize=function(t){var e;e=!!this.props.infinite&&("boolean"!=typeof t||!t),this.setItemsToShow(e)},t.prototype.componentDidUpdate=function(t,e){var i=this,o=t.keyBoardControl,s=t.autoPlay,n=e.containerWidth,r=e.domLoaded;this.containerRef&&this.containerRef.current&&this.containerRef.current.offsetWidth!==n&&setTimeout(function(){i.setItemsToShow(!0)},this.props.transitionDuration||defaultTransitionDuration),o&&!this.props.keyBoardControl&&window.removeEventListener("keyup",this.onKeyUp),s&&!this.props.autoPlay&&this.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0),s||!this.props.autoPlay||this.autoPlay||(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed)),this.props.infinite&&this.correctClonesPosition({domLoaded:r})},t.prototype.correctClonesPosition=function(t){var e=this,i=t.domLoaded,o=React.Children.toArray(this.props.children),s=utils_1.checkClonesPosition(this.state,o,this.props),n=s.isReachingTheEnd,r=s.isReachingTheStart,a=s.nextSlide,h=s.nextPosition;this.state.domLoaded&&i&&(n||r)&&(this.isAnimationAllowed=!1,setTimeout(function(){e.setState({transform:h,currentSlide:a})},this.props.transitionDuration||defaultTransitionDuration))},t.prototype.next=function(t){var e=this;void 0===t&&(t=0);var i=this.props,o=i.afterChange,s=i.beforeChange;if(!utils_1.notEnoughChildren(this.state,this.props)){var n=utils_1.populateNextSlides(this.state,this.props,t),r=n.nextSlides,a=n.nextPosition,h=this.state.currentSlide;void 0!==r&&void 0!==a&&("function"==typeof s&&s(r,this.getState()),this.isAnimationAllowed=!0,this.setState({transform:a,currentSlide:r},function(){"function"==typeof o&&setTimeout(function(){o(h,e.getState())},e.props.transitionDuration||defaultTransitionDuration)}))}},t.prototype.previous=function(t){var e=this;void 0===t&&(t=0);var i=this.props,o=i.afterChange,s=i.beforeChange;if(!utils_1.notEnoughChildren(this.state,this.props)){var n=utils_1.populatePreviousSlides(this.state,this.props,t),r=n.nextSlides,a=n.nextPosition;if(void 0!==r&&void 0!==a){var h=this.state.currentSlide;"function"==typeof s&&s(r,this.getState()),this.isAnimationAllowed=!0,this.setState({transform:a,currentSlide:r},function(){"function"==typeof o&&setTimeout(function(){o(h,e.getState())},e.props.transitionDuration||defaultTransitionDuration)})}}},t.prototype.componentWillUnmount=function(){window.removeEventListener("resize",this.onResize),this.props.keyBoardControl&&window.removeEventListener("keyup",this.onKeyUp),this.props.autoPlay&&this.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0)},t.prototype.resetMoveStatus=function(){this.onMove=!1,this.initialX=0,this.lastX=0,this.direction="",this.initialY=0},t.prototype.handleDown=function(t){if(!(t.touches&&!this.props.swipeable||!t.touches&&!this.props.draggable||this.isInThrottle)){var e=t.touches?t.touches[0]:t,i=e.clientX,o=e.clientY;this.onMove=!0,this.initialX=i,this.initialY=o,this.lastX=i,this.isAnimationAllowed=!1}},t.prototype.handleMove=function(t){if(!(t.touches&&!this.props.swipeable||t&&!t.touches&&!this.props.draggable||utils_1.notEnoughChildren(this.state,this.props))){var e=t.touches?t.touches[0]:t,i=e.clientX,o=e.clientY,s=this.initialX-i,n=this.initialY-o;if(t.touches&&this.autoPlay&&this.props.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0),this.onMove){if(!(Math.abs(s)>Math.abs(n)))return;var r=utils_1.populateSlidesOnMouseTouchMove(this.state,this.props,this.initialX,this.lastX,i),a=r.direction,h=r.nextPosition,l=r.canContinue;a&&(this.direction=a,l&&void 0!==h&&this.setState({transform:h})),this.lastX=i}}},t.prototype.handleOut=function(t){this.props.autoPlay&&!this.autoPlay&&(this.autoPlay=setInterval(this.next,this.props.autoPlaySpeed));var e="touchend"===t.type&&!this.props.swipeable,i=("mouseleave"===t.type||"mouseup"===t.type)&&!this.props.draggable;if(!e&&!i&&this.onMove){if("right"===this.direction)if(this.initialX-this.lastX>=this.props.minimumTouchDrag){var o=Math.round((this.initialX-this.lastX)/this.state.itemWidth);this.next(o)}else this.correctItemsPosition(this.state.itemWidth,!0);if("left"===this.direction)if(this.lastX-this.initialX>this.props.minimumTouchDrag){o=Math.round((this.lastX-this.initialX)/this.state.itemWidth);this.previous(o)}else this.correctItemsPosition(this.state.itemWidth,!0);this.resetMoveStatus()}},t.prototype.onKeyUp=function(t){switch(t.keyCode){case 37:return this.previous();case 39:return this.next()}},t.prototype.handleEnter=function(){this.autoPlay&&this.props.autoPlay&&(clearInterval(this.autoPlay),this.autoPlay=void 0)},t.prototype.goToSlide=function(t){var e=this;if(!this.isInThrottle){var i=this.state.itemWidth,o=this.props,s=o.afterChange,n=o.beforeChange,r=this.state.currentSlide;"function"==typeof n&&n(t,this.getState()),this.isAnimationAllowed=!0,this.setState({currentSlide:t,transform:-i*t},function(){e.props.infinite&&e.correctClonesPosition({domLoaded:!0}),"function"==typeof s&&setTimeout(function(){s(r,e.getState())},e.props.transitionDuration||defaultTransitionDuration)})}},t.prototype.getState=function(){return __assign({},this.state,{onMove:this.onMove,direction:this.direction})},t.prototype.renderLeftArrow=function(){var t=this,e=this.props.customLeftArrow;return React.createElement(Arrows_1.LeftArrow,{customLeftArrow:e,getState:function(){return t.getState()},previous:this.previous})},t.prototype.renderRightArrow=function(){var t=this,e=this.props.customRightArrow;return React.createElement(Arrows_1.RightArrow,{customRightArrow:e,getState:function(){return t.getState()},next:this.next})},t.prototype.renderButtonGroups=function(){var e=this,t=this.props.customButtonGroup;return t?React.cloneElement(t,{previous:function(){return e.previous()},next:function(){return e.next()},goToSlide:function(t){return e.goToSlide(t)},carouselState:this.getState()}):null},t.prototype.renderDotsList=function(){var t=this;return React.createElement(Dots_1.default,{state:this.state,props:this.props,goToSlide:this.goToSlide,getState:function(){return t.getState()}})},t.prototype.renderCarouselItems=function(){var t=[];if(this.props.infinite){var e=React.Children.toArray(this.props.children);t=utils_1.getClones(this.state.slidesToShow,e)}return React.createElement(CarouselItems_1.default,{clones:t,goToSlide:this.goToSlide,state:this.state,props:this.props})},t.prototype.render=function(){var t=this.props,e=t.deviceType,i=t.arrows,o=t.removeArrowOnDeviceType,s=t.infinite,n=t.containerClass,r=t.sliderClass,a=t.customTransition,h=t.partialVisbile,l=t.centerMode,u=t.additionalTransfrom,p=t.renderDotsOutside,d=t.className;"production"!==process.env.NODE_ENV&&utils_1.throwError(this.state,this.props);var c=utils_1.getInitialState(this.state,this.props),f=c.shouldRenderOnSSR,m=c.paritialVisibilityGutter,v=c.shouldRenderAtAll,y=utils_1.isInLeftEnd(this.state),S=utils_1.isInRightEnd(this.state),g=i&&!(o&&(e&&-1<o.indexOf(e)||this.state.deviceType&&-1<o.indexOf(this.state.deviceType)))&&!utils_1.notEnoughChildren(this.state,this.props)&&v,w=!s&&y,T=!s&&S,_=h?utils_1.getTransformForPartialVsibile(this.state,m,this.props):l?utils_1.getTransformForCenterMode(this.state,this.props):this.state.transform;return React.createElement(React.Fragment,null,React.createElement("div",{className:"react-multi-carousel-list "+n+" "+d,ref:this.containerRef},React.createElement("ul",{className:"react-multi-carousel-track "+r,style:{transition:this.isAnimationAllowed?a||defaultTransition:"none",overflow:f?"hidden":"unset",transform:"translate3d("+(_+u)+"px,0,0)"},onMouseMove:this.handleMove,onMouseDown:this.handleDown,onMouseUp:this.handleOut,onMouseEnter:this.handleEnter,onMouseLeave:this.handleOut,onTouchStart:this.handleDown,onTouchMove:this.handleMove,onTouchEnd:this.handleOut},this.renderCarouselItems()),g&&!w&&this.renderLeftArrow(),g&&!T&&this.renderRightArrow(),v&&this.renderButtonGroups(),v&&!p&&this.renderDotsList()),v&&p&&this.renderDotsList())},t.defaultProps={slidesToSlide:1,infinite:!1,draggable:!0,swipeable:!0,arrows:!0,containerClass:"",sliderClass:"",itemClass:"",keyBoardControl:!0,autoPlaySpeed:3e3,showDots:!1,renderDotsOutside:!1,minimumTouchDrag:80,dotListClass:"",focusOnSelect:!1,centerMode:!1,additionalTransfrom:0},t}(React.Component);exports.default=Carousel;

@@ -0,1 +1,2 @@

/// <reference types="react" />
import { CarouselInternalState, CarouselProps } from "./types";

@@ -5,6 +6,6 @@ interface CarouselItemsProps {

state: CarouselInternalState;
clones: any[];
goToSlide: (index: number) => void;
clones: any;
}
declare const CarouselItems: ({ props, state, goToSlide, clones }: CarouselItemsProps) => any;
declare const CarouselItems: ({ props, state, goToSlide, clones, }: CarouselItemsProps) => JSX.Element | null;
export default CarouselItems;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),utils_1=require("./utils"),CarouselItems=function(e){var i=e.props,l=e.state,a=e.goToSlide,t=e.clones,s=l.itemWidth,r=i.children,u=i.infinite,n=i.itemClass,o=i.partialVisbile,c=utils_1.getInitialState(l,i),d=c.flexBisis,f=c.shouldRenderOnSSR,m=c.domFullyLoaded,p=c.paritialVisibilityGutter;return c.shouldRenderAtAll?u?t.map(function(e,t){return React.createElement("li",{key:t,onClick:function(){i.focusOnSelect&&a(t)},"aria-hidden":utils_1.getIfSlideIsVisbile(t,l)?"false":"true","data-index":t,style:{flex:f?"1 0 "+d+"%":"auto",position:"relative",width:m?(o&&p?s-p:s)+"px":"auto"},className:"react-multi-carousel-item "+(utils_1.getIfSlideIsVisbile(t,l)?"react-multi-carousel-item--active":"")+" "+n},e)}):React.Children.toArray(r).map(function(e,t){return React.createElement("li",{key:t,"data-index":t,onClick:function(){i.focusOnSelect&&a(t)},"aria-hidden":utils_1.getIfSlideIsVisbile(t,l)?"false":"true",style:{flex:f?"1 0 "+d+"%":"auto",position:"relative",width:m?(o&&p?s-p:s)+"px":"auto"},className:"react-multi-carousel-item "+(utils_1.getIfSlideIsVisbile(t,l)?"react-multi-carousel-item--active":"")+" "+n},e)}):null};exports.default=CarouselItems;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),utils_1=require("./utils"),CarouselItems=function(e){var i=e.props,l=e.state,a=e.goToSlide,t=e.clones,r=l.itemWidth,s=i.children,u=i.infinite,n=i.itemClass,o=i.partialVisbile,c=utils_1.getInitialState(l,i),d=c.flexBisis,m=c.shouldRenderOnSSR,f=c.domFullyLoaded,p=c.paritialVisibilityGutter;return c.shouldRenderAtAll?React.createElement(React.Fragment,null,(u?t:React.Children.toArray(s)).map(function(e,t){return React.createElement("li",{key:t,"data-index":t,onClick:function(){i.focusOnSelect&&a(t)},"aria-hidden":utils_1.getIfSlideIsVisbile(t,l)?"false":"true",style:{flex:m?"1 0 "+d+"%":"auto",position:"relative",width:f?(o&&p?r-p:r)+"px":"auto"},className:"react-multi-carousel-item "+(utils_1.getIfSlideIsVisbile(t,l)?"react-multi-carousel-item--active":"")+" "+n},e)})):null};exports.default=CarouselItems;

@@ -79,3 +79,2 @@ import * as React from "react";

isSliding?: boolean;
clones: any[];
}

@@ -82,0 +81,0 @@ export default class Carousel extends React.PureComponent<CarouselProps> {

@@ -11,6 +11,4 @@ import { CarouselInternalState, CarouselProps } from "../types";

declare function getOriginalIndexLookupTableByClones(slidesToShow: number, childrenArr: any[]): Table;
declare function getClones(slidesToShow: number, childrenArr: any[]): {
clones: any[];
initialSlide: number;
};
declare function getClones(slidesToShow: number, childrenArr: any[]): any[];
declare function getInitialSlideInInifteMode(slidesToShow: number, childrenArr: any[]): number;
declare function checkClonesPosition({ currentSlide, slidesToShow, itemWidth, totalItems }: CarouselInternalState, childrenArr: any[], props: CarouselProps): {

@@ -22,2 +20,2 @@ isReachingTheEnd: boolean;

};
export { getOriginalCounterPart, getOriginalIndexLookupTableByClones, getClones, checkClonesPosition, };
export { getOriginalCounterPart, getOriginalIndexLookupTableByClones, getClones, checkClonesPosition, getInitialSlideInInifteMode };

@@ -1,1 +0,1 @@

"use strict";function getOriginalCounterPart(e,t,n){var l=t.slidesToShow,o=t.currentSlide;return n.length>2*l?e+2*l:o>=n.length?n.length+e:e}function getOriginalIndexLookupTableByClones(e,t){if(t.length>2*e){for(var n={},l=t.length-2*e,o=t.length-l,r=l,i=0;i<o;i++)n[i]=r,r++;var g=t.length+o,h=g+t.slice(0,2*e).length,s=0;for(i=g;i<=h;i++)n[i]=s,s++;var a=g,c=0;for(i=o;i<a;i++)n[i]=c,c++;return n}n={};var u=3*t.length,d=0;for(i=0;i<u;i++)n[i]=d,++d===t.length&&(d=0);return n}function getClones(e,t){var n,l;return n=t.length>2*e?(l=t.slice(t.length-2*e,t.length).concat(t,t.slice(0,2*e)),2*e):(l=t.concat(t,t),t.length),{clones:l,initialSlide:n}}function checkClonesPosition(e,t,n){var l,o=e.currentSlide,r=e.slidesToShow,i=e.itemWidth,g=e.totalItems,h=0,s=0,a=0===o,c=t.length-(t.length-2*r);return t.length>2*r?((l=o>=c+t.length)&&(s=-i*(h=o-t.length)),a&&(s=-i*(h=c+(t.length-2*r)))):((l=o>=2*t.length)&&(s=-i*(h=o-t.length)),a&&(s=n.showDots?-i*(h=t.length):-i*(h=g-2*r))),{isReachingTheEnd:l,isReachingTheStart:a,nextSlide:h,nextPosition:s}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getOriginalCounterPart=getOriginalCounterPart,exports.getOriginalIndexLookupTableByClones=getOriginalIndexLookupTableByClones,exports.getClones=getClones,exports.checkClonesPosition=checkClonesPosition;
"use strict";function getOriginalCounterPart(e,t,n){var l=t.slidesToShow,o=t.currentSlide;return n.length>2*l?e+2*l:o>=n.length?n.length+e:e}function getOriginalIndexLookupTableByClones(e,t){if(t.length>2*e){for(var n={},l=t.length-2*e,o=t.length-l,i=l,r=0;r<o;r++)n[r]=i,i++;var g=t.length+o,h=g+t.slice(0,2*e).length,s=0;for(r=g;r<=h;r++)n[r]=s,s++;var a=g,c=0;for(r=o;r<a;r++)n[r]=c,c++;return n}n={};var u=3*t.length,d=0;for(r=0;r<u;r++)n[r]=d,++d===t.length&&(d=0);return n}function getClones(e,t){return t.length>2*e?t.slice(t.length-2*e,t.length).concat(t,t.slice(0,2*e)):t.concat(t,t)}function getInitialSlideInInifteMode(e,t){return t.length>2*e?2*e:t.length}function checkClonesPosition(e,t,n){var l,o=e.currentSlide,i=e.slidesToShow,r=e.itemWidth,g=e.totalItems,h=0,s=0,a=0===o,c=t.length-(t.length-2*i);return t.length>2*i?((l=o>=c+t.length)&&(s=-r*(h=o-t.length)),a&&(s=-r*(h=c+(t.length-2*i)))):((l=o>=2*t.length)&&(s=-r*(h=o-t.length)),a&&(s=n.showDots?-r*(h=t.length):-r*(h=g-2*i))),{isReachingTheEnd:l,isReachingTheStart:a,nextSlide:h,nextPosition:s}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getOriginalCounterPart=getOriginalCounterPart,exports.getOriginalIndexLookupTableByClones=getOriginalIndexLookupTableByClones,exports.getClones=getClones,exports.getInitialSlideInInifteMode=getInitialSlideInInifteMode,exports.checkClonesPosition=checkClonesPosition;

@@ -1,2 +0,2 @@

import { getOriginalCounterPart, getClones, checkClonesPosition } from "./clones";
import { getOriginalCounterPart, getClones, checkClonesPosition, getInitialSlideInInifteMode } from "./clones";
import { getWidthFromDeviceType, getParitialVisibilityGutter, getItemClientSideWidth } from "./elementWidth";

@@ -9,2 +9,2 @@ import { getInitialState, getIfSlideIsVisbile, getTransformForCenterMode, getTransformForPartialVsibile, isInLeftEnd, isInRightEnd, notEnoughChildren, getSlidesToSlide } from "./common";

import { populateSlidesOnMouseTouchMove } from "./mouseOrTouchMove";
export { isInLeftEnd, isInRightEnd, getOriginalCounterPart, getClones, getSlidesToSlide, getWidthFromDeviceType, checkClonesPosition, getItemClientSideWidth, getParitialVisibilityGutter, throttle, getInitialState, getIfSlideIsVisbile, getTransformForCenterMode, getTransformForPartialVsibile, throwError, populateNextSlides, populatePreviousSlides, populateSlidesOnMouseTouchMove, notEnoughChildren };
export { isInLeftEnd, isInRightEnd, getOriginalCounterPart, getClones, getSlidesToSlide, getWidthFromDeviceType, checkClonesPosition, getItemClientSideWidth, getParitialVisibilityGutter, throttle, getInitialState, getIfSlideIsVisbile, getTransformForCenterMode, getTransformForPartialVsibile, throwError, populateNextSlides, populatePreviousSlides, populateSlidesOnMouseTouchMove, notEnoughChildren, getInitialSlideInInifteMode };

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var clones_1=require("./clones");exports.getOriginalCounterPart=clones_1.getOriginalCounterPart,exports.getClones=clones_1.getClones,exports.checkClonesPosition=clones_1.checkClonesPosition;var elementWidth_1=require("./elementWidth");exports.getWidthFromDeviceType=elementWidth_1.getWidthFromDeviceType,exports.getParitialVisibilityGutter=elementWidth_1.getParitialVisibilityGutter,exports.getItemClientSideWidth=elementWidth_1.getItemClientSideWidth;var common_1=require("./common");exports.getInitialState=common_1.getInitialState,exports.getIfSlideIsVisbile=common_1.getIfSlideIsVisbile,exports.getTransformForCenterMode=common_1.getTransformForCenterMode,exports.getTransformForPartialVsibile=common_1.getTransformForPartialVsibile,exports.isInLeftEnd=common_1.isInLeftEnd,exports.isInRightEnd=common_1.isInRightEnd,exports.notEnoughChildren=common_1.notEnoughChildren,exports.getSlidesToSlide=common_1.getSlidesToSlide;var throttle_1=require("./throttle");exports.throttle=throttle_1.default;var throwError_1=require("./throwError");exports.throwError=throwError_1.default;var next_1=require("./next");exports.populateNextSlides=next_1.populateNextSlides;var previous_1=require("./previous");exports.populatePreviousSlides=previous_1.populatePreviousSlides;var mouseOrTouchMove_1=require("./mouseOrTouchMove");exports.populateSlidesOnMouseTouchMove=mouseOrTouchMove_1.populateSlidesOnMouseTouchMove;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var clones_1=require("./clones");exports.getOriginalCounterPart=clones_1.getOriginalCounterPart,exports.getClones=clones_1.getClones,exports.checkClonesPosition=clones_1.checkClonesPosition,exports.getInitialSlideInInifteMode=clones_1.getInitialSlideInInifteMode;var elementWidth_1=require("./elementWidth");exports.getWidthFromDeviceType=elementWidth_1.getWidthFromDeviceType,exports.getParitialVisibilityGutter=elementWidth_1.getParitialVisibilityGutter,exports.getItemClientSideWidth=elementWidth_1.getItemClientSideWidth;var common_1=require("./common");exports.getInitialState=common_1.getInitialState,exports.getIfSlideIsVisbile=common_1.getIfSlideIsVisbile,exports.getTransformForCenterMode=common_1.getTransformForCenterMode,exports.getTransformForPartialVsibile=common_1.getTransformForPartialVsibile,exports.isInLeftEnd=common_1.isInLeftEnd,exports.isInRightEnd=common_1.isInRightEnd,exports.notEnoughChildren=common_1.notEnoughChildren,exports.getSlidesToSlide=common_1.getSlidesToSlide;var throttle_1=require("./throttle");exports.throttle=throttle_1.default;var throwError_1=require("./throwError");exports.throwError=throwError_1.default;var next_1=require("./next");exports.populateNextSlides=next_1.populateNextSlides;var previous_1=require("./previous");exports.populatePreviousSlides=previous_1.populatePreviousSlides;var mouseOrTouchMove_1=require("./mouseOrTouchMove");exports.populateSlidesOnMouseTouchMove=mouseOrTouchMove_1.populateSlidesOnMouseTouchMove;
{
"name": "react-multi-carousel",
"private": false,
"version": "2.2.1",
"version": "2.2.2",
"description": "Production-ready, lightweight fully customizable React carousel component that rocks supports multiple items and SSR(Server-side rendering) with typescript.",

@@ -6,0 +6,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc