react-slideshow-image 3.6.1 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/props.js CHANGED
@@ -31,7 +31,14 @@ var defaultProps = {
31
31
  canSwipe: true,
32
32
  slidesToShow: 1,
33
33
  slidesToScroll: 1,
34
- cssClass: ''
34
+ cssClass: '',
35
+ responsive: []
36
+ };
37
+
38
+ var getResponsiveSettings = function getResponsiveSettings(windowWidth, responsive) {
39
+ return responsive.find(function (each) {
40
+ return each.breakpoint <= windowWidth;
41
+ });
35
42
  };
36
43
 
37
44
  var getProps = function getProps(componentProps) {
@@ -39,7 +46,18 @@ var getProps = function getProps(componentProps) {
39
46
  return each;
40
47
  });
41
48
 
42
- return _objectSpread({}, defaultProps, {}, componentProps, {
49
+ var settings = {};
50
+
51
+ if (typeof window !== 'undefined' && Array.isArray(componentProps.responsive)) {
52
+ var windowWidth = window.innerWidth;
53
+ var responsiveSettings = getResponsiveSettings(windowWidth, componentProps.responsive);
54
+
55
+ if (responsiveSettings) {
56
+ settings = responsiveSettings.settings;
57
+ }
58
+ }
59
+
60
+ return _objectSpread({}, defaultProps, {}, componentProps, {}, settings, {
43
61
  children: children
44
62
  });
45
63
  };
@@ -62,7 +80,8 @@ var propTypes = {
62
80
  canSwipe: 'boolean',
63
81
  slidesToShow: 'number',
64
82
  slidesToScroll: 'number',
65
- cssClass: 'string'
83
+ cssClass: 'string',
84
+ responsive: 'array'
66
85
  };
67
86
  exports.propTypes = propTypes;
68
87
 
@@ -73,7 +92,9 @@ var validatePropTypes = function validatePropTypes(props) {
73
92
  if (propTypes[key]) {
74
93
  if (Array.isArray(propTypes[key]) && !propTypes[key].includes(propValueType)) {
75
94
  console.warn("".concat(key, " must be of one of type ").concat(propTypes[key].join(', ')));
76
- } else if (!Array.isArray(propTypes[key]) && propValueType !== propTypes[key]) {
95
+ } else if (propTypes[key] === 'array' && !Array.isArray(props[key])) {
96
+ console.warn("".concat(key, " must be of type ").concat(propTypes[key]));
97
+ } else if (propTypes[key] !== 'array' && !Array.isArray(propTypes[key]) && propValueType !== propTypes[key]) {
77
98
  console.warn("".concat(key, " must be of type ").concat(propTypes[key]));
78
99
  }
79
100
  }
package/lib/slide.js CHANGED
@@ -51,6 +51,7 @@ function (_Component) {
51
51
 
52
52
  _this = _possibleConstructorReturn(this, _getPrototypeOf(Slideshow).call(this));
53
53
  _this.state = {
54
+ slidesToShow: props.slidesToShow || 1,
54
55
  index: props.defaultIndex && props.defaultIndex < props.children.length ? props.defaultIndex : 0
55
56
  };
56
57
  _this.width = 0;
@@ -200,6 +201,13 @@ function (_Component) {
200
201
  slidesToShow = _getProps5.slidesToShow,
201
202
  infinite = _getProps5.infinite;
202
203
 
204
+ if (this.state.slidesToShow !== slidesToShow) {
205
+ this.setState({
206
+ slidesToShow: slidesToShow,
207
+ index: 0
208
+ });
209
+ }
210
+
203
211
  this.width = (this.wrapper && this.wrapper.clientWidth || 0) / slidesToShow;
204
212
 
205
213
  var numberOfSlides = _react["default"].Children.count(this.props.children);
@@ -387,7 +395,17 @@ function (_Component) {
387
395
  }
388
396
  }, {
389
397
  key: "renderTrailingSlides",
390
- value: function renderTrailingSlides(children, slidesToShow) {
398
+ value: function renderTrailingSlides() {
399
+ var _getProps13 = (0, _props.getProps)(this.props),
400
+ children = _getProps13.children,
401
+ slidesToShow = _getProps13.slidesToShow,
402
+ slidesToScroll = _getProps13.slidesToScroll,
403
+ infinite = _getProps13.infinite;
404
+
405
+ if (!infinite && slidesToShow === slidesToScroll) {
406
+ return;
407
+ }
408
+
391
409
  return children.slice(0, slidesToShow).map(function (each, index) {
392
410
  return _react["default"].createElement("div", {
393
411
  "data-index": children.length + index,
@@ -411,13 +429,13 @@ function (_Component) {
411
429
  value: function render() {
412
430
  var _this7 = this;
413
431
 
414
- var _getProps13 = (0, _props.getProps)(this.props),
415
- children = _getProps13.children,
416
- indicators = _getProps13.indicators,
417
- arrows = _getProps13.arrows,
418
- cssClass = _getProps13.cssClass,
419
- slidesToShow = _getProps13.slidesToShow,
420
- infinite = _getProps13.infinite;
432
+ var _getProps14 = (0, _props.getProps)(this.props),
433
+ children = _getProps14.children,
434
+ indicators = _getProps14.indicators,
435
+ arrows = _getProps14.arrows,
436
+ cssClass = _getProps14.cssClass,
437
+ slidesToShow = _getProps14.slidesToShow,
438
+ infinite = _getProps14.infinite;
421
439
 
422
440
  var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
423
441
  var index = this.state.index;
@@ -461,23 +479,23 @@ function (_Component) {
461
479
  "aria-roledescription": "slide",
462
480
  "aria-hidden": isSlideActive ? 'false' : 'true'
463
481
  }, each);
464
- }), infinite ? this.renderTrailingSlides(children, slidesToShow) : '')), arrows && (0, _helpers.showNextArrow)((0, _props.getProps)(this.props), this.state.index, this.moveSlides)), indicators && (0, _helpers.showIndicators)((0, _props.getProps)(this.props), this.state.index, this.goToSlide));
482
+ }), this.renderTrailingSlides())), arrows && (0, _helpers.showNextArrow)((0, _props.getProps)(this.props), this.state.index, this.moveSlides)), indicators && (0, _helpers.showIndicators)((0, _props.getProps)(this.props), this.state.index, this.goToSlide));
465
483
  }
466
484
  }, {
467
485
  key: "slideImages",
468
486
  value: function slideImages(index, animationDuration) {
469
487
  var _this8 = this;
470
488
 
471
- var _getProps14 = (0, _props.getProps)(this.props),
472
- children = _getProps14.children,
473
- transitionDuration = _getProps14.transitionDuration,
474
- autoplay = _getProps14.autoplay,
475
- infinite = _getProps14.infinite,
476
- duration = _getProps14.duration,
477
- onChange = _getProps14.onChange,
478
- easing = _getProps14.easing,
479
- slidesToShow = _getProps14.slidesToShow,
480
- slidesToScroll = _getProps14.slidesToScroll;
489
+ var _getProps15 = (0, _props.getProps)(this.props),
490
+ children = _getProps15.children,
491
+ transitionDuration = _getProps15.transitionDuration,
492
+ autoplay = _getProps15.autoplay,
493
+ infinite = _getProps15.infinite,
494
+ duration = _getProps15.duration,
495
+ onChange = _getProps15.onChange,
496
+ easing = _getProps15.easing,
497
+ slidesToShow = _getProps15.slidesToShow,
498
+ slidesToScroll = _getProps15.slidesToScroll;
481
499
 
482
500
  transitionDuration = animationDuration || transitionDuration;
483
501
  var existingTweens = this.tweenGroup.getAll();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-slideshow-image",
3
- "version": "3.6.1",
3
+ "version": "3.7.2",
4
4
  "author": "Femi Oladeji",
5
5
  "description": "An image slideshow with react",
6
6
  "files": [
@@ -45,23 +45,23 @@
45
45
  "html-webpack-plugin": "^3.0.0",
46
46
  "husky": "^0.14.3",
47
47
  "jest": "^26.0.1",
48
- "lint-staged": "^7.3.0",
48
+ "lint-staged": "^12.3.7",
49
49
  "prettier": "^1.14.3",
50
50
  "react": "^17.0.2",
51
51
  "react-dom": "^17.0.2",
52
52
  "react-router": "^5.1.2",
53
53
  "react-router-dom": "^5.1.2",
54
54
  "react-syntax-highlighter": "^15.4.3",
55
- "serve": "^11.3.2",
55
+ "serve": "^13.0.2",
56
56
  "style-loader": "^1.2.1",
57
57
  "uglifycss": "0.0.29",
58
58
  "webpack": "^4.42.0",
59
59
  "webpack-cli": "^3.3.4",
60
- "webpack-dev-server": "^3.7.1"
60
+ "webpack-dev-server": "^4.7.4"
61
61
  },
62
62
  "peerDependencies": {
63
- "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0",
64
- "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0"
63
+ "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0",
64
+ "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0"
65
65
  },
66
66
  "lint-staged": {
67
67
  "{src,__tests__,docs}/**/*.{js,jsx,json,css}": [
@@ -72,15 +72,15 @@
72
72
  "main": "dist/react-slideshow-image.min.js",
73
73
  "scripts": {
74
74
  "dev": "webpack-dev-server",
75
- "build": "webpack --config webpack.config.dist.js && uglifycss src/css/styles.css > dist/styles.css ",
76
- "heroku-postbuild": "npm i --only=dev && webpack --prod",
75
+ "build": "webpack --config webpack.config.dist.js && uglifycss src/css/styles.css > dist/styles.css",
76
+ "heroku-postbuild": "npm i --only=dev && webpack --prod && echo '/* /index.html 200' | cat >public/_redirects",
77
77
  "start": "serve public -s",
78
78
  "precommit": "lint-staged",
79
79
  "test": "jest && codecov",
80
80
  "prepublishOnly": "NODE_ENV=production babel src --out-dir lib --copy-files && npm run build"
81
81
  },
82
82
  "dependencies": {
83
- "@tweenjs/tween.js": "^18.1.2",
83
+ "@tweenjs/tween.js": "^18.6.4",
84
84
  "resize-observer-polyfill": "^1.5.1"
85
85
  }
86
86
  }