react-slideshow-image 3.7.1 → 3.7.4
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/README.md +5 -5
- package/dist/react-slideshow-image.min.js +1 -1
- package/dist/react-slideshow-image.min.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +16 -18
- package/lib/css/styles.css +0 -155
- package/lib/fade.js +0 -420
- package/lib/helpers.js +0 -153
- package/lib/index.js +0 -31
- package/lib/props.js +0 -104
- package/lib/slide.js +0 -567
- package/lib/zoom.js +0 -431
package/lib/zoom.js
DELETED
@@ -1,431 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports["default"] = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
11
|
-
|
12
|
-
var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
|
13
|
-
|
14
|
-
var _props = require("./props");
|
15
|
-
|
16
|
-
var _helpers = require("./helpers.js");
|
17
|
-
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
19
|
-
|
20
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
|
21
|
-
|
22
|
-
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); }
|
23
|
-
|
24
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
25
|
-
|
26
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
27
|
-
|
28
|
-
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); } }
|
29
|
-
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
31
|
-
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
33
|
-
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
35
|
-
|
36
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
37
|
-
|
38
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
39
|
-
|
40
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
41
|
-
|
42
|
-
var Zoom =
|
43
|
-
/*#__PURE__*/
|
44
|
-
function (_Component) {
|
45
|
-
_inherits(Zoom, _Component);
|
46
|
-
|
47
|
-
function Zoom(props) {
|
48
|
-
var _this;
|
49
|
-
|
50
|
-
_classCallCheck(this, Zoom);
|
51
|
-
|
52
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Zoom).call(this));
|
53
|
-
_this.state = {
|
54
|
-
index: props.defaultIndex && props.defaultIndex < props.children.length ? props.defaultIndex : 0
|
55
|
-
};
|
56
|
-
_this.width = 0;
|
57
|
-
_this.timeout = null;
|
58
|
-
_this.divsContainer = null;
|
59
|
-
_this.wrapper = null;
|
60
|
-
_this.setWidth = _this.setWidth.bind(_assertThisInitialized(_this));
|
61
|
-
_this.handleResize = _this.handleResize.bind(_assertThisInitialized(_this));
|
62
|
-
_this.navigate = _this.navigate.bind(_assertThisInitialized(_this));
|
63
|
-
_this.preZoom = _this.preZoom.bind(_assertThisInitialized(_this));
|
64
|
-
_this.pauseSlides = _this.pauseSlides.bind(_assertThisInitialized(_this));
|
65
|
-
_this.startSlides = _this.startSlides.bind(_assertThisInitialized(_this));
|
66
|
-
_this.tweenGroup = new _tween["default"].Group();
|
67
|
-
_this.initResizeObserver = _this.initResizeObserver.bind(_assertThisInitialized(_this));
|
68
|
-
_this.reactSlideshowWrapper = (0, _react.createRef)();
|
69
|
-
_this.startSwipe = _this.startSwipe.bind(_assertThisInitialized(_this));
|
70
|
-
_this.endSwipe = _this.endSwipe.bind(_assertThisInitialized(_this));
|
71
|
-
return _this;
|
72
|
-
}
|
73
|
-
|
74
|
-
_createClass(Zoom, [{
|
75
|
-
key: "componentDidMount",
|
76
|
-
value: function componentDidMount() {
|
77
|
-
this.setWidth();
|
78
|
-
this.play();
|
79
|
-
this.initResizeObserver();
|
80
|
-
(0, _props.validatePropTypes)(this.props);
|
81
|
-
}
|
82
|
-
}, {
|
83
|
-
key: "initResizeObserver",
|
84
|
-
value: function initResizeObserver() {
|
85
|
-
var _this2 = this;
|
86
|
-
|
87
|
-
if (this.reactSlideshowWrapper.current) {
|
88
|
-
this.resizeObserver = new _resizeObserverPolyfill["default"](function (entries) {
|
89
|
-
if (!entries) return;
|
90
|
-
|
91
|
-
_this2.handleResize();
|
92
|
-
});
|
93
|
-
this.resizeObserver.observe(this.reactSlideshowWrapper.current);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}, {
|
97
|
-
key: "play",
|
98
|
-
value: function play() {
|
99
|
-
var _this3 = this;
|
100
|
-
|
101
|
-
var _getProps = (0, _props.getProps)(this.props),
|
102
|
-
autoplay = _getProps.autoplay,
|
103
|
-
children = _getProps.children,
|
104
|
-
duration = _getProps.duration;
|
105
|
-
|
106
|
-
var index = this.state.index;
|
107
|
-
|
108
|
-
if (autoplay && children.length > 1) {
|
109
|
-
clearTimeout(this.timeout);
|
110
|
-
this.timeout = setTimeout(function () {
|
111
|
-
return _this3.zoomTo(index + 1);
|
112
|
-
}, duration);
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}, {
|
116
|
-
key: "componentWillUnmount",
|
117
|
-
value: function componentWillUnmount() {
|
118
|
-
this.willUnmount = true;
|
119
|
-
clearTimeout(this.timeout);
|
120
|
-
this.removeResizeObserver();
|
121
|
-
}
|
122
|
-
}, {
|
123
|
-
key: "removeResizeObserver",
|
124
|
-
value: function removeResizeObserver() {
|
125
|
-
if (this.resizeObserver && this.reactSlideshowWrapper && this.reactSlideshowWrapper.current) {
|
126
|
-
this.resizeObserver.unobserve(this.reactSlideshowWrapper.current);
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}, {
|
130
|
-
key: "componentDidUpdate",
|
131
|
-
value: function componentDidUpdate(props) {
|
132
|
-
var _getProps2 = (0, _props.getProps)(this.props),
|
133
|
-
autoplay = _getProps2.autoplay,
|
134
|
-
children = _getProps2.children;
|
135
|
-
|
136
|
-
var newProps = (0, _props.getProps)(props);
|
137
|
-
|
138
|
-
if (autoplay !== newProps.autoplay) {
|
139
|
-
if (autoplay) {
|
140
|
-
this.play();
|
141
|
-
} else {
|
142
|
-
clearTimeout(this.timeout);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
if (children.length != newProps.children.length) {
|
147
|
-
this.applyStyle();
|
148
|
-
clearTimeout(this.timeout);
|
149
|
-
this.play();
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}, {
|
153
|
-
key: "setWidth",
|
154
|
-
value: function setWidth() {
|
155
|
-
if (this.wrapper) {
|
156
|
-
this.width = this.wrapper.clientWidth;
|
157
|
-
}
|
158
|
-
|
159
|
-
this.applyStyle();
|
160
|
-
}
|
161
|
-
}, {
|
162
|
-
key: "handleResize",
|
163
|
-
value: function handleResize() {
|
164
|
-
this.setWidth();
|
165
|
-
}
|
166
|
-
}, {
|
167
|
-
key: "applyStyle",
|
168
|
-
value: function applyStyle() {
|
169
|
-
var fullwidth = this.width * _react["default"].Children.count(this.props.children);
|
170
|
-
|
171
|
-
if (this.divsContainer) {
|
172
|
-
this.divsContainer.style.width = "".concat(fullwidth, "px");
|
173
|
-
|
174
|
-
for (var index = 0; index < this.divsContainer.children.length; index++) {
|
175
|
-
var eachDiv = this.divsContainer.children[index];
|
176
|
-
|
177
|
-
if (eachDiv) {
|
178
|
-
eachDiv.style.width = "".concat(this.width, "px");
|
179
|
-
eachDiv.style.left = "".concat(index * -this.width, "px");
|
180
|
-
}
|
181
|
-
}
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}, {
|
185
|
-
key: "pauseSlides",
|
186
|
-
value: function pauseSlides() {
|
187
|
-
if ((0, _props.getProps)(this.props).pauseOnHover) {
|
188
|
-
clearTimeout(this.timeout);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}, {
|
192
|
-
key: "startSlides",
|
193
|
-
value: function startSlides() {
|
194
|
-
var _this4 = this;
|
195
|
-
|
196
|
-
var _getProps3 = (0, _props.getProps)(this.props),
|
197
|
-
pauseOnHover = _getProps3.pauseOnHover,
|
198
|
-
autoplay = _getProps3.autoplay,
|
199
|
-
duration = _getProps3.duration;
|
200
|
-
|
201
|
-
if (pauseOnHover && autoplay) {
|
202
|
-
this.timeout = setTimeout(function () {
|
203
|
-
return _this4.goNext();
|
204
|
-
}, duration);
|
205
|
-
}
|
206
|
-
}
|
207
|
-
}, {
|
208
|
-
key: "goNext",
|
209
|
-
value: function goNext() {
|
210
|
-
var index = this.state.index;
|
211
|
-
|
212
|
-
var _getProps4 = (0, _props.getProps)(this.props),
|
213
|
-
children = _getProps4.children,
|
214
|
-
infinite = _getProps4.infinite;
|
215
|
-
|
216
|
-
if (!infinite && index === children.length - 1) {
|
217
|
-
return;
|
218
|
-
}
|
219
|
-
|
220
|
-
this.zoomTo((index + 1) % children.length);
|
221
|
-
}
|
222
|
-
}, {
|
223
|
-
key: "goBack",
|
224
|
-
value: function goBack() {
|
225
|
-
var index = this.state.index;
|
226
|
-
|
227
|
-
var _getProps5 = (0, _props.getProps)(this.props),
|
228
|
-
children = _getProps5.children,
|
229
|
-
infinite = _getProps5.infinite;
|
230
|
-
|
231
|
-
if (!infinite && index === 0) {
|
232
|
-
return;
|
233
|
-
}
|
234
|
-
|
235
|
-
this.zoomTo(index === 0 ? children.length - 1 : index - 1);
|
236
|
-
}
|
237
|
-
}, {
|
238
|
-
key: "goTo",
|
239
|
-
value: function goTo(index) {
|
240
|
-
this.zoomTo(index);
|
241
|
-
}
|
242
|
-
}, {
|
243
|
-
key: "navigate",
|
244
|
-
value: function navigate(_ref) {
|
245
|
-
var dataset = _ref.currentTarget.dataset;
|
246
|
-
|
247
|
-
if (dataset.key != this.state.index) {
|
248
|
-
this.goTo(parseInt(dataset.key));
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}, {
|
252
|
-
key: "preZoom",
|
253
|
-
value: function preZoom(_ref2) {
|
254
|
-
var currentTarget = _ref2.currentTarget;
|
255
|
-
|
256
|
-
if (currentTarget.dataset.type === 'prev') {
|
257
|
-
this.goBack();
|
258
|
-
} else {
|
259
|
-
this.goNext();
|
260
|
-
}
|
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
|
-
}
|
295
|
-
}, {
|
296
|
-
key: "render",
|
297
|
-
value: function render() {
|
298
|
-
var _this5 = this;
|
299
|
-
|
300
|
-
var _getProps8 = (0, _props.getProps)(this.props),
|
301
|
-
indicators = _getProps8.indicators,
|
302
|
-
arrows = _getProps8.arrows,
|
303
|
-
children = _getProps8.children,
|
304
|
-
cssClass = _getProps8.cssClass;
|
305
|
-
|
306
|
-
var index = this.state.index;
|
307
|
-
var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
|
308
|
-
return _react["default"].createElement("div", _extends({
|
309
|
-
dir: "ltr",
|
310
|
-
"aria-roledescription": "carousel"
|
311
|
-
}, unhandledProps), _react["default"].createElement("div", {
|
312
|
-
className: "react-slideshow-container",
|
313
|
-
onMouseEnter: this.pauseSlides,
|
314
|
-
onMouseOver: this.pauseSlides,
|
315
|
-
onMouseLeave: this.startSlides,
|
316
|
-
onMouseDown: this.startSwipe,
|
317
|
-
onMouseUp: this.endSwipe,
|
318
|
-
onTouchStart: this.startSwipe,
|
319
|
-
onTouchEnd: this.endSwipe,
|
320
|
-
onTouchCancel: this.endSwipe,
|
321
|
-
ref: this.reactSlideshowWrapper
|
322
|
-
}, arrows && (0, _helpers.showPreviousArrow)((0, _props.getProps)(this.props), this.state.index, this.preZoom), _react["default"].createElement("div", {
|
323
|
-
className: "react-slideshow-zoom-wrapper ".concat(cssClass),
|
324
|
-
ref: function ref(_ref3) {
|
325
|
-
return _this5.wrapper = _ref3;
|
326
|
-
}
|
327
|
-
}, _react["default"].createElement("div", {
|
328
|
-
className: "zoom-wrapper",
|
329
|
-
ref: function ref(wrap) {
|
330
|
-
return _this5.divsContainer = wrap;
|
331
|
-
}
|
332
|
-
}, children.map(function (each, key) {
|
333
|
-
return _react["default"].createElement("div", {
|
334
|
-
style: {
|
335
|
-
opacity: key === index ? '1' : '0',
|
336
|
-
zIndex: key === index ? '1' : '0'
|
337
|
-
},
|
338
|
-
"data-index": key,
|
339
|
-
key: key,
|
340
|
-
"aria-roledescription": "slide",
|
341
|
-
"aria-hidden": key === index ? 'false' : 'true'
|
342
|
-
}, each);
|
343
|
-
}))), arrows && (0, _helpers.showNextArrow)((0, _props.getProps)(this.props), this.state.index, this.preZoom)), indicators && (0, _helpers.showIndicators)((0, _props.getProps)(this.props), this.state.index, this.navigate));
|
344
|
-
}
|
345
|
-
}, {
|
346
|
-
key: "zoomTo",
|
347
|
-
value: function zoomTo(newIndex) {
|
348
|
-
var _this6 = this;
|
349
|
-
|
350
|
-
var index = this.state.index;
|
351
|
-
|
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;
|
361
|
-
|
362
|
-
var existingTweens = this.tweenGroup.getAll();
|
363
|
-
|
364
|
-
if (!existingTweens.length) {
|
365
|
-
if (this.divsContainer && !this.divsContainer.children[newIndex]) {
|
366
|
-
newIndex = 0;
|
367
|
-
}
|
368
|
-
|
369
|
-
clearTimeout(this.timeout);
|
370
|
-
var value = {
|
371
|
-
opacity: 0,
|
372
|
-
scale: 1
|
373
|
-
};
|
374
|
-
|
375
|
-
var animate = function animate() {
|
376
|
-
if (_this6.willUnmount) {
|
377
|
-
_this6.tweenGroup.removeAll();
|
378
|
-
|
379
|
-
return;
|
380
|
-
}
|
381
|
-
|
382
|
-
requestAnimationFrame(animate);
|
383
|
-
|
384
|
-
_this6.tweenGroup.update();
|
385
|
-
};
|
386
|
-
|
387
|
-
animate();
|
388
|
-
var tween = new _tween["default"].Tween(value, this.tweenGroup).to({
|
389
|
-
opacity: 1,
|
390
|
-
scale: scale
|
391
|
-
}, transitionDuration).onUpdate(function (value) {
|
392
|
-
if (_this6.divsContainer) {
|
393
|
-
_this6.divsContainer.children[newIndex].style.opacity = value.opacity;
|
394
|
-
_this6.divsContainer.children[index].style.opacity = 1 - value.opacity;
|
395
|
-
_this6.divsContainer.children[index].style.transform = "scale(".concat(value.scale, ")");
|
396
|
-
}
|
397
|
-
}).start();
|
398
|
-
tween.easing((0, _helpers.getEasing)(easing));
|
399
|
-
tween.onComplete(function () {
|
400
|
-
if (_this6.willUnmount) {
|
401
|
-
return;
|
402
|
-
}
|
403
|
-
|
404
|
-
if (typeof onChange === 'function') {
|
405
|
-
onChange(index, newIndex);
|
406
|
-
}
|
407
|
-
|
408
|
-
_this6.setState({
|
409
|
-
index: newIndex
|
410
|
-
}, function () {
|
411
|
-
if (_this6.divsContainer) {
|
412
|
-
_this6.divsContainer.children[index].style.transform = "scale(1)";
|
413
|
-
}
|
414
|
-
});
|
415
|
-
|
416
|
-
if (autoplay && (infinite || newIndex < children.length - 1)) {
|
417
|
-
clearTimeout(_this6.timeout);
|
418
|
-
_this6.timeout = setTimeout(function () {
|
419
|
-
_this6.zoomTo((newIndex + 1) % children.length);
|
420
|
-
}, duration);
|
421
|
-
}
|
422
|
-
});
|
423
|
-
}
|
424
|
-
}
|
425
|
-
}]);
|
426
|
-
|
427
|
-
return Zoom;
|
428
|
-
}(_react.Component);
|
429
|
-
|
430
|
-
var _default = Zoom;
|
431
|
-
exports["default"] = _default;
|