nuka-carousel
Advanced tools
Comparing version 5.0.15 to 5.0.16
@@ -120,3 +120,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; } | ||
if (props.wrapAround || currentSlide < count - props.slidesToScroll) { | ||
var nextPosition = getNextMoveIndex(props.scrollMode, props.wrapAround, currentSlide, count, props.slidesToScroll); | ||
var nextPosition = getNextMoveIndex(props.scrollMode, props.wrapAround, currentSlide, count, props.slidesToScroll, props.slidesToShow); | ||
moveSlide(nextPosition); | ||
@@ -123,0 +123,0 @@ } else { |
@@ -8,3 +8,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 from 'react'; | ||
import React, { useCallback, useMemo } from 'react'; | ||
import { ScrollMode } from './types'; | ||
@@ -74,5 +74,11 @@ | ||
slidesToScroll = _ref3.slidesToScroll, | ||
wrapAround = _ref3.wrapAround; | ||
wrapAround = _ref3.wrapAround, | ||
scrollMode = _ref3.scrollMode; | ||
// inifite carousel with visible slides that are less than all slides | ||
// remainder scroll mode | ||
if (!wrapAround && scrollMode === ScrollMode.remainder && currentSlide >= slideCount - slidesToShow) { | ||
return true; | ||
} // inifite carousel with visible slides that are less than all slides | ||
if (wrapAround && slidesToShow < slideCount) { | ||
@@ -115,3 +121,3 @@ return false; | ||
}; | ||
export var getDotIndexes = function getDotIndexes(slideCount, slidesToScroll, scrollMode) { | ||
export var getDotIndexes = function getDotIndexes(slideCount, slidesToScroll, scrollMode, slidesToShow, wrapAround) { | ||
var dotIndexes = []; | ||
@@ -121,7 +127,11 @@ var scrollSlides = slidesToScroll === 0 ? 1 : slidesToScroll; | ||
for (var i = 0; i < slideCount; i += scrollSlides) { | ||
if (scrollMode === ScrollMode.remainder && i + scrollSlides > slideCount) { | ||
dotIndexes.push(i - (scrollSlides - (slideCount - i))); | ||
} else { | ||
if (!(!wrapAround && scrollMode === ScrollMode.remainder && i > slideCount - slidesToShow)) { | ||
dotIndexes.push(i); | ||
} | ||
} // check if the slidesToShow is float value, if true add the last dot (remainder scroll mode) | ||
if (!wrapAround && scrollMode === ScrollMode.remainder && slidesToShow % 1 !== 0) { | ||
var lastIndex = dotIndexes[dotIndexes.length - 1]; | ||
dotIndexes.push(lastIndex + slidesToShow % 1); | ||
} | ||
@@ -140,4 +150,3 @@ | ||
}; | ||
var getButtonStyles = function getButtonStyles(active) { | ||
var getButtonStyles = useCallback(function (active) { | ||
return { | ||
@@ -150,5 +159,6 @@ cursor: 'pointer', | ||
}; | ||
}; | ||
var indexes = getDotIndexes(props.slideCount, props.slidesToScroll, props.scrollMode); | ||
}, []); | ||
var indexes = useMemo(function () { | ||
return getDotIndexes(props.slideCount, props.slidesToScroll, props.scrollMode, props.slidesToShow, props.wrapAround); | ||
}, [props.slideCount, props.slidesToScroll, props.scrollMode, props.slidesToShow, props.wrapAround]); | ||
var _props$defaultControl = props.defaultControlsConfig, | ||
@@ -155,0 +165,0 @@ pagingDotsContainerClassName = _props$defaultControl.pagingDotsContainerClassName, |
@@ -46,5 +46,5 @@ import { ScrollMode } from './types'; | ||
}; | ||
export var getNextMoveIndex = function getNextMoveIndex(scrollMode, wrapAround, currentSlide, count, slidesToScroll) { | ||
if (!wrapAround && scrollMode === ScrollMode.remainder && count < currentSlide + slidesToScroll * 2) { | ||
var remindedSlides = count - (currentSlide + slidesToScroll); | ||
export var getNextMoveIndex = function getNextMoveIndex(scrollMode, wrapAround, currentSlide, count, slidesToScroll, slidesToShow) { | ||
if (!wrapAround && scrollMode === ScrollMode.remainder && count < currentSlide + (slidesToScroll + slidesToShow)) { | ||
var remindedSlides = count - (currentSlide + slidesToScroll) - (slidesToShow - slidesToScroll); | ||
return currentSlide + remindedSlides; | ||
@@ -51,0 +51,0 @@ } |
@@ -141,3 +141,3 @@ "use strict"; | ||
if (props.wrapAround || currentSlide < count - props.slidesToScroll) { | ||
var nextPosition = (0, _utils.getNextMoveIndex)(props.scrollMode, props.wrapAround, currentSlide, count, props.slidesToScroll); | ||
var nextPosition = (0, _utils.getNextMoveIndex)(props.scrollMode, props.wrapAround, currentSlide, count, props.slidesToScroll, props.slidesToShow); | ||
moveSlide(nextPosition); | ||
@@ -144,0 +144,0 @@ } else { |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,8 +10,10 @@ value: true | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _types = require("./types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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; } | ||
@@ -89,5 +93,11 @@ | ||
slidesToScroll = _ref3.slidesToScroll, | ||
wrapAround = _ref3.wrapAround; | ||
wrapAround = _ref3.wrapAround, | ||
scrollMode = _ref3.scrollMode; | ||
// inifite carousel with visible slides that are less than all slides | ||
// remainder scroll mode | ||
if (!wrapAround && scrollMode === _types.ScrollMode.remainder && currentSlide >= slideCount - slidesToShow) { | ||
return true; | ||
} // inifite carousel with visible slides that are less than all slides | ||
if (wrapAround && slidesToShow < slideCount) { | ||
@@ -136,3 +146,3 @@ return false; | ||
var getDotIndexes = function getDotIndexes(slideCount, slidesToScroll, scrollMode) { | ||
var getDotIndexes = function getDotIndexes(slideCount, slidesToScroll, scrollMode, slidesToShow, wrapAround) { | ||
var dotIndexes = []; | ||
@@ -142,7 +152,11 @@ var scrollSlides = slidesToScroll === 0 ? 1 : slidesToScroll; | ||
for (var i = 0; i < slideCount; i += scrollSlides) { | ||
if (scrollMode === _types.ScrollMode.remainder && i + scrollSlides > slideCount) { | ||
dotIndexes.push(i - (scrollSlides - (slideCount - i))); | ||
} else { | ||
if (!(!wrapAround && scrollMode === _types.ScrollMode.remainder && i > slideCount - slidesToShow)) { | ||
dotIndexes.push(i); | ||
} | ||
} // check if the slidesToShow is float value, if true add the last dot (remainder scroll mode) | ||
if (!wrapAround && scrollMode === _types.ScrollMode.remainder && slidesToShow % 1 !== 0) { | ||
var lastIndex = dotIndexes[dotIndexes.length - 1]; | ||
dotIndexes.push(lastIndex + slidesToShow % 1); | ||
} | ||
@@ -164,4 +178,3 @@ | ||
}; | ||
var getButtonStyles = function getButtonStyles(active) { | ||
var getButtonStyles = (0, _react.useCallback)(function (active) { | ||
return { | ||
@@ -174,5 +187,6 @@ cursor: 'pointer', | ||
}; | ||
}; | ||
var indexes = getDotIndexes(props.slideCount, props.slidesToScroll, props.scrollMode); | ||
}, []); | ||
var indexes = (0, _react.useMemo)(function () { | ||
return getDotIndexes(props.slideCount, props.slidesToScroll, props.scrollMode, props.slidesToShow, props.wrapAround); | ||
}, [props.slideCount, props.slidesToScroll, props.scrollMode, props.slidesToShow, props.wrapAround]); | ||
var _props$defaultControl = props.defaultControlsConfig, | ||
@@ -179,0 +193,0 @@ pagingDotsContainerClassName = _props$defaultControl.pagingDotsContainerClassName, |
@@ -63,5 +63,5 @@ "use strict"; | ||
var getNextMoveIndex = function getNextMoveIndex(scrollMode, wrapAround, currentSlide, count, slidesToScroll) { | ||
if (!wrapAround && scrollMode === _types.ScrollMode.remainder && count < currentSlide + slidesToScroll * 2) { | ||
var remindedSlides = count - (currentSlide + slidesToScroll); | ||
var getNextMoveIndex = function getNextMoveIndex(scrollMode, wrapAround, currentSlide, count, slidesToScroll, slidesToShow) { | ||
if (!wrapAround && scrollMode === _types.ScrollMode.remainder && count < currentSlide + (slidesToScroll + slidesToShow)) { | ||
var remindedSlides = count - (currentSlide + slidesToScroll) - (slidesToShow - slidesToScroll); | ||
return currentSlide + remindedSlides; | ||
@@ -68,0 +68,0 @@ } |
{ | ||
"name": "nuka-carousel", | ||
"version": "5.0.15", | ||
"version": "5.0.16", | ||
"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
136278
2735