react-multi-carousel
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -12,3 +12,5 @@ import * as React from "react"; | ||
autoPlay?: any; | ||
isInThrottle?: boolean; | ||
constructor(props: CarouselProps); | ||
setIsInThrottle(isInThrottle?: boolean): void; | ||
componentDidMount(): void; | ||
@@ -15,0 +17,0 @@ setClones(slidesToShow: number, itemWidth?: number, forResizing?: boolean): void; |
@@ -30,2 +30,3 @@ "use strict"; | ||
this.handleEnter = this.handleEnter.bind(this); | ||
this.setIsInThrottle = this.setIsInThrottle.bind(this); | ||
/* | ||
@@ -35,6 +36,6 @@ The reason of using throttle its because of cloning elemnts for inifinite mode. | ||
this.next = infinite | ||
? utils_1.throttle(this.next.bind(this), props.transitionDuration || defaultTransitionDuration) | ||
? utils_1.throttle(this.next.bind(this), props.transitionDuration || defaultTransitionDuration, this.setIsInThrottle) | ||
: this.next.bind(this); | ||
this.previous = infinite | ||
? utils_1.throttle(this.previous.bind(this), props.transitionDuration || defaultTransitionDuration) | ||
? utils_1.throttle(this.previous.bind(this), props.transitionDuration || defaultTransitionDuration, this.setIsInThrottle) | ||
: this.previous.bind(this); | ||
@@ -50,3 +51,7 @@ this.goToSlide = infinite | ||
this.direction = ""; | ||
this.isInThrottle = false; | ||
} | ||
setIsInThrottle(isInThrottle = false) { | ||
this.isInThrottle = isInThrottle; | ||
} | ||
componentDidMount() { | ||
@@ -193,4 +198,4 @@ this.setState({ domLoaded: true }); | ||
slidesToShow + | ||
slidesToSlide; | ||
const nextSlides = this.state.currentSlide + slidesHavePassed + slidesToSlide; | ||
(slidesHavePassed > 0 ? 0 : slidesToSlide); | ||
const nextSlides = this.state.currentSlide + slidesHavePassed + (slidesHavePassed > 0 ? 0 : slidesToSlide); | ||
const nextPosition = -(this.state.itemWidth * nextSlides); | ||
@@ -245,3 +250,5 @@ const previousSlide = this.state.currentSlide; | ||
const { slidesToSlide, infinite, afterChange, beforeChange } = this.props; | ||
const nextSlides = this.state.currentSlide - slidesHavePassed - slidesToSlide; | ||
const nextSlides = this.state.currentSlide - | ||
slidesHavePassed - | ||
(slidesHavePassed > 0 ? 0 : slidesToSlide); | ||
const nextPosition = -(this.state.itemWidth * nextSlides); | ||
@@ -327,3 +334,3 @@ const previousSlide = this.state.currentSlide; | ||
if ((e.touches && !this.props.swipeable) || | ||
(e && !e.touches && !this.props.draggable)) { | ||
(e && !e.touches && !this.props.draggable) || (this.isInThrottle && this.props.infinite)) { | ||
return; | ||
@@ -330,0 +337,0 @@ } |
@@ -19,3 +19,3 @@ import { responsiveType, CarouselInternalState, CarouselProps } from "./types"; | ||
}; | ||
declare const throttle: (func: any, limit: number) => any; | ||
declare const throttle: (func: any, limit: number, setIsInThrottle?: any) => any; | ||
export { guessWidthFromDeviceType, getParitialVisibilityGutter, getClones, whenEnteredClones, throttle, getCounterPart }; |
@@ -119,3 +119,3 @@ "use strict"; | ||
exports.whenEnteredClones = whenEnteredClones; | ||
const throttle = (func, limit) => { | ||
const throttle = (func, limit, setIsInThrottle) => { | ||
let inThrottle; | ||
@@ -128,3 +128,11 @@ return function () { | ||
inThrottle = true; | ||
setTimeout(() => (inThrottle = false), limit); | ||
if (typeof setIsInThrottle === 'function') { | ||
setIsInThrottle(true); | ||
} | ||
setTimeout(() => { | ||
inThrottle = false; | ||
if (typeof setIsInThrottle === 'function') { | ||
setIsInThrottle(false); | ||
} | ||
}, limit); | ||
} | ||
@@ -131,0 +139,0 @@ }; |
{ | ||
"name": "react-multi-carousel", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "", | ||
@@ -5,0 +5,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
136960
1669