@ndla/ui 3.3.7 → 3.3.8
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/es/Breadcrumb/Breadcrumb.js +2 -1
- package/es/NDLAFilm/FilmSlideshow.js +213 -247
- package/es/NDLAFilm/NavigationArrow.js +13 -60
- package/es/NDLAFilm/SlideshowIndicator.js +16 -63
- package/es/NDLAFilm/interfaces.js +0 -0
- package/es/NDLAFilm/shapes.js +0 -10
- package/es/Spinner/Spinner.js +3 -3
- package/lib/Breadcrumb/Breadcrumb.js +2 -1
- package/lib/NDLAFilm/FilmSlideshow.d.ts +16 -0
- package/lib/NDLAFilm/FilmSlideshow.js +214 -248
- package/lib/NDLAFilm/NavigationArrow.d.ts +15 -0
- package/lib/NDLAFilm/NavigationArrow.js +20 -65
- package/lib/NDLAFilm/SlideshowIndicator.d.ts +15 -0
- package/lib/NDLAFilm/SlideshowIndicator.js +16 -69
- package/lib/NDLAFilm/interfaces.d.ts +10 -0
- package/lib/NDLAFilm/interfaces.js +1 -0
- package/lib/NDLAFilm/shapes.d.ts +5 -0
- package/lib/NDLAFilm/shapes.js +1 -14
- package/lib/Spinner/Spinner.d.ts +3 -3
- package/lib/Spinner/Spinner.js +2 -2
- package/package.json +4 -4
- package/src/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/NDLAFilm/FilmSlideshow.tsx +264 -0
- package/src/NDLAFilm/NavigationArrow.tsx +42 -0
- package/src/NDLAFilm/SlideshowIndicator.tsx +40 -0
- package/src/NDLAFilm/interfaces.ts +10 -0
- package/src/NDLAFilm/shapes.ts +6 -0
- package/src/Spinner/Spinner.tsx +9 -5
- package/src/NDLAFilm/FilmSlideshow.jsx +0 -277
- package/src/NDLAFilm/NavigationArrow.jsx +0 -46
- package/src/NDLAFilm/SlideshowIndicator.jsx +0 -43
- package/src/NDLAFilm/shapes.js +0 -17
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
12
|
|
|
23
13
|
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); }
|
|
24
14
|
|
|
@@ -29,14 +19,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
29
19
|
* LICENSE file in the root directory of this source tree.
|
|
30
20
|
*
|
|
31
21
|
*/
|
|
32
|
-
import React, {
|
|
33
|
-
import
|
|
34
|
-
import { Swipeable } from 'react-swipeable';
|
|
22
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
23
|
+
import { useSwipeable } from 'react-swipeable';
|
|
35
24
|
import BEMHelper from 'react-bem-helper';
|
|
36
|
-
import { OneColumn } from '@ndla/ui';
|
|
37
25
|
import SafeLink from '@ndla/safelink';
|
|
26
|
+
import { OneColumn } from '../Layout';
|
|
38
27
|
import Spinner from '../Spinner';
|
|
39
|
-
import { movieShape } from './shapes';
|
|
40
28
|
import NavigationArrow from './NavigationArrow';
|
|
41
29
|
import SlideshowIndicator from './SlideshowIndicator';
|
|
42
30
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
@@ -58,253 +46,231 @@ var renderSlideItem = function renderSlideItem(slide) {
|
|
|
58
46
|
}));
|
|
59
47
|
};
|
|
60
48
|
|
|
61
|
-
var FilmSlideshow =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
49
|
+
var FilmSlideshow = function FilmSlideshow(_ref) {
|
|
50
|
+
var _ref$autoSlide = _ref.autoSlide,
|
|
51
|
+
autoSlide = _ref$autoSlide === void 0 ? false : _ref$autoSlide,
|
|
52
|
+
_ref$slideshow = _ref.slideshow,
|
|
53
|
+
slideshow = _ref$slideshow === void 0 ? [] : _ref$slideshow,
|
|
54
|
+
_ref$slideInterval = _ref.slideInterval,
|
|
55
|
+
slideInterval = _ref$slideInterval === void 0 ? 5000 : _ref$slideInterval;
|
|
56
|
+
|
|
57
|
+
var _useState = useState(0),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
swipeDistance = _useState2[0],
|
|
60
|
+
setSwipeDistance = _useState2[1];
|
|
61
|
+
|
|
62
|
+
var _useState3 = useState(0),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
slideIndex = _useState4[0],
|
|
65
|
+
setSlideIndex = _useState4[1];
|
|
66
|
+
|
|
67
|
+
var _useState5 = useState(0),
|
|
68
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
69
|
+
slideIndexTarget = _useState6[0],
|
|
70
|
+
setSlideIndexTarget = _useState6[1];
|
|
71
|
+
|
|
72
|
+
var _useState7 = useState(true),
|
|
73
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
74
|
+
animationComplete = _useState8[0],
|
|
75
|
+
setAnimationComplete = _useState8[1];
|
|
76
|
+
|
|
77
|
+
var slideRef = useRef(null);
|
|
78
|
+
var slideText = useRef(null);
|
|
79
|
+
var timer = useRef(null);
|
|
80
|
+
var gotoSlide = useCallback(function (indexTarget) {
|
|
81
|
+
var useAnimation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
82
|
+
setSwipeDistance(0);
|
|
83
|
+
|
|
84
|
+
if (timer.current) {
|
|
85
|
+
clearTimeout(timer.current);
|
|
95
86
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
|
|
88
|
+
setSlideIndexTarget(indexTarget);
|
|
89
|
+
setAnimationComplete(!useAnimation);
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
var onChangedSlide = function onChangedSlide() {
|
|
93
|
+
if (!animationComplete) {
|
|
94
|
+
if (slideRef.current) {
|
|
95
|
+
slideRef.current.style.transition = 'none';
|
|
96
|
+
slideRef.current.style.transform = "translateX(".concat(slideIndexTarget * 100, "vw))");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setAnimationComplete(true);
|
|
100
|
+
setSlideIndex(slideIndexTarget);
|
|
101
|
+
} else if (slideIndexTarget === -1) {
|
|
102
|
+
if (slideRef.current) {
|
|
109
103
|
// Go to last slide for continuous loop
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
104
|
+
slideRef.current.style.transition = 'none';
|
|
105
|
+
slideRef.current.style.transform = "translateX(".concat(slideshow.length * 100, "vw))");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setSlideIndex(slideshow.length - 1);
|
|
109
|
+
setSlideIndexTarget(slideshow.length - 1);
|
|
110
|
+
setAnimationComplete(true);
|
|
111
|
+
} else if (slideIndexTarget === slideshow.length) {
|
|
112
|
+
if (slideRef.current) {
|
|
118
113
|
// Go to first slide for continuous loop
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.setState({
|
|
122
|
-
slideIndex: 0,
|
|
123
|
-
slideIndexTarget: 0,
|
|
124
|
-
animationComplete: true
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
this.setState(function (prevState) {
|
|
128
|
-
return {
|
|
129
|
-
animationComplete: true,
|
|
130
|
-
slideIndex: prevState.slideIndexTarget
|
|
131
|
-
};
|
|
132
|
-
});
|
|
114
|
+
slideRef.current.style.transition = 'none';
|
|
115
|
+
slideRef.current.style.transform = "translateX(100vw))";
|
|
133
116
|
}
|
|
117
|
+
|
|
118
|
+
setSlideIndex(0);
|
|
119
|
+
setSlideIndexTarget(0);
|
|
120
|
+
setAnimationComplete(true);
|
|
121
|
+
} else {
|
|
122
|
+
setAnimationComplete(true);
|
|
123
|
+
setSlideIndex(slideIndexTarget);
|
|
134
124
|
}
|
|
135
|
-
}
|
|
136
|
-
key: "onSwipeEnd",
|
|
137
|
-
value: function onSwipeEnd() {
|
|
138
|
-
var slide;
|
|
139
|
-
|
|
140
|
-
if (this.swipeDistance > 40) {
|
|
141
|
-
slide = -1;
|
|
142
|
-
} else if (this.swipeDistance < -40) {
|
|
143
|
-
slide = 1;
|
|
144
|
-
} else {
|
|
145
|
-
slide = 0;
|
|
146
|
-
}
|
|
125
|
+
};
|
|
147
126
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
slideIndex: prevState.slideIndex + slide,
|
|
158
|
-
slideIndexTarget: prevState.slideIndex + slide
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
// Reset transfrom
|
|
163
|
-
this.slideRef.current.style.transform = this.getSlidePosition(this.state.slideIndex + slide);
|
|
164
|
-
}
|
|
127
|
+
var onSwipeEnd = function onSwipeEnd() {
|
|
128
|
+
var slide;
|
|
129
|
+
|
|
130
|
+
if (swipeDistance > 40) {
|
|
131
|
+
slide = -1;
|
|
132
|
+
} else if (swipeDistance < -40) {
|
|
133
|
+
slide = 1;
|
|
134
|
+
} else {
|
|
135
|
+
slide = 0;
|
|
165
136
|
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "onSwipe",
|
|
168
|
-
value: function onSwipe(eventData) {
|
|
169
|
-
if (eventData.dir === 'Up' || eventData.dir === 'Down') {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
137
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var opacityText = 1 - Math.min(100, Math.abs(this.swipeDistance)) / 100;
|
|
178
|
-
this.slideText.current.style.transition = 'none';
|
|
179
|
-
this.slideText.current.style.opacity = opacityText;
|
|
138
|
+
if (slideRef.current && slideText.current) {
|
|
139
|
+
slideRef.current.style.transition = defaultTransitionSwipeEnd;
|
|
140
|
+
slideText.current.style.transition = defaultTransitionText;
|
|
141
|
+
slideText.current.style.opacity = '1';
|
|
180
142
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
} else if (this.state.slideIndex >= slideshowLength) {
|
|
194
|
-
this.slideRef.current.style.transition = 'none';
|
|
195
|
-
this.slideRef.current.style.transform = this.getSlidePosition(0);
|
|
196
|
-
this.setState({
|
|
197
|
-
slideIndex: 0,
|
|
198
|
-
slideIndexTarget: 0
|
|
199
|
-
});
|
|
143
|
+
|
|
144
|
+
setSwipeDistance(0);
|
|
145
|
+
initTimer();
|
|
146
|
+
|
|
147
|
+
if (slide !== 0) {
|
|
148
|
+
setSlideIndex(slideIndex + slide);
|
|
149
|
+
setSlideIndexTarget(slideIndex + slide);
|
|
150
|
+
} else {
|
|
151
|
+
// Reset transfrom
|
|
152
|
+
if (slideRef.current) {
|
|
153
|
+
slideRef.current.style.transform = getSlidePosition(slideIndex + slide);
|
|
200
154
|
}
|
|
201
155
|
}
|
|
202
|
-
}
|
|
203
|
-
key: "getSlidePosition",
|
|
204
|
-
value: function getSlidePosition(target) {
|
|
205
|
-
if (this.swipeDistance !== 0) {
|
|
206
|
-
return "translateX(calc(".concat(this.swipeDistance, "px -\n ").concat((target + 1) * 100, "vw))");
|
|
207
|
-
}
|
|
156
|
+
};
|
|
208
157
|
|
|
209
|
-
|
|
158
|
+
var onSwipe = function onSwipe(eventData) {
|
|
159
|
+
if (eventData.dir === 'Up' || eventData.dir === 'Down') {
|
|
160
|
+
return;
|
|
210
161
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this.swipeDistance = 0;
|
|
215
|
-
clearTimeout(this.timer);
|
|
216
|
-
this.initTimer();
|
|
217
|
-
this.setState({
|
|
218
|
-
slideIndexTarget: slideIndexTarget,
|
|
219
|
-
animationComplete: !useAnimation
|
|
220
|
-
});
|
|
162
|
+
|
|
163
|
+
if (timer.current) {
|
|
164
|
+
clearTimeout(timer.current);
|
|
221
165
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.timer = setTimeout(function () {
|
|
229
|
-
_this2.gotoSlide(_this2.state.slideIndex + 1);
|
|
230
|
-
}, this.props.slideInterval);
|
|
231
|
-
}
|
|
166
|
+
|
|
167
|
+
setSwipeDistance(eventData.deltaX);
|
|
168
|
+
|
|
169
|
+
if (slideRef && slideRef.current) {
|
|
170
|
+
slideRef.current.style.transition = 'none';
|
|
171
|
+
slideRef.current.style.transform = getSlidePosition(slideIndexTarget);
|
|
232
172
|
}
|
|
233
|
-
}, {
|
|
234
|
-
key: "render",
|
|
235
|
-
value: function render() {
|
|
236
|
-
var slideshow = this.props.slideshow;
|
|
237
|
-
var _this$state = this.state,
|
|
238
|
-
slideIndex = _this$state.slideIndex,
|
|
239
|
-
slideIndexTarget = _this$state.slideIndexTarget,
|
|
240
|
-
animationComplete = _this$state.animationComplete;
|
|
241
|
-
|
|
242
|
-
if (slideshow.length === 0) {
|
|
243
|
-
return ___EmotionJSX("div", null, ___EmotionJSX("div", classes('slideshow'), ___EmotionJSX(Spinner, {
|
|
244
|
-
inverted: true
|
|
245
|
-
})));
|
|
246
|
-
}
|
|
247
173
|
|
|
248
|
-
|
|
249
|
-
|
|
174
|
+
var opacityText = 1 - Math.min(100, Math.abs(swipeDistance)) / 100;
|
|
175
|
+
|
|
176
|
+
if (slideText && slideText.current) {
|
|
177
|
+
slideText.current.style.transition = 'none';
|
|
178
|
+
slideText.current.style.opacity = opacityText.toString();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
var onTransitionEnd = function onTransitionEnd() {
|
|
183
|
+
var slideshowLength = slideshow.length;
|
|
250
184
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
185
|
+
if (slideIndex === -1) {
|
|
186
|
+
if (slideRef.current) {
|
|
187
|
+
slideRef.current.style.transition = 'none';
|
|
188
|
+
slideRef.current.style.transform = getSlidePosition(slideshowLength - 1);
|
|
255
189
|
}
|
|
256
190
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}), !animationComplete && ___EmotionJSX("div", _extends({}, classes('item', 'fade-over'), {
|
|
274
|
-
role: "img",
|
|
275
|
-
onAnimationEnd: this.onChangedSlide,
|
|
276
|
-
style: {
|
|
277
|
-
backgroundImage: "url(".concat(slideshow[activeSlide].metaImage && slideshow[activeSlide].metaImage.url || '', ")")
|
|
278
|
-
}
|
|
279
|
-
})), ___EmotionJSX("div", _extends({
|
|
280
|
-
ref: this.slideRef
|
|
281
|
-
}, classes('item-wrapper'), {
|
|
282
|
-
onTransitionEnd: this.onTransitionEnd,
|
|
283
|
-
style: {
|
|
284
|
-
width: slideshowWidth,
|
|
285
|
-
transform: this.getSlidePosition(slideIndex)
|
|
286
|
-
}
|
|
287
|
-
}), renderSlideItem(slideshow[slideshow.length - 1], -1), slideshow.map(renderSlideItem), renderSlideItem(slideshow[0], slideshow.length))), ___EmotionJSX(SlideshowIndicator, {
|
|
288
|
-
slideshow: slideshow,
|
|
289
|
-
activeSlide: activeSlide,
|
|
290
|
-
gotoSlide: this.gotoSlide
|
|
291
|
-
}));
|
|
191
|
+
setSlideIndex(slideshowLength - 1);
|
|
192
|
+
setSlideIndexTarget(slideshowLength - 1);
|
|
193
|
+
} else if (slideIndex >= slideshowLength) {
|
|
194
|
+
if (slideRef.current) {
|
|
195
|
+
slideRef.current.style.transition = 'none';
|
|
196
|
+
slideRef.current.style.transform = getSlidePosition(0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
setSlideIndex(0);
|
|
200
|
+
setSlideIndexTarget(0);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
var getSlidePosition = function getSlidePosition(target) {
|
|
205
|
+
if (swipeDistance !== 0) {
|
|
206
|
+
return "translateX(calc(".concat(swipeDistance, "px -\n ").concat((target + 1) * 100, "vw))");
|
|
292
207
|
}
|
|
293
|
-
}]);
|
|
294
208
|
|
|
295
|
-
|
|
296
|
-
}
|
|
209
|
+
return "translateX(-".concat((target + 1) * 100, "vw)");
|
|
210
|
+
};
|
|
297
211
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
212
|
+
var initTimer = useCallback(function () {
|
|
213
|
+
if (autoSlide) {
|
|
214
|
+
timer.current = setTimeout(function () {
|
|
215
|
+
gotoSlide(slideIndex + 1);
|
|
216
|
+
}, slideInterval);
|
|
217
|
+
}
|
|
218
|
+
}, [autoSlide, gotoSlide, slideInterval, slideIndex]);
|
|
219
|
+
useEffect(function () {
|
|
220
|
+
initTimer();
|
|
221
|
+
}, [initTimer]);
|
|
222
|
+
var handlers = useSwipeable({
|
|
223
|
+
onSwiped: onSwipeEnd,
|
|
224
|
+
onSwiping: onSwipe
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (slideshow.length === 0) {
|
|
228
|
+
return ___EmotionJSX("div", null, ___EmotionJSX("div", classes('slideshow'), ___EmotionJSX(Spinner, {
|
|
229
|
+
inverted: true
|
|
230
|
+
})));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
var slideshowWidth = "".concat((slideshow.length + 2) * 100, "vw");
|
|
234
|
+
var activeSlide = slideIndex;
|
|
235
|
+
|
|
236
|
+
if (activeSlide < 0) {
|
|
237
|
+
activeSlide = slideshow.length - 1;
|
|
238
|
+
} else if (activeSlide >= slideshow.length) {
|
|
239
|
+
activeSlide = 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return ___EmotionJSX("section", _extends({}, classes(''), handlers), ___EmotionJSX(React.Fragment, null, ___EmotionJSX("div", classes('slide-link-wrapper'), ___EmotionJSX(OneColumn, null, ___EmotionJSX(SafeLink, _extends({
|
|
243
|
+
to: slideshow[activeSlide].path
|
|
244
|
+
}, classes('item-wrapper', 'text', {
|
|
245
|
+
out: !animationComplete
|
|
246
|
+
})), ___EmotionJSX("div", _extends({}, classes('slide-info'), {
|
|
247
|
+
ref: slideText
|
|
248
|
+
}), ___EmotionJSX("h1", null, slideshow[activeSlide].title), ___EmotionJSX("p", null, slideshow[activeSlide].metaDescription))))), ___EmotionJSX(NavigationArrow, {
|
|
249
|
+
slideIndexTarget: slideIndexTarget > 0 ? slideIndexTarget - 1 : slideshow.length - 1,
|
|
250
|
+
gotoSlide: gotoSlide
|
|
251
|
+
}), ___EmotionJSX(NavigationArrow, {
|
|
252
|
+
slideIndexTarget: slideIndexTarget < slideshow.length - 1 ? slideIndexTarget + 1 : 0,
|
|
253
|
+
gotoSlide: gotoSlide,
|
|
254
|
+
rightArrow: true
|
|
255
|
+
}), !animationComplete && ___EmotionJSX("div", _extends({}, classes('item', 'fade-over'), {
|
|
256
|
+
role: "img",
|
|
257
|
+
onAnimationEnd: onChangedSlide,
|
|
258
|
+
style: {
|
|
259
|
+
backgroundImage: "url(".concat(slideshow[activeSlide].metaImage && slideshow[activeSlide].metaImage.url || '', ")")
|
|
260
|
+
}
|
|
261
|
+
})), ___EmotionJSX("div", _extends({
|
|
262
|
+
ref: slideRef
|
|
263
|
+
}, classes('item-wrapper'), {
|
|
264
|
+
onTransitionEnd: onTransitionEnd,
|
|
265
|
+
style: {
|
|
266
|
+
width: slideshowWidth,
|
|
267
|
+
transform: getSlidePosition(slideIndex)
|
|
268
|
+
}
|
|
269
|
+
}), renderSlideItem(slideshow[slideshow.length - 1]), slideshow.map(renderSlideItem), renderSlideItem(slideshow[0])), ___EmotionJSX(SlideshowIndicator, {
|
|
270
|
+
slideshow: slideshow,
|
|
271
|
+
activeSlide: activeSlide,
|
|
272
|
+
gotoSlide: gotoSlide
|
|
273
|
+
})));
|
|
309
274
|
};
|
|
275
|
+
|
|
310
276
|
export default FilmSlideshow;
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; 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); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
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); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
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); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
1
|
/**
|
|
24
2
|
* Copyright (c) 2016-present, NDLA.
|
|
25
3
|
*
|
|
@@ -27,8 +5,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
27
5
|
* LICENSE file in the root directory of this source tree.
|
|
28
6
|
*
|
|
29
7
|
*/
|
|
30
|
-
import React
|
|
31
|
-
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
32
9
|
import BEMHelper from 'react-bem-helper';
|
|
33
10
|
import { ChevronRight, ChevronLeft } from '@ndla/icons/common';
|
|
34
11
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
@@ -37,42 +14,18 @@ var classes = new BEMHelper({
|
|
|
37
14
|
prefix: 'c-'
|
|
38
15
|
});
|
|
39
16
|
|
|
40
|
-
var NavigationArrow =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_createClass(NavigationArrow, [{
|
|
52
|
-
key: "render",
|
|
53
|
-
value: function render() {
|
|
54
|
-
var _this$props = this.props,
|
|
55
|
-
slideIndexTarget = _this$props.slideIndexTarget,
|
|
56
|
-
gotoSlide = _this$props.gotoSlide,
|
|
57
|
-
rightArrow = _this$props.rightArrow;
|
|
58
|
-
var Chevron = rightArrow ? ChevronRight : ChevronLeft;
|
|
59
|
-
return ___EmotionJSX("div", classes('navigation-arrows', rightArrow ? 'right' : ''), ___EmotionJSX("button", {
|
|
60
|
-
type: "button",
|
|
61
|
-
tabIndex: -1,
|
|
62
|
-
onClick: function onClick() {
|
|
63
|
-
gotoSlide(slideIndexTarget, true);
|
|
64
|
-
}
|
|
65
|
-
}, ___EmotionJSX(Chevron, null)));
|
|
17
|
+
var NavigationArrow = function NavigationArrow(_ref) {
|
|
18
|
+
var slideIndexTarget = _ref.slideIndexTarget,
|
|
19
|
+
gotoSlide = _ref.gotoSlide,
|
|
20
|
+
rightArrow = _ref.rightArrow;
|
|
21
|
+
var Chevron = rightArrow ? ChevronRight : ChevronLeft;
|
|
22
|
+
return ___EmotionJSX("div", classes('navigation-arrows', rightArrow ? 'right' : ''), ___EmotionJSX("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
gotoSlide(slideIndexTarget, true);
|
|
66
27
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return NavigationArrow;
|
|
70
|
-
}(Component);
|
|
71
|
-
|
|
72
|
-
NavigationArrow.propTypes = {
|
|
73
|
-
slideIndexTarget: PropTypes.number,
|
|
74
|
-
slideshowLength: PropTypes.number,
|
|
75
|
-
gotoSlide: PropTypes.func,
|
|
76
|
-
rightArrow: PropTypes.bool
|
|
28
|
+
}, ___EmotionJSX(Chevron, null)));
|
|
77
29
|
};
|
|
30
|
+
|
|
78
31
|
export default NavigationArrow;
|