Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

infinite-react-carousel

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

infinite-react-carousel - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

123

lib/carousel/array.js

@@ -12,73 +12,92 @@ "use strict";

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var CircularArray = function CircularArray(n) {
var _this = this;
var CircularArray =
/*#__PURE__*/
function () {
_createClass(CircularArray, [{
key: "length",
get: function get() {
return this.array.length;
}
}]);
_classCallCheck(this, CircularArray);
function CircularArray(n) {
var _this = this;
_defineProperty(this, "toString", function (array) {
var result = [];
var newArray = array || _this.array;
newArray.forEach(function (item) {
if (_typeof(item) === 'object' && item instanceof Array) result.push("[".concat(_this.toString(item), "]"));else if (_typeof(item) === 'object') result.push(JSON.stringify(item));else result.push(item.toString());
_classCallCheck(this, CircularArray);
_defineProperty(this, "array", []);
_defineProperty(this, "toString", function (array) {
var result = [];
var newArray = array || _this.array;
newArray.forEach(function (item) {
if (_typeof(item) === 'object' && item instanceof Array) result.push("[".concat(_this.toString(item), "]"));else if (_typeof(item) === 'object') result.push(JSON.stringify(item));else result.push(item.toString());
});
return result.join(',');
});
return result.join(',');
});
_defineProperty(this, "get", function (i) {
var result;
_defineProperty(this, "get", function (i) {
var result;
if (i < 0 || i < _this.length - _this.array.length) {
result = _this.array[-i % _this.array.length === 0 ? 0 : _this.array.length + i % _this.array.length];
} else {
result = _this.array[i % _this.array.length];
}
if (i < 0 || i < _this.length - _this.array.length) {
result = _this.array[-i % _this.array.length === 0 ? 0 : _this.array.length + i % _this.array.length];
} else {
result = _this.array[i % _this.array.length];
}
return result;
});
return result;
});
_defineProperty(this, "getIndex", function (i) {
var result;
_defineProperty(this, "getIndex", function (i) {
var result;
if (i < 0 || i < _this.length - _this.array.length) {
result = -i % _this.array.length === 0 ? 0 : _this.array.length + i % _this.array.length;
} else {
result = i % _this.array.length;
}
if (i < 0 || i < _this.length - _this.array.length) {
result = -i % _this.array.length === 0 ? 0 : _this.array.length + i % _this.array.length;
} else {
result = i % _this.array.length;
}
return result;
});
return result;
});
_defineProperty(this, "set", function (i, v) {
if (i < 0 || i < _this.length - _this.array.length) {
throw new Error('can not set index < 0');
}
_defineProperty(this, "set", function (i, v) {
if (i < 0 || i < _this.length - _this.array.length) {
throw new Error('can not set index < 0');
}
while (i > _this.length) {
_this.array[_this.length % _this.array.length] = undefined;
_this.length += 1;
}
if (i >= _this.length) {
var newArr = new Array(i - _this.length + 1);
_this.array = _this.array.concat(newArr);
_this.array[_this.getIndex(i)] = v;
if (i === _this.length) _this.length += 1;
});
_this.array.splice(i, 1, v);
} else {
_this.array[_this.getIndex(i)] = v;
}
});
this.array = [];
this.array = [];
if (typeof n === 'number') {
this.array = new Array(n);
this.length = 0;
} else if (_typeof(n) === 'object' && Array.isArray(n)) {
this.array = n;
this.length = n.length;
} else if (_typeof(n) === 'object' && n.length > 0) {
n.forEach(function (e) {
return _this.array.push(e);
});
this.length = n.length;
if (typeof n === 'number') {
this.array = new Array(n);
} else if (_typeof(n) === 'object' && Array.isArray(n)) {
this.array = n;
} else if (_typeof(n) === 'object' && n.length > 0) {
n.forEach(function (e) {
return _this.array.push(e);
});
} else {
throw new Error('can not create array');
}
}
};
return CircularArray;
}();
var _default = CircularArray;
exports["default"] = _default;

@@ -12,6 +12,4 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _types = require("./types");
var _this = void 0;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -28,4 +26,3 @@

var Arrow = function Arrow(_ref) {
var arrows = _ref.arrows,
arrowsScroll = _ref.arrowsScroll,
var arrowsScroll = _ref.arrowsScroll,
clickHandler = _ref.clickHandler,

@@ -38,6 +35,3 @@ type = _ref.type,

var ClickHandler = function ClickHandler(options, e) {
if (e) {
e.preventDefault();
}
e.preventDefault();
clickHandler(options, e);

@@ -50,3 +44,2 @@ };

};
var handler = null;
var arrowOptions = {

@@ -63,4 +56,3 @@ arrowsScroll: arrowsScroll

});
handler = ClickHandler.bind(_this, arrowOptions);
} else if (type === 'next') {
} else {
Object.assign(classes, {

@@ -72,3 +64,2 @@ 'carousel-next': true

});
handler = ClickHandler.bind(_this, arrowOptions);
}

@@ -81,3 +72,5 @@

// style: { display: 'block' },
onClick: handler
onClick: function onClick(e) {
return ClickHandler(arrowOptions, e);
}
}; // const customProps = {

@@ -88,17 +81,13 @@ // currentSlide,

var customArrow;
var customArrow = null;
if (arrows) {
if (prevArrow && type === 'prev') {
customArrow = _react["default"].cloneElement(prevArrow, _objectSpread({}, arrowProps));
} else if (nextArrow && type === 'next') {
customArrow = _react["default"].cloneElement(nextArrow, _objectSpread({}, arrowProps));
} else {
customArrow = _react["default"].createElement("button", _extends({}, arrowProps, {
key: type === 'prev' ? '0' : '1',
type: "button"
}), ' ', type === 'prev' ? 'Previous' : 'Next');
}
if (prevArrow && type === 'prev') {
customArrow = _react["default"].cloneElement(prevArrow, _objectSpread({}, arrowProps));
} else if (nextArrow && type === 'next') {
customArrow = _react["default"].cloneElement(nextArrow, _objectSpread({}, arrowProps));
} else {
customArrow = null;
customArrow = _react["default"].createElement("button", _extends({}, arrowProps, {
key: type === 'prev' ? '0' : '1',
type: "button"
}), ' ', type === 'prev' ? 'Previous' : 'Next');
}

@@ -109,24 +98,4 @@

Arrow.propTypes = {
arrows: _propTypes["default"].bool,
arrowsScroll: _propTypes["default"].number,
// currentSlide: PropTypes,
clickHandler: _propTypes["default"].func,
// slideCount,
type: _propTypes["default"].oneOf(['prev', 'next']),
prevArrow: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].element, _propTypes["default"].instanceOf(Element), _propTypes["default"].oneOf([null])]),
nextArrow: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].element, _propTypes["default"].instanceOf(Element), _propTypes["default"].oneOf([null])]),
arrowsBlock: _propTypes["default"].bool
};
Arrow.defaultProps = {
arrows: true,
arrowsScroll: 1,
// currentSlide,
clickHandler: function clickHandler() {},
// slideCount,
type: 'prev',
arrowsBlock: true,
prevArrow: null,
nextArrow: null
};
Arrow.propTypes = _types.arrowsPropTypes;
Arrow.defaultProps = _types.arrowsDefaultProps;

@@ -133,0 +102,0 @@ var PrevArrow = function PrevArrow(props) {

@@ -12,3 +12,3 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _types = require("./types");

@@ -24,5 +24,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var getDotCount = function getDotCount(spec) {
var dots;
if (spec.infinite) dots = Math.ceil(spec.slideCount / spec.dotsScroll);else dots = Math.ceil((spec.slideCount - spec.slidesToShow) / spec.dotsScroll) + 1;
return dots;
return Math.ceil(spec.slideCount / spec.dotsScroll);
};

@@ -90,41 +88,5 @@

Dots.defaultProps = {
slideCount: 0,
dotsScroll: 1,
slidesToShow: 1,
infinite: true,
currentSlide: 0,
clickHandler: function clickHandler() {},
onMouseEnter: function onMouseEnter() {},
onMouseOver: function onMouseOver() {},
onMouseLeave: function onMouseLeave() {},
customPaging: function customPaging(i) {
return _react["default"].createElement("button", {
type: "button"
}, i + 1);
},
appendDots: function appendDots(dots) {
return _react["default"].createElement("ul", {
style: {
display: 'block'
}
}, dots);
},
dotsClass: ''
};
Dots.propTypes = {
slideCount: _propTypes["default"].number,
dotsScroll: _propTypes["default"].number,
slidesToShow: _propTypes["default"].number,
infinite: _propTypes["default"].bool,
currentSlide: _propTypes["default"].number,
clickHandler: _propTypes["default"].func,
onMouseEnter: _propTypes["default"].func,
onMouseOver: _propTypes["default"].func,
onMouseLeave: _propTypes["default"].func,
customPaging: _propTypes["default"].func,
appendDots: _propTypes["default"].func,
dotsClass: _propTypes["default"].string
};
Dots.defaultProps = _types.dotsDefaultProps;
Dots.propTypes = _types.dotsPropTypes;
var _default = Dots;
exports["default"] = _default;

@@ -130,10 +130,3 @@ "use strict";

});
if (settings.variableWidth && (settings.rows > 1 || settings.slidesPerRow > 1)) {
console.warn('variableWidth is not supported in case of rows > 1 or slidesPerRow > 1');
settings.variableWidth = false;
}
_this.newChildren = [];
var currentWidth = null;

@@ -147,6 +140,2 @@ for (var i = 0; i < children.length; i += settings.rows * settings.slidesPerRow) {

for (var k = j; k < j + settings.slidesPerRow; k += 1) {
if (settings.variableWidth && children[k].props.style) {
currentWidth = children[k].props.style.width;
}
if (k >= children.length) break;

@@ -164,2 +153,3 @@ row.push(_react["default"].cloneElement(children[k], {

newSlide.push(_react["default"].createElement("div", {
className: "carousel-row",
key: 10 * i + j

@@ -169,20 +159,11 @@ }, row));

if (settings.variableWidth) {
_this.newChildren.push(_react["default"].createElement("div", {
key: i,
style: {
width: currentWidth
}
}, newSlide));
} else {
var width = _this.state.width;
var width = _this.state.width;
_this.newChildren.push(_react["default"].createElement("div", {
key: i,
className: "carousel-item",
style: {
width: "".concat(width, "px")
}
}, newSlide));
}
_this.newChildren.push(_react["default"].createElement("div", {
key: i,
className: "carousel-item",
style: {
width: "".concat(width, "px")
}
}, newSlide));
}

@@ -958,2 +939,4 @@

this.init();
var onInit = this.props.onInit;
if (onInit && typeof onInit === 'function') onInit(this);
}

@@ -972,5 +955,7 @@ }, {

if (!(0, _isEqual["default"])(this.props, prevProps)) {
var onReInit = this.props.onReInit;
this.init();
this.slideInit();
this.setRef(SliderRef);
if (onReInit && typeof onReInit === 'function') onReInit(this);
}

@@ -977,0 +962,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

});
exports.autoplayProps = exports.propTypes = exports.defaultProps = void 0;
exports.arrowsPropTypes = exports.arrowsDefaultProps = exports.dotsPropTypes = exports.dotsDefaultProps = exports.autoplayProps = exports.propTypes = exports.defaultProps = void 0;

@@ -21,2 +21,3 @@ var _react = _interopRequireDefault(require("react"));

accessibility: true,
//
adaptiveHeight: false,

@@ -45,2 +46,3 @@ //

arrowsScroll: 1,
//
centerPadding: 50,

@@ -73,4 +75,6 @@ //

onInit: null,
//
onLazyLoadError: null,
onReInit: null,
//
pauseOnDotsHover: false,

@@ -93,9 +97,4 @@ pauseOnFocus: false,

//
swipeEvent: null,
swipeToSlide: false,
useCSS: true,
useTransform: true,
variableWidth: false,
vertical: false,
waitForAnimate: true,
duration: 200,

@@ -114,3 +113,5 @@ //

onResize: function onResize() {},
onSwipe: function onSwipe() {}
//
onSwipe: function onSwipe() {} //
};

@@ -159,9 +160,4 @@ exports.defaultProps = defaultProps;

swipe: _propTypes["default"].bool,
swipeEvent: _propTypes["default"].func,
swipeToSlide: _propTypes["default"].bool,
useCSS: _propTypes["default"].bool,
useTransform: _propTypes["default"].bool,
variableWidth: _propTypes["default"].bool,
vertical: _propTypes["default"].bool,
waitForAnimate: _propTypes["default"].bool,
duration: _propTypes["default"].number,

@@ -176,2 +172,66 @@ shift: _propTypes["default"].number,

};
exports.propTypes = propTypes;
exports.propTypes = propTypes;
var dotsDefaultProps = {
slideCount: 0,
dotsScroll: 1,
slidesToShow: 1,
infinite: true,
currentSlide: 0,
clickHandler: function clickHandler() {},
onMouseEnter: function onMouseEnter() {},
onMouseOver: function onMouseOver() {},
onMouseLeave: function onMouseLeave() {},
customPaging: function customPaging(i) {
return _react["default"].createElement("button", {
type: "button"
}, i + 1);
},
appendDots: function appendDots(dots) {
return _react["default"].createElement("ul", {
style: {
display: 'block'
}
}, dots);
},
dotsClass: ''
};
exports.dotsDefaultProps = dotsDefaultProps;
var dotsPropTypes = {
slideCount: _propTypes["default"].number,
dotsScroll: _propTypes["default"].number,
slidesToShow: _propTypes["default"].number,
infinite: _propTypes["default"].bool,
currentSlide: _propTypes["default"].number,
clickHandler: _propTypes["default"].func,
onMouseEnter: _propTypes["default"].func,
onMouseOver: _propTypes["default"].func,
onMouseLeave: _propTypes["default"].func,
customPaging: _propTypes["default"].func,
appendDots: _propTypes["default"].func,
dotsClass: _propTypes["default"].string
};
exports.dotsPropTypes = dotsPropTypes;
var arrowsPropTypes = {
arrows: _propTypes["default"].bool,
arrowsScroll: _propTypes["default"].number,
// currentSlide: PropTypes,
clickHandler: _propTypes["default"].func,
// slideCount,
type: _propTypes["default"].oneOf(['prev', 'next']),
prevArrow: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].element, _propTypes["default"].instanceOf(Element), _propTypes["default"].oneOf([null])]),
nextArrow: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].element, _propTypes["default"].instanceOf(Element), _propTypes["default"].oneOf([null])]),
arrowsBlock: _propTypes["default"].bool
};
exports.arrowsPropTypes = arrowsPropTypes;
var arrowsDefaultProps = {
arrows: true,
arrowsScroll: 1,
// currentSlide,
clickHandler: function clickHandler() {},
// slideCount,
type: 'prev',
arrowsBlock: true,
prevArrow: null,
nextArrow: null
};
exports.arrowsDefaultProps = arrowsDefaultProps;

@@ -31,3 +31,3 @@ "use strict";

if (verticalSwiping === true) {
if (swipeAngle >= 35 && swipeAngle <= 135) {
if (swipeAngle > 45 && swipeAngle < 135) {
return 'up';

@@ -34,0 +34,0 @@ }

{
"name": "infinite-react-carousel",
"version": "1.1.4",
"version": "1.1.5",
"description": "Infinite carousel for react",

@@ -21,3 +21,3 @@ "main": "./lib",

"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx ./src --fix",
"test": "npm run lint && jest",
"test": "jest",
"test:watch": "jest --watch"

@@ -127,1 +127,2 @@ },

}

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

Sorry, the diff of this file is too big to display

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