react-img-carousel
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -39,5 +39,5 @@ 'use strict'; | ||
var _classnames = require('classnames'); | ||
var _classnames2 = require('classnames'); | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
var _classnames3 = _interopRequireDefault(_classnames2); | ||
@@ -60,2 +60,4 @@ var _controls = require('./controls'); | ||
var SELECTED_CLASS = 'carousel-slide-selected'; | ||
/** | ||
@@ -66,2 +68,3 @@ * React component class that renders a carousel, which can contain images or other content. | ||
*/ | ||
var Carousel = function (_Component) { | ||
@@ -500,3 +503,3 @@ _inherits(Carousel, _Component); | ||
var numSlides = _react.Children.count(children); | ||
var classes = (0, _classnames2.default)('carousel', className, { | ||
var classes = (0, _classnames3.default)('carousel', className, { | ||
'loaded': !loading | ||
@@ -615,8 +618,7 @@ }); | ||
var childrenToRender = _react.Children.map(children, function (child, index) { | ||
var _classnames; | ||
var key = 'slide-' + index; | ||
var imgSrc = child.props.src; | ||
var slideClasses = (0, _classnames2.default)('carousel-slide', { | ||
'carousel-slide-selected': index === currentSlide, | ||
'carousel-slide-fade': transition === 'fade' | ||
}); | ||
var slideClasses = (0, _classnames3.default)('carousel-slide', (_classnames = {}, _defineProperty(_classnames, SELECTED_CLASS, index === currentSlide), _defineProperty(_classnames, 'carousel-slide-fade', transition === 'fade'), _classnames)); | ||
var slideStyle = { | ||
@@ -685,3 +687,3 @@ marginLeft: cellPadding + 'px', | ||
'data-index': index, | ||
className: (0, _classnames2.default)(slideClasses, 'carousel-slide-loading') | ||
className: (0, _classnames3.default)(slideClasses, 'carousel-slide-loading') | ||
}); | ||
@@ -749,15 +751,20 @@ }); | ||
var numOriginals = originals.length; | ||
var prependClones = [(0, _react.cloneElement)((0, _lodash2.default)(originals, numOriginals - 2), { | ||
var originalsToClone = [(0, _lodash2.default)(originals, numOriginals - 2), (0, _lodash2.default)(originals, numOriginals - 1), (0, _lodash2.default)(originals, 0), (0, _lodash2.default)(originals, Math.min(1, numOriginals - 1))]; | ||
var prependClones = [(0, _react.cloneElement)(originalsToClone[0], { | ||
key: 'clone-1', | ||
'data-index': -2 | ||
}), (0, _react.cloneElement)((0, _lodash2.default)(originals, numOriginals - 1), { | ||
'data-index': -2, | ||
className: originalsToClone[0].props.className.replace(SELECTED_CLASS, '') | ||
}), (0, _react.cloneElement)(originalsToClone[1], { | ||
key: 'clone-0', | ||
'data-index': -1 | ||
'data-index': -1, | ||
className: originalsToClone[1].props.className.replace(SELECTED_CLASS, '') | ||
})]; | ||
var appendClones = [(0, _react.cloneElement)((0, _lodash2.default)(originals, 0), { | ||
var appendClones = [(0, _react.cloneElement)(originalsToClone[2], { | ||
key: 'clone-2', | ||
'data-index': numOriginals | ||
}), (0, _react.cloneElement)((0, _lodash2.default)(originals, Math.min(1, numOriginals - 1)), { | ||
'data-index': numOriginals, | ||
className: originalsToClone[2].props.className.replace(SELECTED_CLASS, '') | ||
}), (0, _react.cloneElement)(originalsToClone[3], { | ||
key: 'clone-3', | ||
'data-index': numOriginals + 1 | ||
'data-index': numOriginals + 1, | ||
className: originalsToClone[3].props.className.replace(SELECTED_CLASS, '') | ||
})]; | ||
@@ -764,0 +771,0 @@ |
{ | ||
"name": "react-img-carousel", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"description": "Provides an image carousel React component.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -12,2 +12,4 @@ import React, { Component, Children, cloneElement } from 'react'; | ||
const SELECTED_CLASS = 'carousel-slide-selected'; | ||
/** | ||
@@ -458,3 +460,3 @@ * React component class that renders a carousel, which can contain images or other content. | ||
{ | ||
'carousel-slide-selected': index === currentSlide, | ||
[SELECTED_CLASS]: index === currentSlide, | ||
'carousel-slide-fade': transition === 'fade' | ||
@@ -583,20 +585,30 @@ } | ||
const numOriginals = originals.length; | ||
const originalsToClone = [ | ||
nth(originals, numOriginals - 2), | ||
nth(originals, numOriginals - 1), | ||
nth(originals, 0), | ||
nth(originals, Math.min(1, numOriginals - 1)) | ||
]; | ||
const prependClones = [ | ||
cloneElement(nth(originals, numOriginals - 2), { | ||
cloneElement(originalsToClone[0], { | ||
key: 'clone-1', | ||
'data-index': -2 | ||
'data-index': -2, | ||
className: originalsToClone[0].props.className.replace(SELECTED_CLASS, '') | ||
}), | ||
cloneElement(nth(originals, numOriginals - 1), { | ||
cloneElement(originalsToClone[1], { | ||
key: 'clone-0', | ||
'data-index': -1 | ||
'data-index': -1, | ||
className: originalsToClone[1].props.className.replace(SELECTED_CLASS, '') | ||
}) | ||
]; | ||
const appendClones = [ | ||
cloneElement(nth(originals, 0), { | ||
cloneElement(originalsToClone[2], { | ||
key: 'clone-2', | ||
'data-index': numOriginals | ||
'data-index': numOriginals, | ||
className: originalsToClone[2].props.className.replace(SELECTED_CLASS, '') | ||
}), | ||
cloneElement(nth(originals, Math.min(1, numOriginals - 1)), { | ||
cloneElement(originalsToClone[3], { | ||
key: 'clone-3', | ||
'data-index': numOriginals + 1 | ||
'data-index': numOriginals + 1, | ||
className: originalsToClone[3].props.className.replace(SELECTED_CLASS, '') | ||
}) | ||
@@ -603,0 +615,0 @@ ]; |
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
107498
2589