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.0 to 2.2.1

2

lib/Carousel.js

@@ -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(){return React.createElement(CarouselItems_1.default,{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,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;

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

goToSlide: (index: number) => void;
clones: any;
}
declare const CarouselItems: ({ props, state, goToSlide }: CarouselItemsProps) => any;
declare const CarouselItems: ({ props, state, goToSlide, clones }: CarouselItemsProps) => any;
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,s=l.itemWidth,t=l.clones,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,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;
{
"name": "react-multi-carousel",
"private": false,
"version": "2.2.0",
"version": "2.2.1",
"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

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