react-slideshow-image 3.7.0 → 3.7.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -2
- package/dist/react-slideshow-image.min.js +1 -1
- package/dist/react-slideshow-image.min.js.map +1 -1
- package/package.json +19 -21
- 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/package.json
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-slideshow-image",
|
3
|
-
"version": "3.7.
|
3
|
+
"version": "3.7.3",
|
4
4
|
"author": "Femi Oladeji",
|
5
5
|
"description": "An image slideshow with react",
|
6
6
|
"files": [
|
7
|
-
"lib",
|
8
7
|
"dist"
|
9
8
|
],
|
10
9
|
"homepage": "https://react-slideshow-image.netlify.com",
|
@@ -40,28 +39,28 @@
|
|
40
39
|
"codecov": "^3.1.0",
|
41
40
|
"copy-webpack-plugin": "^6.0.3",
|
42
41
|
"css-loader": "^3.5.3",
|
43
|
-
"extract-text-webpack-plugin": "4.0.0-alpha.0",
|
44
42
|
"file-loader": "^6.0.0",
|
45
|
-
"html-webpack-plugin": "^
|
43
|
+
"html-webpack-plugin": "^5.5.0",
|
46
44
|
"husky": "^0.14.3",
|
47
45
|
"jest": "^26.0.1",
|
48
|
-
"lint-staged": "^
|
46
|
+
"lint-staged": "^12.3.7",
|
47
|
+
"mini-css-extract-plugin": "^2.6.0",
|
49
48
|
"prettier": "^1.14.3",
|
50
|
-
"react": "^
|
51
|
-
"react-dom": "^
|
52
|
-
"react-router": "^
|
53
|
-
"react-router-dom": "^
|
49
|
+
"react": "^18.0.0",
|
50
|
+
"react-dom": "^18.0.0",
|
51
|
+
"react-router": "^6.3.0",
|
52
|
+
"react-router-dom": "^6.3.0",
|
54
53
|
"react-syntax-highlighter": "^15.4.3",
|
55
|
-
"serve": "^
|
56
|
-
"style-loader": "^1.2.1",
|
54
|
+
"serve": "^13.0.2",
|
57
55
|
"uglifycss": "0.0.29",
|
58
|
-
"webpack": "^
|
59
|
-
"webpack-cli": "^
|
60
|
-
"webpack-dev-server": "^
|
56
|
+
"webpack": "^5.72.0",
|
57
|
+
"webpack-cli": "^4.9.2",
|
58
|
+
"webpack-dev-server": "^4.8.1",
|
59
|
+
"webpack-merge": "^5.8.0"
|
61
60
|
},
|
62
61
|
"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"
|
62
|
+
"react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0",
|
63
|
+
"react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
65
64
|
},
|
66
65
|
"lint-staged": {
|
67
66
|
"{src,__tests__,docs}/**/*.{js,jsx,json,css}": [
|
@@ -71,16 +70,15 @@
|
|
71
70
|
},
|
72
71
|
"main": "dist/react-slideshow-image.min.js",
|
73
72
|
"scripts": {
|
74
|
-
"dev": "webpack
|
75
|
-
"build": "webpack --config
|
76
|
-
"heroku-postbuild": "npm i --only=dev && webpack --prod",
|
73
|
+
"dev": "webpack serve --config=webpack.config.dev.js",
|
74
|
+
"docs-build": "webpack --config=webpack.config.prod.js && echo '/* /index.html 200' | cat >public/_redirects",
|
77
75
|
"start": "serve public -s",
|
78
76
|
"precommit": "lint-staged",
|
79
77
|
"test": "jest && codecov",
|
80
|
-
"prepublishOnly": "
|
78
|
+
"prepublishOnly": "webpack --config webpack.config.dist.js && uglifycss src/css/styles.css > dist/styles.css"
|
81
79
|
},
|
82
80
|
"dependencies": {
|
83
|
-
"@tweenjs/tween.js": "^18.
|
81
|
+
"@tweenjs/tween.js": "^18.6.4",
|
84
82
|
"resize-observer-polyfill": "^1.5.1"
|
85
83
|
}
|
86
84
|
}
|
package/lib/css/styles.css
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
.react-slideshow-container {
|
2
|
-
display: -webkit-box;
|
3
|
-
display: -ms-flexbox;
|
4
|
-
display: flex;
|
5
|
-
-webkit-box-align: center;
|
6
|
-
-ms-flex-align: center;
|
7
|
-
align-items: center;
|
8
|
-
}
|
9
|
-
|
10
|
-
.react-slideshow-container .nav {
|
11
|
-
z-index: 10;
|
12
|
-
}
|
13
|
-
|
14
|
-
.react-slideshow-container .default-nav {
|
15
|
-
height: 30px;
|
16
|
-
background: rgba(255, 255, 255, 0.6);
|
17
|
-
width: 30px;
|
18
|
-
border: none;
|
19
|
-
text-align: center;
|
20
|
-
cursor: pointer;
|
21
|
-
color: #fff;
|
22
|
-
border-radius: 50%;
|
23
|
-
display: -webkit-box;
|
24
|
-
display: -ms-flexbox;
|
25
|
-
display: flex;
|
26
|
-
-webkit-box-align: center;
|
27
|
-
-ms-flex-align: center;
|
28
|
-
align-items: center;
|
29
|
-
-webkit-box-pack: center;
|
30
|
-
-ms-flex-pack: center;
|
31
|
-
justify-content: center;
|
32
|
-
}
|
33
|
-
|
34
|
-
.react-slideshow-container .default-nav:hover,
|
35
|
-
.react-slideshow-container .default-nav:focus {
|
36
|
-
background: #fff;
|
37
|
-
color: #666;
|
38
|
-
outline: none;
|
39
|
-
}
|
40
|
-
|
41
|
-
.react-slideshow-container .default-nav.disabled:hover {
|
42
|
-
cursor: not-allowed;
|
43
|
-
}
|
44
|
-
|
45
|
-
.react-slideshow-container .default-nav:first-of-type {
|
46
|
-
margin-right: -30px;
|
47
|
-
border-right: none;
|
48
|
-
border-top: none;
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
.react-slideshow-container .default-nav:last-of-type {
|
53
|
-
margin-left: -30px;
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
.react-slideshow-container + ul.indicators {
|
58
|
-
display: -webkit-box;
|
59
|
-
display: -ms-flexbox;
|
60
|
-
display: flex;
|
61
|
-
-ms-flex-wrap: wrap;
|
62
|
-
flex-wrap: wrap;
|
63
|
-
-webkit-box-pack: center;
|
64
|
-
-ms-flex-pack: center;
|
65
|
-
justify-content: center;
|
66
|
-
margin-top: 20px;
|
67
|
-
}
|
68
|
-
|
69
|
-
.react-slideshow-container + ul.indicators li {
|
70
|
-
display: inline-block;
|
71
|
-
position: relative;
|
72
|
-
width: 7px;
|
73
|
-
height: 7px;
|
74
|
-
padding: 5px;
|
75
|
-
margin: 0;
|
76
|
-
}
|
77
|
-
|
78
|
-
.react-slideshow-container + ul.indicators .each-slideshow-indicator {
|
79
|
-
border: none;
|
80
|
-
opacity: 0.25;
|
81
|
-
cursor: pointer;
|
82
|
-
background: transparent;
|
83
|
-
color: transparent;
|
84
|
-
}
|
85
|
-
|
86
|
-
.react-slideshow-container + ul.indicators .each-slideshow-indicator:before {
|
87
|
-
position: absolute;
|
88
|
-
top: 0;
|
89
|
-
left: 0;
|
90
|
-
width: 7px;
|
91
|
-
height: 7px;
|
92
|
-
border-radius: 50%;
|
93
|
-
content: '';
|
94
|
-
background: #000;
|
95
|
-
text-align: center;
|
96
|
-
}
|
97
|
-
|
98
|
-
.react-slideshow-container + ul.indicators .each-slideshow-indicator:hover,
|
99
|
-
.react-slideshow-container + ul.indicators .each-slideshow-indicator.active,
|
100
|
-
.react-slideshow-container + ul.indicators .each-slideshow-indicator:focus {
|
101
|
-
opacity: 0.75;
|
102
|
-
outline: none;
|
103
|
-
}
|
104
|
-
|
105
|
-
.react-slideshow-fade-wrapper {
|
106
|
-
width: 100%;
|
107
|
-
overflow: hidden;
|
108
|
-
}
|
109
|
-
|
110
|
-
.react-slideshow-fade-wrapper .react-slideshow-fade-images-wrap {
|
111
|
-
display: -webkit-box;
|
112
|
-
display: -ms-flexbox;
|
113
|
-
display: flex;
|
114
|
-
-ms-flex-wrap: wrap;
|
115
|
-
flex-wrap: wrap;
|
116
|
-
}
|
117
|
-
|
118
|
-
.react-slideshow-fade-wrapper .react-slideshow-fade-images-wrap > div {
|
119
|
-
position: relative;
|
120
|
-
opacity: 0;
|
121
|
-
}
|
122
|
-
|
123
|
-
.react-slideshow-wrapper.slide {
|
124
|
-
width: 100%;
|
125
|
-
overflow: hidden;
|
126
|
-
}
|
127
|
-
|
128
|
-
.react-slideshow-wrapper .images-wrap {
|
129
|
-
display: -webkit-box;
|
130
|
-
display: -ms-flexbox;
|
131
|
-
display: flex;
|
132
|
-
-ms-flex-wrap: wrap;
|
133
|
-
flex-wrap: wrap;
|
134
|
-
}
|
135
|
-
|
136
|
-
.react-slideshow-zoom-wrapper {
|
137
|
-
width: 100%;
|
138
|
-
overflow: hidden;
|
139
|
-
}
|
140
|
-
|
141
|
-
.react-slideshow-zoom-wrapper .zoom-wrapper {
|
142
|
-
display: -webkit-box;
|
143
|
-
display: -ms-flexbox;
|
144
|
-
display: flex;
|
145
|
-
-ms-flex-wrap: wrap;
|
146
|
-
flex-wrap: wrap;
|
147
|
-
overflow: hidden;
|
148
|
-
}
|
149
|
-
|
150
|
-
.react-slideshow-zoom-wrapper .zoom-wrapper > div {
|
151
|
-
position: relative;
|
152
|
-
display: -webkit-box;
|
153
|
-
display: -ms-flexbox;
|
154
|
-
display: flex;
|
155
|
-
}
|
package/lib/fade.js
DELETED
@@ -1,420 +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 _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
|
11
|
-
|
12
|
-
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
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 Fade =
|
43
|
-
/*#__PURE__*/
|
44
|
-
function (_Component) {
|
45
|
-
_inherits(Fade, _Component);
|
46
|
-
|
47
|
-
function Fade(props) {
|
48
|
-
var _this;
|
49
|
-
|
50
|
-
_classCallCheck(this, Fade);
|
51
|
-
|
52
|
-
_this = _possibleConstructorReturn(this, _getPrototypeOf(Fade).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.preFade = _this.preFade.bind(_assertThisInitialized(_this));
|
64
|
-
_this.pauseSlides = _this.pauseSlides.bind(_assertThisInitialized(_this));
|
65
|
-
_this.startSlides = _this.startSlides.bind(_assertThisInitialized(_this));
|
66
|
-
_this.initResizeObserver = _this.initResizeObserver.bind(_assertThisInitialized(_this));
|
67
|
-
_this.tweenGroup = new _tween["default"].Group();
|
68
|
-
_this.reactSlideshowWrapper = (0, _react.createRef)();
|
69
|
-
_this.wrapper = (0, _react.createRef)();
|
70
|
-
_this.startSwipe = _this.startSwipe.bind(_assertThisInitialized(_this));
|
71
|
-
_this.endSwipe = _this.endSwipe.bind(_assertThisInitialized(_this));
|
72
|
-
return _this;
|
73
|
-
}
|
74
|
-
|
75
|
-
_createClass(Fade, [{
|
76
|
-
key: "componentDidMount",
|
77
|
-
value: function componentDidMount() {
|
78
|
-
this.setWidth();
|
79
|
-
this.play();
|
80
|
-
this.initResizeObserver();
|
81
|
-
(0, _props.validatePropTypes)(this.props);
|
82
|
-
}
|
83
|
-
}, {
|
84
|
-
key: "initResizeObserver",
|
85
|
-
value: function initResizeObserver() {
|
86
|
-
var _this2 = this;
|
87
|
-
|
88
|
-
if (this.reactSlideshowWrapper.current) {
|
89
|
-
this.resizeObserver = new _resizeObserverPolyfill["default"](function (entries) {
|
90
|
-
if (!entries) return;
|
91
|
-
|
92
|
-
_this2.handleResize();
|
93
|
-
});
|
94
|
-
this.resizeObserver.observe(this.reactSlideshowWrapper.current);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}, {
|
98
|
-
key: "play",
|
99
|
-
value: function play() {
|
100
|
-
var _this3 = this;
|
101
|
-
|
102
|
-
var _getProps = (0, _props.getProps)(this.props),
|
103
|
-
autoplay = _getProps.autoplay,
|
104
|
-
children = _getProps.children,
|
105
|
-
duration = _getProps.duration;
|
106
|
-
|
107
|
-
var index = this.state.index;
|
108
|
-
|
109
|
-
if (autoplay && children.length > 1) {
|
110
|
-
clearTimeout(this.timeout);
|
111
|
-
this.timeout = setTimeout(function () {
|
112
|
-
return _this3.fadeImages(index + 1);
|
113
|
-
}, duration);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}, {
|
117
|
-
key: "componentDidUpdate",
|
118
|
-
value: function componentDidUpdate(props) {
|
119
|
-
var _getProps2 = (0, _props.getProps)(this.props),
|
120
|
-
autoplay = _getProps2.autoplay,
|
121
|
-
children = _getProps2.children;
|
122
|
-
|
123
|
-
var newProps = (0, _props.getProps)(props);
|
124
|
-
|
125
|
-
if (autoplay !== newProps.autoplay) {
|
126
|
-
if (autoplay) {
|
127
|
-
this.play();
|
128
|
-
} else {
|
129
|
-
clearTimeout(this.timeout);
|
130
|
-
}
|
131
|
-
}
|
132
|
-
|
133
|
-
if (children.length != newProps.children.length) {
|
134
|
-
this.applyStyle();
|
135
|
-
clearTimeout(this.timeout);
|
136
|
-
this.play();
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}, {
|
140
|
-
key: "componentWillUnmount",
|
141
|
-
value: function componentWillUnmount() {
|
142
|
-
this.willUnmount = true;
|
143
|
-
clearTimeout(this.timeout);
|
144
|
-
this.removeResizeObserver();
|
145
|
-
}
|
146
|
-
}, {
|
147
|
-
key: "removeResizeObserver",
|
148
|
-
value: function removeResizeObserver() {
|
149
|
-
if (this.resizeObserver && this.reactSlideshowWrapper && this.reactSlideshowWrapper.current) {
|
150
|
-
this.resizeObserver.unobserve(this.reactSlideshowWrapper.current);
|
151
|
-
}
|
152
|
-
}
|
153
|
-
}, {
|
154
|
-
key: "setWidth",
|
155
|
-
value: function setWidth() {
|
156
|
-
if (this.wrapper.current) {
|
157
|
-
this.width = this.wrapper.current.clientWidth;
|
158
|
-
}
|
159
|
-
|
160
|
-
this.applyStyle();
|
161
|
-
}
|
162
|
-
}, {
|
163
|
-
key: "handleResize",
|
164
|
-
value: function handleResize() {
|
165
|
-
this.setWidth();
|
166
|
-
}
|
167
|
-
}, {
|
168
|
-
key: "applyStyle",
|
169
|
-
value: function applyStyle() {
|
170
|
-
var fullwidth = this.width * _react["default"].Children.count(this.props.children);
|
171
|
-
|
172
|
-
if (this.divsContainer) {
|
173
|
-
this.divsContainer.style.width = "".concat(fullwidth, "px");
|
174
|
-
|
175
|
-
for (var index = 0; index < this.divsContainer.children.length; index++) {
|
176
|
-
var eachDiv = this.divsContainer.children[index];
|
177
|
-
|
178
|
-
if (eachDiv) {
|
179
|
-
eachDiv.style.width = "".concat(this.width, "px");
|
180
|
-
eachDiv.style.left = "".concat(index * -this.width, "px");
|
181
|
-
}
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
}, {
|
186
|
-
key: "pauseSlides",
|
187
|
-
value: function pauseSlides() {
|
188
|
-
if ((0, _props.getProps)(this.props).pauseOnHover) {
|
189
|
-
clearTimeout(this.timeout);
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}, {
|
193
|
-
key: "startSlides",
|
194
|
-
value: function startSlides() {
|
195
|
-
var _this4 = this;
|
196
|
-
|
197
|
-
var _getProps3 = (0, _props.getProps)(this.props),
|
198
|
-
pauseOnHover = _getProps3.pauseOnHover,
|
199
|
-
autoplay = _getProps3.autoplay,
|
200
|
-
duration = _getProps3.duration;
|
201
|
-
|
202
|
-
if (pauseOnHover && autoplay) {
|
203
|
-
this.timeout = setTimeout(function () {
|
204
|
-
return _this4.goNext();
|
205
|
-
}, duration);
|
206
|
-
}
|
207
|
-
}
|
208
|
-
}, {
|
209
|
-
key: "goNext",
|
210
|
-
value: function goNext() {
|
211
|
-
var index = this.state.index;
|
212
|
-
|
213
|
-
var _getProps4 = (0, _props.getProps)(this.props),
|
214
|
-
children = _getProps4.children,
|
215
|
-
infinite = _getProps4.infinite;
|
216
|
-
|
217
|
-
if (!infinite && index === children.length - 1) {
|
218
|
-
return;
|
219
|
-
}
|
220
|
-
|
221
|
-
this.fadeImages((index + 1) % children.length);
|
222
|
-
}
|
223
|
-
}, {
|
224
|
-
key: "goBack",
|
225
|
-
value: function goBack() {
|
226
|
-
var index = this.state.index;
|
227
|
-
|
228
|
-
var _getProps5 = (0, _props.getProps)(this.props),
|
229
|
-
children = _getProps5.children,
|
230
|
-
infinite = _getProps5.infinite;
|
231
|
-
|
232
|
-
if (!infinite && index === 0) {
|
233
|
-
return;
|
234
|
-
}
|
235
|
-
|
236
|
-
this.fadeImages(index === 0 ? children.length - 1 : index - 1);
|
237
|
-
}
|
238
|
-
}, {
|
239
|
-
key: "navigate",
|
240
|
-
value: function navigate(_ref) {
|
241
|
-
var dataset = _ref.currentTarget.dataset;
|
242
|
-
|
243
|
-
if (dataset.key != this.state.index) {
|
244
|
-
this.goTo(parseInt(dataset.key));
|
245
|
-
}
|
246
|
-
}
|
247
|
-
}, {
|
248
|
-
key: "goTo",
|
249
|
-
value: function goTo(index) {
|
250
|
-
this.fadeImages(index);
|
251
|
-
}
|
252
|
-
}, {
|
253
|
-
key: "preFade",
|
254
|
-
value: function preFade(_ref2) {
|
255
|
-
var currentTarget = _ref2.currentTarget;
|
256
|
-
|
257
|
-
if (currentTarget.dataset.type === 'prev') {
|
258
|
-
this.goBack();
|
259
|
-
} else {
|
260
|
-
this.goNext();
|
261
|
-
}
|
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
|
-
}
|
296
|
-
}, {
|
297
|
-
key: "render",
|
298
|
-
value: function render() {
|
299
|
-
var _this5 = this;
|
300
|
-
|
301
|
-
var _getProps8 = (0, _props.getProps)(this.props),
|
302
|
-
indicators = _getProps8.indicators,
|
303
|
-
children = _getProps8.children,
|
304
|
-
arrows = _getProps8.arrows,
|
305
|
-
cssClass = _getProps8.cssClass;
|
306
|
-
|
307
|
-
var index = this.state.index;
|
308
|
-
var unhandledProps = (0, _helpers.getUnhandledProps)(_props.propTypes, this.props);
|
309
|
-
return _react["default"].createElement("div", _extends({
|
310
|
-
dir: "ltr",
|
311
|
-
"aria-roledescription": "carousel"
|
312
|
-
}, unhandledProps), _react["default"].createElement("div", {
|
313
|
-
className: "react-slideshow-container",
|
314
|
-
onMouseEnter: this.pauseSlides,
|
315
|
-
onMouseOver: this.pauseSlides,
|
316
|
-
onMouseLeave: this.startSlides,
|
317
|
-
onMouseDown: this.startSwipe,
|
318
|
-
onMouseUp: this.endSwipe,
|
319
|
-
onTouchStart: this.startSwipe,
|
320
|
-
onTouchEnd: this.endSwipe,
|
321
|
-
onTouchCancel: this.endSwipe,
|
322
|
-
ref: this.reactSlideshowWrapper
|
323
|
-
}, arrows && (0, _helpers.showPreviousArrow)((0, _props.getProps)(this.props), this.state.index, this.preFade), _react["default"].createElement("div", {
|
324
|
-
className: "react-slideshow-fade-wrapper ".concat(cssClass),
|
325
|
-
ref: this.wrapper
|
326
|
-
}, _react["default"].createElement("div", {
|
327
|
-
className: "react-slideshow-fade-images-wrap",
|
328
|
-
ref: function ref(wrap) {
|
329
|
-
return _this5.divsContainer = wrap;
|
330
|
-
}
|
331
|
-
}, children.map(function (each, key) {
|
332
|
-
return _react["default"].createElement("div", {
|
333
|
-
style: {
|
334
|
-
opacity: key === index ? '1' : '0',
|
335
|
-
zIndex: key === index ? '1' : '0'
|
336
|
-
},
|
337
|
-
"data-index": key,
|
338
|
-
key: key,
|
339
|
-
"aria-roledescription": "slide",
|
340
|
-
"aria-hidden": key === index ? 'false' : 'true'
|
341
|
-
}, each);
|
342
|
-
}))), arrows && (0, _helpers.showNextArrow)((0, _props.getProps)(this.props), this.state.index, this.preFade)), indicators && (0, _helpers.showIndicators)((0, _props.getProps)(this.props), this.state.index, this.navigate));
|
343
|
-
}
|
344
|
-
}, {
|
345
|
-
key: "fadeImages",
|
346
|
-
value: function fadeImages(newIndex) {
|
347
|
-
var _this6 = this;
|
348
|
-
|
349
|
-
var index = this.state.index;
|
350
|
-
|
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;
|
359
|
-
|
360
|
-
var existingTweens = this.tweenGroup.getAll();
|
361
|
-
|
362
|
-
if (!existingTweens.length) {
|
363
|
-
if (!this.divsContainer.children[newIndex]) {
|
364
|
-
newIndex = 0;
|
365
|
-
}
|
366
|
-
|
367
|
-
clearTimeout(this.timeout);
|
368
|
-
var value = {
|
369
|
-
opacity: 0
|
370
|
-
};
|
371
|
-
|
372
|
-
var animate = function animate() {
|
373
|
-
if (_this6.willUnmount) {
|
374
|
-
_this6.tweenGroup.removeAll();
|
375
|
-
|
376
|
-
return;
|
377
|
-
}
|
378
|
-
|
379
|
-
requestAnimationFrame(animate);
|
380
|
-
|
381
|
-
_this6.tweenGroup.update();
|
382
|
-
};
|
383
|
-
|
384
|
-
animate();
|
385
|
-
var tween = new _tween["default"].Tween(value, this.tweenGroup).to({
|
386
|
-
opacity: 1
|
387
|
-
}, transitionDuration).onUpdate(function (value) {
|
388
|
-
_this6.divsContainer.children[newIndex].style.opacity = value.opacity;
|
389
|
-
_this6.divsContainer.children[index].style.opacity = 1 - value.opacity;
|
390
|
-
}).start();
|
391
|
-
tween.easing((0, _helpers.getEasing)(easing));
|
392
|
-
tween.onComplete(function () {
|
393
|
-
if (_this6.willUnmount) {
|
394
|
-
return;
|
395
|
-
}
|
396
|
-
|
397
|
-
_this6.setState({
|
398
|
-
index: newIndex
|
399
|
-
});
|
400
|
-
|
401
|
-
if (typeof onChange === 'function') {
|
402
|
-
onChange(index, newIndex);
|
403
|
-
}
|
404
|
-
|
405
|
-
if (autoplay && (infinite || newIndex < children.length - 1)) {
|
406
|
-
clearTimeout(_this6.timeout);
|
407
|
-
_this6.timeout = setTimeout(function () {
|
408
|
-
_this6.fadeImages((newIndex + 1) % children.length);
|
409
|
-
}, duration);
|
410
|
-
}
|
411
|
-
});
|
412
|
-
}
|
413
|
-
}
|
414
|
-
}]);
|
415
|
-
|
416
|
-
return Fade;
|
417
|
-
}(_react.Component);
|
418
|
-
|
419
|
-
var _default = Fade;
|
420
|
-
exports["default"] = _default;
|