nuka-carousel
Advanced tools
Comparing version 5.0.6 to 5.0.7
@@ -20,3 +20,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
/* eslint-disable complexity */ | ||
import React, { useEffect, useState, useRef } from 'react'; | ||
import React, { useEffect, useState, useRef, useCallback } from 'react'; | ||
import Slide from './slide'; | ||
@@ -75,10 +75,23 @@ import { getSliderListStyles } from './slider-list'; | ||
var carouselRef = props.innerRef || carouselEl; | ||
var getNextIndex = useCallback(function (to) { | ||
var index = to !== null && to !== void 0 ? to : currentSlide; | ||
if (index < 0) { | ||
return index + count; | ||
} | ||
if (index === count) { | ||
return 0; | ||
} | ||
return index; | ||
}, [count, currentSlide]); | ||
var moveSlide = function moveSlide(to) { | ||
var _getIndexes = getIndexes(currentSlide, currentSlide - slidesToScroll, count), | ||
_getIndexes2 = _slicedToArray(_getIndexes, 2), | ||
slide = _getIndexes2[0], | ||
endSlide = _getIndexes2[1]; | ||
_getIndexes2 = _slicedToArray(_getIndexes, 1), | ||
slide = _getIndexes2[0]; | ||
to && props.beforeSlide(slide, endSlide); | ||
var nextIndex = getNextIndex(to); | ||
typeof to === 'number' && props.beforeSlide(slide, nextIndex); | ||
!props.disableAnimation && setAnimation(true); | ||
@@ -88,3 +101,3 @@ setCurrentSlide(to !== null && to !== void 0 ? to : currentSlide); | ||
if (!isMounted.current) return; | ||
to && props.afterSlide(currentSlide); | ||
typeof to === 'number' && props.afterSlide(nextIndex); | ||
!props.disableAnimation && setAnimation(false); | ||
@@ -91,0 +104,0 @@ }, !props.disableAnimation ? props.speed || 500 : 40); // if animation is disabled decrease the speed to 40 |
@@ -95,10 +95,23 @@ "use strict"; | ||
var carouselRef = props.innerRef || carouselEl; | ||
var getNextIndex = (0, _react.useCallback)(function (to) { | ||
var index = to !== null && to !== void 0 ? to : currentSlide; | ||
if (index < 0) { | ||
return index + count; | ||
} | ||
if (index === count) { | ||
return 0; | ||
} | ||
return index; | ||
}, [count, currentSlide]); | ||
var moveSlide = function moveSlide(to) { | ||
var _getIndexes = (0, _utils.getIndexes)(currentSlide, currentSlide - slidesToScroll, count), | ||
_getIndexes2 = _slicedToArray(_getIndexes, 2), | ||
slide = _getIndexes2[0], | ||
endSlide = _getIndexes2[1]; | ||
_getIndexes2 = _slicedToArray(_getIndexes, 1), | ||
slide = _getIndexes2[0]; | ||
to && props.beforeSlide(slide, endSlide); | ||
var nextIndex = getNextIndex(to); | ||
typeof to === 'number' && props.beforeSlide(slide, nextIndex); | ||
!props.disableAnimation && setAnimation(true); | ||
@@ -108,3 +121,3 @@ setCurrentSlide(to !== null && to !== void 0 ? to : currentSlide); | ||
if (!isMounted.current) return; | ||
to && props.afterSlide(currentSlide); | ||
typeof to === 'number' && props.afterSlide(nextIndex); | ||
!props.disableAnimation && setAnimation(false); | ||
@@ -111,0 +124,0 @@ }, !props.disableAnimation ? props.speed || 500 : 40); // if animation is disabled decrease the speed to 40 |
{ | ||
"name": "nuka-carousel", | ||
"version": "5.0.6", | ||
"version": "5.0.7", | ||
"description": "Pure React Carousel", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155086
2594