react-slideshow-image 3.4.6 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +37 -37
- package/dist/react-slideshow-image.min.js +1 -1
- package/dist/react-slideshow-image.min.js.map +1 -1
- package/lib/fade.js +55 -13
- package/lib/helpers.js +19 -13
- package/lib/props.js +15 -7
- package/lib/slide.js +139 -53
- package/lib/zoom.js +56 -14
- package/package.json +4 -4
package/lib/fade.js
CHANGED
@@ -67,6 +67,8 @@ function (_Component) {
|
|
67
67
|
_this.tweenGroup = new _tween["default"].Group();
|
68
68
|
_this.reactSlideshowWrapper = (0, _react.createRef)();
|
69
69
|
_this.wrapper = (0, _react.createRef)();
|
70
|
+
_this.startSwipe = _this.startSwipe.bind(_assertThisInitialized(_this));
|
71
|
+
_this.endSwipe = _this.endSwipe.bind(_assertThisInitialized(_this));
|
70
72
|
return _this;
|
71
73
|
}
|
72
74
|
|
@@ -258,28 +260,68 @@ function (_Component) {
|
|
258
260
|
this.goNext();
|
259
261
|
}
|
260
262
|
}
|
263
|
+
}, {
|
264
|
+
key: "startSwipe",
|
265
|
+
value: function startSwipe(e) {
|
266
|
+
var _getProps6 = (0, _props.getProps)(this.props),
|
267
|
+
canSwipe = _getProps6.canSwipe;
|
268
|
+
|
269
|
+
if (canSwipe) {
|
270
|
+
this.startingClientX = e.touches ? e.touches[0].pageX : e.clientX;
|
271
|
+
clearTimeout(this.timeout);
|
272
|
+
this.dragging = true;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}, {
|
276
|
+
key: "endSwipe",
|
277
|
+
value: function endSwipe(e) {
|
278
|
+
var clientX = e.changedTouches ? e.changedTouches[0].pageX : e.clientX;
|
279
|
+
var distance = clientX - this.startingClientX;
|
280
|
+
|
281
|
+
var _getProps7 = (0, _props.getProps)(this.props),
|
282
|
+
canSwipe = _getProps7.canSwipe;
|
283
|
+
|
284
|
+
if (canSwipe) {
|
285
|
+
this.dragging = false;
|
286
|
+
|
287
|
+
if (Math.abs(distance) / this.width > 0.2) {
|
288
|
+
if (distance < 0) {
|
289
|
+
this.goNext();
|
290
|
+
} else {
|
291
|
+
this.goBack();
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
261
296
|
}, {
|
262
297
|
key: "render",
|
263
298
|
value: function render() {
|
264
299
|
var _this5 = this;
|
265
300
|
|
266
|
-
var
|
267
|
-
indicators =
|
268
|
-
children =
|
269
|
-
arrows =
|
301
|
+
var _getProps8 = (0, _props.getProps)(this.props),
|
302
|
+
indicators = _getProps8.indicators,
|
303
|
+
children = _getProps8.children,
|
304
|
+
arrows = _getProps8.arrows,
|
305
|
+
cssClass = _getProps8.cssClass;
|
270
306
|
|
271
307
|
var index = this.state.index;
|
272
308
|
var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
|
273
309
|
return _react["default"].createElement("div", _extends({
|
310
|
+
dir: "ltr",
|
274
311
|
"aria-roledescription": "carousel"
|
275
312
|
}, unhandledProps), _react["default"].createElement("div", {
|
276
313
|
className: "react-slideshow-container",
|
277
314
|
onMouseEnter: this.pauseSlides,
|
278
315
|
onMouseOver: this.pauseSlides,
|
279
316
|
onMouseLeave: this.startSlides,
|
317
|
+
onMouseDown: this.startSwipe,
|
318
|
+
onMouseUp: this.endSwipe,
|
319
|
+
onTouchStart: this.startSwipe,
|
320
|
+
onTouchEnd: this.endSwipe,
|
321
|
+
onTouchCancel: this.endSwipe,
|
280
322
|
ref: this.reactSlideshowWrapper
|
281
323
|
}, arrows && (0, _helpers.showPreviousArrow)((0, _props.getProps)(this.props), this.state.index, this.preFade), _react["default"].createElement("div", {
|
282
|
-
className: "react-slideshow-fade-wrapper",
|
324
|
+
className: "react-slideshow-fade-wrapper ".concat(cssClass),
|
283
325
|
ref: this.wrapper
|
284
326
|
}, _react["default"].createElement("div", {
|
285
327
|
className: "react-slideshow-fade-images-wrap",
|
@@ -306,14 +348,14 @@ function (_Component) {
|
|
306
348
|
|
307
349
|
var index = this.state.index;
|
308
350
|
|
309
|
-
var
|
310
|
-
autoplay =
|
311
|
-
children =
|
312
|
-
infinite =
|
313
|
-
duration =
|
314
|
-
transitionDuration =
|
315
|
-
onChange =
|
316
|
-
easing =
|
351
|
+
var _getProps9 = (0, _props.getProps)(this.props),
|
352
|
+
autoplay = _getProps9.autoplay,
|
353
|
+
children = _getProps9.children,
|
354
|
+
infinite = _getProps9.infinite,
|
355
|
+
duration = _getProps9.duration,
|
356
|
+
transitionDuration = _getProps9.transitionDuration,
|
357
|
+
onChange = _getProps9.onChange,
|
358
|
+
easing = _getProps9.easing;
|
317
359
|
|
318
360
|
var existingTweens = this.tweenGroup.getAll();
|
319
361
|
|
package/lib/helpers.js
CHANGED
@@ -76,11 +76,12 @@ var showPreviousArrow = function showPreviousArrow(_ref, currentIndex, moveSlide
|
|
76
76
|
|
77
77
|
exports.showPreviousArrow = showPreviousArrow;
|
78
78
|
|
79
|
-
var showNextArrow = function showNextArrow(
|
80
|
-
var nextArrow =
|
81
|
-
infinite =
|
82
|
-
children =
|
83
|
-
|
79
|
+
var showNextArrow = function showNextArrow(properties, currentIndex, moveSlides) {
|
80
|
+
var nextArrow = properties.nextArrow,
|
81
|
+
infinite = properties.infinite,
|
82
|
+
children = properties.children,
|
83
|
+
slidesToScroll = properties.slidesToScroll;
|
84
|
+
var isDisabled = currentIndex >= children.length - slidesToScroll && !infinite;
|
84
85
|
var props = {
|
85
86
|
'data-type': 'next',
|
86
87
|
'aria-label': 'Next Slide',
|
@@ -108,39 +109,44 @@ var showNextArrow = function showNextArrow(_ref2, currentIndex, moveSlides) {
|
|
108
109
|
|
109
110
|
exports.showNextArrow = showNextArrow;
|
110
111
|
|
111
|
-
var showDefaultIndicator = function showDefaultIndicator(
|
112
|
+
var showDefaultIndicator = function showDefaultIndicator(isCurrentPageActive, key, indicatorProps) {
|
112
113
|
return _react["default"].createElement("li", {
|
113
114
|
key: key
|
114
115
|
}, _react["default"].createElement("button", _extends({
|
115
|
-
className: "each-slideshow-indicator ".concat(
|
116
|
+
className: "each-slideshow-indicator ".concat(isCurrentPageActive ? 'active' : '')
|
116
117
|
}, indicatorProps)));
|
117
118
|
};
|
118
119
|
|
119
|
-
var showCustomIndicator = function showCustomIndicator(
|
120
|
+
var showCustomIndicator = function showCustomIndicator(isCurrentPageActive, key, indicatorProps, eachIndicator) {
|
120
121
|
return _react["default"].cloneElement(eachIndicator, _objectSpread({
|
121
|
-
className: "".concat(eachIndicator.props.className, " ").concat(
|
122
|
+
className: "".concat(eachIndicator.props.className, " ").concat(isCurrentPageActive ? 'active' : ''),
|
122
123
|
key: key
|
123
124
|
}, indicatorProps));
|
124
125
|
};
|
125
126
|
|
126
127
|
var showIndicators = function showIndicators(props, currentIndex, navigate) {
|
127
128
|
var children = props.children,
|
128
|
-
indicators = props.indicators
|
129
|
+
indicators = props.indicators,
|
130
|
+
slidesToScroll = props.slidesToScroll;
|
129
131
|
var isCustomIndicator = typeof indicators !== 'boolean';
|
132
|
+
var pages = Math.ceil(children.length / slidesToScroll);
|
130
133
|
return _react["default"].createElement("ul", {
|
131
134
|
className: "indicators"
|
132
|
-
},
|
135
|
+
}, Array.from({
|
136
|
+
length: pages
|
137
|
+
}, function (_, key) {
|
133
138
|
var indicatorProps = {
|
134
139
|
'data-key': key,
|
135
140
|
'aria-label': "Go to slide ".concat(key + 1),
|
136
141
|
onClick: navigate
|
137
142
|
};
|
143
|
+
var isCurrentPageActive = Math.floor((currentIndex + slidesToScroll - 1) / slidesToScroll) === key;
|
138
144
|
|
139
145
|
if (isCustomIndicator) {
|
140
|
-
return showCustomIndicator(
|
146
|
+
return showCustomIndicator(isCurrentPageActive, key, indicatorProps, indicators(key));
|
141
147
|
}
|
142
148
|
|
143
|
-
return showDefaultIndicator(
|
149
|
+
return showDefaultIndicator(isCurrentPageActive, key, indicatorProps);
|
144
150
|
}));
|
145
151
|
};
|
146
152
|
|
package/lib/props.js
CHANGED
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.validatePropTypes = exports.propTypes = exports.getProps = void 0;
|
7
7
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11
|
+
|
8
12
|
function _typeof(obj) { 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); }
|
9
13
|
|
10
14
|
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; }
|
@@ -24,15 +28,16 @@ var defaultProps = {
|
|
24
28
|
pauseOnHover: true,
|
25
29
|
scale: 1,
|
26
30
|
easing: 'linear',
|
27
|
-
canSwipe: true
|
31
|
+
canSwipe: true,
|
32
|
+
slidesToShow: 1,
|
33
|
+
slidesToScroll: 1,
|
34
|
+
cssClass: ''
|
28
35
|
};
|
29
36
|
|
30
37
|
var getProps = function getProps(componentProps) {
|
31
|
-
var children = componentProps.children
|
32
|
-
|
33
|
-
|
34
|
-
children = [children];
|
35
|
-
}
|
38
|
+
var children = _react["default"].Children.map(componentProps.children, function (each) {
|
39
|
+
return each;
|
40
|
+
});
|
36
41
|
|
37
42
|
return _objectSpread({}, defaultProps, {}, componentProps, {
|
38
43
|
children: children
|
@@ -54,7 +59,10 @@ var propTypes = {
|
|
54
59
|
nextArrow: ['object', 'function'],
|
55
60
|
scale: 'number',
|
56
61
|
easing: 'string',
|
57
|
-
canSwipe: 'boolean'
|
62
|
+
canSwipe: 'boolean',
|
63
|
+
slidesToShow: 'number',
|
64
|
+
slidesToScroll: 'number',
|
65
|
+
cssClass: 'string'
|
58
66
|
};
|
59
67
|
exports.propTypes = propTypes;
|
60
68
|
|
package/lib/slide.js
CHANGED
@@ -152,14 +152,32 @@ function (_Component) {
|
|
152
152
|
key: "swipe",
|
153
153
|
value: function swipe(e) {
|
154
154
|
var _getProps4 = (0, _props.getProps)(this.props),
|
155
|
-
canSwipe = _getProps4.canSwipe
|
155
|
+
canSwipe = _getProps4.canSwipe,
|
156
|
+
slidesToShow = _getProps4.slidesToShow,
|
157
|
+
children = _getProps4.children,
|
158
|
+
infinite = _getProps4.infinite,
|
159
|
+
slidesToScroll = _getProps4.slidesToScroll;
|
156
160
|
|
157
161
|
if (canSwipe) {
|
158
162
|
var clientX = e.touches ? e.touches[0].pageX : e.clientX;
|
159
163
|
|
160
164
|
if (this.dragging) {
|
161
|
-
var translateValue = this.width * (this.state.index +
|
162
|
-
|
165
|
+
var translateValue = this.width * (this.state.index + slidesToShow);
|
166
|
+
var distance = clientX - this.startingClientX;
|
167
|
+
|
168
|
+
if (!infinite && this.state.index === children.length - slidesToScroll && distance < 0) {
|
169
|
+
// if it is the last and infinite is false and you're swiping left
|
170
|
+
// then nothing happens
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
|
174
|
+
if (!infinite && this.state.index === 0 && distance > 0) {
|
175
|
+
// if it is the first and infinite is false and you're swiping right
|
176
|
+
// then nothing happens
|
177
|
+
return;
|
178
|
+
}
|
179
|
+
|
180
|
+
this.distanceSwiped = distance;
|
163
181
|
translateValue -= this.distanceSwiped;
|
164
182
|
this.imageContainer.style.transform = "translate(-".concat(translateValue, "px)");
|
165
183
|
}
|
@@ -177,12 +195,19 @@ function (_Component) {
|
|
177
195
|
value: function setWidth() {
|
178
196
|
// the .slice.call was needed to support ie11
|
179
197
|
this.allImages = this.wrapper && Array.prototype.slice.call(this.wrapper.querySelectorAll(".images-wrap > div"), 0) || [];
|
180
|
-
|
181
|
-
var
|
198
|
+
|
199
|
+
var _getProps5 = (0, _props.getProps)(this.props),
|
200
|
+
slidesToShow = _getProps5.slidesToShow;
|
201
|
+
|
202
|
+
this.width = (this.wrapper && this.wrapper.clientWidth || 0) / slidesToShow;
|
203
|
+
|
204
|
+
var numberOfSlides = _react["default"].Children.count(this.props.children);
|
205
|
+
|
206
|
+
var fullwidth = this.width * (numberOfSlides + slidesToShow * 2);
|
182
207
|
|
183
208
|
if (this.imageContainer) {
|
184
209
|
this.imageContainer.style.width = "".concat(fullwidth, "px");
|
185
|
-
this.imageContainer.style.transform = "translate(-".concat(this.width * (this.state.index +
|
210
|
+
this.imageContainer.style.transform = "translate(-".concat(this.width * (this.state.index + slidesToShow), "px)");
|
186
211
|
}
|
187
212
|
|
188
213
|
this.applySlideStyle();
|
@@ -192,10 +217,10 @@ function (_Component) {
|
|
192
217
|
value: function componentDidUpdate(props) {
|
193
218
|
var _this4 = this;
|
194
219
|
|
195
|
-
var
|
196
|
-
autoplay =
|
197
|
-
duration =
|
198
|
-
children =
|
220
|
+
var _getProps6 = (0, _props.getProps)(this.props),
|
221
|
+
autoplay = _getProps6.autoplay,
|
222
|
+
duration = _getProps6.duration,
|
223
|
+
children = _getProps6.children;
|
199
224
|
|
200
225
|
var newProps = (0, _props.getProps)(props);
|
201
226
|
|
@@ -243,10 +268,10 @@ function (_Component) {
|
|
243
268
|
value: function startSlides() {
|
244
269
|
var _this6 = this;
|
245
270
|
|
246
|
-
var
|
247
|
-
pauseOnHover =
|
248
|
-
autoplay =
|
249
|
-
duration =
|
271
|
+
var _getProps7 = (0, _props.getProps)(this.props),
|
272
|
+
pauseOnHover = _getProps7.pauseOnHover,
|
273
|
+
autoplay = _getProps7.autoplay,
|
274
|
+
duration = _getProps7.duration;
|
250
275
|
|
251
276
|
if (this.dragging) {
|
252
277
|
this.endSwipe();
|
@@ -273,58 +298,123 @@ function (_Component) {
|
|
273
298
|
key: "goToSlide",
|
274
299
|
value: function goToSlide(_ref2) {
|
275
300
|
var currentTarget = _ref2.currentTarget;
|
276
|
-
|
301
|
+
|
302
|
+
var _getProps8 = (0, _props.getProps)(this.props),
|
303
|
+
slidesToScroll = _getProps8.slidesToScroll;
|
304
|
+
|
305
|
+
this.goTo(parseInt(currentTarget.dataset.key * slidesToScroll));
|
277
306
|
}
|
278
307
|
}, {
|
279
308
|
key: "goTo",
|
280
309
|
value: function goTo(index) {
|
281
|
-
this.slideImages(index);
|
310
|
+
this.slideImages(this.calculateIndex(index));
|
311
|
+
}
|
312
|
+
}, {
|
313
|
+
key: "calculateIndex",
|
314
|
+
value: function calculateIndex(nextIndex) {
|
315
|
+
var _getProps9 = (0, _props.getProps)(this.props),
|
316
|
+
children = _getProps9.children,
|
317
|
+
slidesToScroll = _getProps9.slidesToScroll;
|
318
|
+
|
319
|
+
if (nextIndex < children.length && nextIndex + slidesToScroll > children.length) {
|
320
|
+
if ((children.length - slidesToScroll) % slidesToScroll) {
|
321
|
+
return children.length - slidesToScroll;
|
322
|
+
}
|
323
|
+
|
324
|
+
return nextIndex;
|
325
|
+
}
|
326
|
+
|
327
|
+
return nextIndex;
|
282
328
|
}
|
283
329
|
}, {
|
284
330
|
key: "goNext",
|
285
331
|
value: function goNext() {
|
286
332
|
var index = this.state.index;
|
287
333
|
|
288
|
-
var
|
289
|
-
children =
|
290
|
-
infinite =
|
334
|
+
var _getProps10 = (0, _props.getProps)(this.props),
|
335
|
+
children = _getProps10.children,
|
336
|
+
infinite = _getProps10.infinite,
|
337
|
+
slidesToScroll = _getProps10.slidesToScroll;
|
291
338
|
|
292
|
-
if (!infinite && index === children.length -
|
339
|
+
if (!infinite && index === children.length - slidesToScroll) {
|
293
340
|
return;
|
294
341
|
}
|
295
342
|
|
296
|
-
this.
|
343
|
+
var nextIndex = this.calculateIndex(index + slidesToScroll);
|
344
|
+
this.slideImages(nextIndex);
|
297
345
|
}
|
298
346
|
}, {
|
299
347
|
key: "goBack",
|
300
348
|
value: function goBack() {
|
301
349
|
var index = this.state.index;
|
302
350
|
|
303
|
-
var
|
304
|
-
infinite =
|
351
|
+
var _getProps11 = (0, _props.getProps)(this.props),
|
352
|
+
infinite = _getProps11.infinite,
|
353
|
+
slidesToScroll = _getProps11.slidesToScroll;
|
305
354
|
|
306
355
|
if (!infinite && index === 0) {
|
307
356
|
return;
|
308
357
|
}
|
309
358
|
|
310
|
-
|
359
|
+
var previousIndex = index - slidesToScroll;
|
360
|
+
|
361
|
+
if (previousIndex % slidesToScroll) {
|
362
|
+
previousIndex = Math.ceil(previousIndex / slidesToScroll) * slidesToScroll;
|
363
|
+
}
|
364
|
+
|
365
|
+
this.slideImages(previousIndex);
|
366
|
+
}
|
367
|
+
}, {
|
368
|
+
key: "isSlideActive",
|
369
|
+
value: function isSlideActive(key) {
|
370
|
+
var _getProps12 = (0, _props.getProps)(this.props),
|
371
|
+
slidesToShow = _getProps12.slidesToShow;
|
372
|
+
|
373
|
+
return key < this.state.index + slidesToShow && key >= this.state.index;
|
374
|
+
}
|
375
|
+
}, {
|
376
|
+
key: "renderPreceedingSlides",
|
377
|
+
value: function renderPreceedingSlides(children, slidesToShow) {
|
378
|
+
return children.slice(-slidesToShow).map(function (each, index) {
|
379
|
+
return _react["default"].createElement("div", {
|
380
|
+
"data-index": index - slidesToShow,
|
381
|
+
"aria-roledescription": "slide",
|
382
|
+
"aria-hidden": "true",
|
383
|
+
key: index - slidesToShow
|
384
|
+
}, each);
|
385
|
+
});
|
386
|
+
}
|
387
|
+
}, {
|
388
|
+
key: "renderTrailingSlides",
|
389
|
+
value: function renderTrailingSlides(children, slidesToShow) {
|
390
|
+
return children.slice(0, slidesToShow).map(function (each, index) {
|
391
|
+
return _react["default"].createElement("div", {
|
392
|
+
"data-index": children.length + index,
|
393
|
+
"aria-roledescription": "slide",
|
394
|
+
"aria-hidden": "true",
|
395
|
+
key: children.length + index
|
396
|
+
}, each);
|
397
|
+
});
|
311
398
|
}
|
312
399
|
}, {
|
313
400
|
key: "render",
|
314
401
|
value: function render() {
|
315
402
|
var _this7 = this;
|
316
403
|
|
317
|
-
var
|
318
|
-
children =
|
319
|
-
indicators =
|
320
|
-
arrows =
|
404
|
+
var _getProps13 = (0, _props.getProps)(this.props),
|
405
|
+
children = _getProps13.children,
|
406
|
+
indicators = _getProps13.indicators,
|
407
|
+
arrows = _getProps13.arrows,
|
408
|
+
cssClass = _getProps13.cssClass,
|
409
|
+
slidesToShow = _getProps13.slidesToShow;
|
321
410
|
|
322
411
|
var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
|
323
412
|
var index = this.state.index;
|
324
413
|
var style = {
|
325
|
-
transform: "translate(-".concat((index +
|
414
|
+
transform: "translate(-".concat((index + slidesToShow) * this.width, "px)")
|
326
415
|
};
|
327
416
|
return _react["default"].createElement("div", _extends({
|
417
|
+
dir: "ltr",
|
328
418
|
"aria-roledescription": "carousel"
|
329
419
|
}, unhandledProps), _react["default"].createElement("div", {
|
330
420
|
className: "react-slideshow-container",
|
@@ -340,7 +430,7 @@ function (_Component) {
|
|
340
430
|
onTouchMove: this.swipe,
|
341
431
|
ref: this.reactSlideshowWrapper
|
342
432
|
}, arrows && (0, _helpers.showPreviousArrow)((0, _props.getProps)(this.props), this.state.index, this.moveSlides), _react["default"].createElement("div", {
|
343
|
-
className: "react-slideshow-wrapper slide",
|
433
|
+
className: "react-slideshow-wrapper slide ".concat(cssClass),
|
344
434
|
ref: function ref(_ref4) {
|
345
435
|
return _this7.wrapper = _ref4;
|
346
436
|
}
|
@@ -350,37 +440,33 @@ function (_Component) {
|
|
350
440
|
ref: function ref(_ref3) {
|
351
441
|
return _this7.imageContainer = _ref3;
|
352
442
|
}
|
353
|
-
},
|
354
|
-
|
355
|
-
|
356
|
-
"aria-hidden": "false"
|
357
|
-
}, children[children.length - 1]), children.map(function (each, key) {
|
443
|
+
}, this.renderPreceedingSlides(children, slidesToShow), children.map(function (each, key) {
|
444
|
+
var isSlideActive = _this7.isSlideActive(key);
|
445
|
+
|
358
446
|
return _react["default"].createElement("div", {
|
359
447
|
"data-index": key,
|
360
448
|
key: key,
|
361
|
-
className:
|
449
|
+
className: isSlideActive ? 'active' : '',
|
362
450
|
"aria-roledescription": "slide",
|
363
|
-
"aria-hidden":
|
451
|
+
"aria-hidden": isSlideActive ? 'false' : 'true'
|
364
452
|
}, each);
|
365
|
-
}),
|
366
|
-
"data-index": "-1",
|
367
|
-
"aria-roledescription": "slide",
|
368
|
-
"aria-hidden": "false"
|
369
|
-
}, children[0]))), 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));
|
453
|
+
}), 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));
|
370
454
|
}
|
371
455
|
}, {
|
372
456
|
key: "slideImages",
|
373
457
|
value: function slideImages(index, animationDuration) {
|
374
458
|
var _this8 = this;
|
375
459
|
|
376
|
-
var
|
377
|
-
children =
|
378
|
-
transitionDuration =
|
379
|
-
autoplay =
|
380
|
-
infinite =
|
381
|
-
duration =
|
382
|
-
onChange =
|
383
|
-
easing =
|
460
|
+
var _getProps14 = (0, _props.getProps)(this.props),
|
461
|
+
children = _getProps14.children,
|
462
|
+
transitionDuration = _getProps14.transitionDuration,
|
463
|
+
autoplay = _getProps14.autoplay,
|
464
|
+
infinite = _getProps14.infinite,
|
465
|
+
duration = _getProps14.duration,
|
466
|
+
onChange = _getProps14.onChange,
|
467
|
+
easing = _getProps14.easing,
|
468
|
+
slidesToShow = _getProps14.slidesToShow,
|
469
|
+
slidesToScroll = _getProps14.slidesToScroll;
|
384
470
|
|
385
471
|
transitionDuration = animationDuration || transitionDuration;
|
386
472
|
var existingTweens = this.tweenGroup.getAll();
|
@@ -388,10 +474,10 @@ function (_Component) {
|
|
388
474
|
if (!existingTweens.length) {
|
389
475
|
clearTimeout(this.timeout);
|
390
476
|
var value = {
|
391
|
-
margin: -this.width * (this.state.index +
|
477
|
+
margin: -this.width * (this.state.index + slidesToShow) + this.distanceSwiped
|
392
478
|
};
|
393
479
|
var tween = new _tween["default"].Tween(value, this.tweenGroup).to({
|
394
|
-
margin: -this.width * (index +
|
480
|
+
margin: -this.width * (index + slidesToShow)
|
395
481
|
}, transitionDuration).onUpdate(function (value) {
|
396
482
|
if (_this8.imageContainer) {
|
397
483
|
_this8.imageContainer.style.transform = "translate(".concat(value.margin, "px)");
|
@@ -421,7 +507,7 @@ function (_Component) {
|
|
421
507
|
var newIndex = index;
|
422
508
|
|
423
509
|
if (newIndex < 0) {
|
424
|
-
newIndex = children.length -
|
510
|
+
newIndex = children.length - slidesToScroll;
|
425
511
|
} else if (newIndex >= children.length) {
|
426
512
|
newIndex = 0;
|
427
513
|
}
|
package/lib/zoom.js
CHANGED
@@ -66,6 +66,8 @@ function (_Component) {
|
|
66
66
|
_this.tweenGroup = new _tween["default"].Group();
|
67
67
|
_this.initResizeObserver = _this.initResizeObserver.bind(_assertThisInitialized(_this));
|
68
68
|
_this.reactSlideshowWrapper = (0, _react.createRef)();
|
69
|
+
_this.startSwipe = _this.startSwipe.bind(_assertThisInitialized(_this));
|
70
|
+
_this.endSwipe = _this.endSwipe.bind(_assertThisInitialized(_this));
|
69
71
|
return _this;
|
70
72
|
}
|
71
73
|
|
@@ -257,28 +259,68 @@ function (_Component) {
|
|
257
259
|
this.goNext();
|
258
260
|
}
|
259
261
|
}
|
262
|
+
}, {
|
263
|
+
key: "startSwipe",
|
264
|
+
value: function startSwipe(e) {
|
265
|
+
var _getProps6 = (0, _props.getProps)(this.props),
|
266
|
+
canSwipe = _getProps6.canSwipe;
|
267
|
+
|
268
|
+
if (canSwipe) {
|
269
|
+
this.startingClientX = e.touches ? e.touches[0].pageX : e.clientX;
|
270
|
+
clearTimeout(this.timeout);
|
271
|
+
this.dragging = true;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}, {
|
275
|
+
key: "endSwipe",
|
276
|
+
value: function endSwipe(e) {
|
277
|
+
var clientX = e.changedTouches ? e.changedTouches[0].pageX : e.clientX;
|
278
|
+
var distance = clientX - this.startingClientX;
|
279
|
+
|
280
|
+
var _getProps7 = (0, _props.getProps)(this.props),
|
281
|
+
canSwipe = _getProps7.canSwipe;
|
282
|
+
|
283
|
+
if (canSwipe) {
|
284
|
+
this.dragging = false;
|
285
|
+
|
286
|
+
if (Math.abs(distance) / this.width > 0.2) {
|
287
|
+
if (distance < 0) {
|
288
|
+
this.goNext();
|
289
|
+
} else {
|
290
|
+
this.goBack();
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}
|
260
295
|
}, {
|
261
296
|
key: "render",
|
262
297
|
value: function render() {
|
263
298
|
var _this5 = this;
|
264
299
|
|
265
|
-
var
|
266
|
-
indicators =
|
267
|
-
arrows =
|
268
|
-
children =
|
300
|
+
var _getProps8 = (0, _props.getProps)(this.props),
|
301
|
+
indicators = _getProps8.indicators,
|
302
|
+
arrows = _getProps8.arrows,
|
303
|
+
children = _getProps8.children,
|
304
|
+
cssClass = _getProps8.cssClass;
|
269
305
|
|
270
306
|
var index = this.state.index;
|
271
307
|
var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
|
272
308
|
return _react["default"].createElement("div", _extends({
|
309
|
+
dir: "ltr",
|
273
310
|
"aria-roledescription": "carousel"
|
274
311
|
}, unhandledProps), _react["default"].createElement("div", {
|
275
312
|
className: "react-slideshow-container",
|
276
313
|
onMouseEnter: this.pauseSlides,
|
277
314
|
onMouseOver: this.pauseSlides,
|
278
315
|
onMouseLeave: this.startSlides,
|
316
|
+
onMouseDown: this.startSwipe,
|
317
|
+
onMouseUp: this.endSwipe,
|
318
|
+
onTouchStart: this.startSwipe,
|
319
|
+
onTouchEnd: this.endSwipe,
|
320
|
+
onTouchCancel: this.endSwipe,
|
279
321
|
ref: this.reactSlideshowWrapper
|
280
322
|
}, arrows && (0, _helpers.showPreviousArrow)((0, _props.getProps)(this.props), this.state.index, this.preZoom), _react["default"].createElement("div", {
|
281
|
-
className: "react-slideshow-zoom-wrapper",
|
323
|
+
className: "react-slideshow-zoom-wrapper ".concat(cssClass),
|
282
324
|
ref: function ref(_ref3) {
|
283
325
|
return _this5.wrapper = _ref3;
|
284
326
|
}
|
@@ -307,15 +349,15 @@ function (_Component) {
|
|
307
349
|
|
308
350
|
var index = this.state.index;
|
309
351
|
|
310
|
-
var
|
311
|
-
children =
|
312
|
-
scale =
|
313
|
-
autoplay =
|
314
|
-
infinite =
|
315
|
-
transitionDuration =
|
316
|
-
duration =
|
317
|
-
onChange =
|
318
|
-
easing =
|
352
|
+
var _getProps9 = (0, _props.getProps)(this.props),
|
353
|
+
children = _getProps9.children,
|
354
|
+
scale = _getProps9.scale,
|
355
|
+
autoplay = _getProps9.autoplay,
|
356
|
+
infinite = _getProps9.infinite,
|
357
|
+
transitionDuration = _getProps9.transitionDuration,
|
358
|
+
duration = _getProps9.duration,
|
359
|
+
onChange = _getProps9.onChange,
|
360
|
+
easing = _getProps9.easing;
|
319
361
|
|
320
362
|
var existingTweens = this.tweenGroup.getAll();
|
321
363
|
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-slideshow-image",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.6.0",
|
4
4
|
"author": "Femi Oladeji",
|
5
5
|
"description": "An image slideshow with react",
|
6
6
|
"files": [
|
7
7
|
"lib",
|
8
8
|
"dist"
|
9
9
|
],
|
10
|
-
"homepage": "https://react-slideshow.
|
10
|
+
"homepage": "https://react-slideshow-image.netlify.com",
|
11
11
|
"npmFileMap": [
|
12
12
|
{
|
13
13
|
"basePath": "/dist/",
|
@@ -56,8 +56,8 @@
|
|
56
56
|
"style-loader": "^1.2.1",
|
57
57
|
"uglifycss": "0.0.29",
|
58
58
|
"webpack": "^4.42.0",
|
59
|
-
"webpack-cli": "^3.
|
60
|
-
"webpack-dev-server": "^3.
|
59
|
+
"webpack-cli": "^3.3.4",
|
60
|
+
"webpack-dev-server": "^3.7.1"
|
61
61
|
},
|
62
62
|
"peerDependencies": {
|
63
63
|
"react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0",
|