@micromag/viewer 0.3.317 → 0.3.318
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/assets/css/styles.css +18 -18
- package/es/index.js +597 -823
- package/lib/index.js +597 -823
- package/package.json +12 -12
package/es/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import ShareOptions from '@micromag/element-share-options';
|
|
|
29
29
|
import { useGesture } from '@use-gesture/react';
|
|
30
30
|
import WebView from '@micromag/element-webview';
|
|
31
31
|
|
|
32
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
32
33
|
var routes = PropTypes.shape({
|
|
33
34
|
home: PropTypes.string.isRequired,
|
|
34
35
|
screen: PropTypes.string.isRequired
|
|
@@ -36,11 +37,9 @@ var routes = PropTypes.shape({
|
|
|
36
37
|
|
|
37
38
|
function useKeyboardShortcuts() {
|
|
38
39
|
var shortcuts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
39
|
-
|
|
40
40
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
_ref$disabled = _ref.disabled,
|
|
42
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
44
43
|
useEffect(function () {
|
|
45
44
|
var onKey = function onKey(e) {
|
|
46
45
|
if (['input', 'textarea'].reduce(function (foundMatch, match) {
|
|
@@ -48,19 +47,15 @@ function useKeyboardShortcuts() {
|
|
|
48
47
|
}, false)) {
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
var key = e.key;
|
|
53
51
|
var lowercaseKey = key.toLowerCase();
|
|
54
|
-
|
|
55
52
|
if (typeof shortcuts[lowercaseKey] !== 'undefined') {
|
|
56
53
|
shortcuts[lowercaseKey]();
|
|
57
54
|
}
|
|
58
55
|
};
|
|
59
|
-
|
|
60
56
|
if (!disabled) {
|
|
61
57
|
window.addEventListener('keydown', onKey);
|
|
62
58
|
}
|
|
63
|
-
|
|
64
59
|
return function () {
|
|
65
60
|
if (!disabled) {
|
|
66
61
|
window.removeEventListener('keydown', onKey);
|
|
@@ -72,23 +67,22 @@ function useKeyboardShortcuts() {
|
|
|
72
67
|
function checkClickable(el) {
|
|
73
68
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
74
69
|
var parentDistance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
75
|
-
|
|
76
70
|
var _ref = options || {},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
_ref$maxParentDistanc = _ref.maxParentDistance,
|
|
72
|
+
maxParentDistance = _ref$maxParentDistanc === void 0 ? 5 : _ref$maxParentDistanc,
|
|
73
|
+
_ref$tags = _ref.tags,
|
|
74
|
+
tags = _ref$tags === void 0 ? ['BUTTON', 'A', 'INPUT', 'TEXTAREA'] : _ref$tags;
|
|
82
75
|
var _ref2 = el || {},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
_ref2$tagName = _ref2.tagName,
|
|
77
|
+
tagName = _ref2$tagName === void 0 ? null : _ref2$tagName,
|
|
78
|
+
_ref2$parentNode = _ref2.parentNode,
|
|
79
|
+
parentNode = _ref2$parentNode === void 0 ? null : _ref2$parentNode;
|
|
80
|
+
_ref2.dataset;
|
|
89
81
|
if (tagName === 'BODY') {
|
|
90
82
|
return false;
|
|
91
|
-
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Check if video is suspended
|
|
92
86
|
// if (
|
|
93
87
|
// tagName === 'VIDEO' &&
|
|
94
88
|
// typeof dataset.isSuspended !== 'undefined' &&
|
|
@@ -97,54 +91,47 @@ function checkClickable(el) {
|
|
|
97
91
|
// return true;
|
|
98
92
|
// }
|
|
99
93
|
|
|
100
|
-
|
|
101
94
|
if (tags.map(function (it) {
|
|
102
95
|
return it.toLowerCase();
|
|
103
96
|
}).indexOf(tagName.toLowerCase()) !== -1) {
|
|
104
97
|
return true;
|
|
105
98
|
}
|
|
106
|
-
|
|
107
99
|
if (parentDistance < maxParentDistance) {
|
|
108
100
|
return checkClickable(parentNode, options, parentDistance + 1);
|
|
109
101
|
}
|
|
110
|
-
|
|
111
102
|
return false;
|
|
112
103
|
}
|
|
113
104
|
|
|
114
105
|
function useScreenInteraction() {
|
|
115
106
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
107
|
+
screens = _ref.screens,
|
|
108
|
+
screenIndex = _ref.screenIndex,
|
|
109
|
+
screenWidth = _ref.screenWidth,
|
|
110
|
+
_ref$disableCurrentSc = _ref.disableCurrentScreenNavigation,
|
|
111
|
+
disableCurrentScreenNavigation = _ref$disableCurrentSc === void 0 ? false : _ref$disableCurrentSc,
|
|
112
|
+
_ref$clickOnSiblings = _ref.clickOnSiblings,
|
|
113
|
+
clickOnSiblings = _ref$clickOnSiblings === void 0 ? false : _ref$clickOnSiblings,
|
|
114
|
+
_ref$nextScreenWidthP = _ref.nextScreenWidthPercent,
|
|
115
|
+
nextScreenWidthPercent = _ref$nextScreenWidthP === void 0 ? 0.5 : _ref$nextScreenWidthP,
|
|
116
|
+
_ref$onInteract = _ref.onInteract,
|
|
117
|
+
onInteract = _ref$onInteract === void 0 ? null : _ref$onInteract,
|
|
118
|
+
_ref$onNavigate = _ref.onNavigate,
|
|
119
|
+
onNavigate = _ref$onNavigate === void 0 ? null : _ref$onNavigate;
|
|
130
120
|
var _useState = useState(screens.reduce(function (map, _ref2) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
var id = _ref2.id;
|
|
122
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, true));
|
|
123
|
+
}, {})),
|
|
124
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
125
|
+
screensInteractionEnabled = _useState2[0],
|
|
126
|
+
setScreensInteractionEnabled = _useState2[1];
|
|
138
127
|
var _ref3 = screens[screenIndex] || {},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
_ref3$id = _ref3.id,
|
|
129
|
+
screenId = _ref3$id === void 0 ? screenIndex : _ref3$id;
|
|
142
130
|
var _screensInteractionEn = screensInteractionEnabled[screenId],
|
|
143
|
-
|
|
131
|
+
currentScreenInteractionEnabled = _screensInteractionEn === void 0 ? true : _screensInteractionEn;
|
|
144
132
|
var updateInteraction = useCallback(function (newValue) {
|
|
145
133
|
var _screensInteractionEn2 = screensInteractionEnabled[screenId],
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
currentValue = _screensInteractionEn2 === void 0 ? true : _screensInteractionEn2;
|
|
148
135
|
if (currentValue !== newValue) {
|
|
149
136
|
setScreensInteractionEnabled(screens.reduce(function (map, _ref4) {
|
|
150
137
|
var id = _ref4.id;
|
|
@@ -160,12 +147,11 @@ function useScreenInteraction() {
|
|
|
160
147
|
}, [updateInteraction]);
|
|
161
148
|
var interact = useCallback(function (_ref5) {
|
|
162
149
|
var event = _ref5.event,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
target = _ref5.target,
|
|
151
|
+
currentTarget = _ref5.currentTarget,
|
|
152
|
+
x = _ref5.x,
|
|
153
|
+
y = _ref5.y,
|
|
154
|
+
index = _ref5.index;
|
|
169
155
|
if (onInteract !== null) {
|
|
170
156
|
onInteract({
|
|
171
157
|
event: event,
|
|
@@ -176,30 +162,24 @@ function useScreenInteraction() {
|
|
|
176
162
|
y: y
|
|
177
163
|
});
|
|
178
164
|
}
|
|
179
|
-
|
|
180
165
|
var screensCount = screens.length;
|
|
181
166
|
var tappedCurrent = screenIndex === index;
|
|
182
|
-
|
|
183
167
|
if (disableCurrentScreenNavigation && tappedCurrent || checkClickable(target) || tappedCurrent && !currentScreenInteractionEnabled) {
|
|
184
168
|
return;
|
|
185
169
|
}
|
|
186
|
-
|
|
187
170
|
var _currentTarget$getBou = currentTarget.getBoundingClientRect(),
|
|
188
|
-
|
|
189
|
-
|
|
171
|
+
width = _currentTarget$getBou.width;
|
|
190
172
|
var margin = (width - screenWidth) / 2;
|
|
191
173
|
var screenPreviousZone = screenWidth * (1 - nextScreenWidthPercent);
|
|
192
174
|
var previousZone = margin + screenPreviousZone;
|
|
193
175
|
var direction = x < previousZone ? 'previous' : 'next';
|
|
194
176
|
var lastIndex = screensCount - 1;
|
|
195
177
|
var nextIndex = index;
|
|
196
|
-
|
|
197
178
|
if (direction === 'previous' && !clickOnSiblings) {
|
|
198
179
|
nextIndex = Math.max(0, screenIndex - 1);
|
|
199
180
|
} else if (direction === 'next' && !clickOnSiblings) {
|
|
200
181
|
nextIndex = Math.min(lastIndex, screenIndex + 1);
|
|
201
182
|
}
|
|
202
|
-
|
|
203
183
|
if (onNavigate !== null) {
|
|
204
184
|
onNavigate({
|
|
205
185
|
index: index,
|
|
@@ -245,9 +225,9 @@ var propTypes$n = {
|
|
|
245
225
|
onClick: PropTypes.func,
|
|
246
226
|
refButton: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
247
227
|
current: PropTypes.any // eslint-disable-line
|
|
248
|
-
|
|
249
228
|
})])
|
|
250
229
|
};
|
|
230
|
+
|
|
251
231
|
var defaultProps$n = {
|
|
252
232
|
type: 'button',
|
|
253
233
|
theme: null,
|
|
@@ -273,35 +253,32 @@ var defaultProps$n = {
|
|
|
273
253
|
onClick: null,
|
|
274
254
|
refButton: null
|
|
275
255
|
};
|
|
276
|
-
|
|
277
256
|
var Button = function Button(_ref) {
|
|
278
257
|
var _ref2;
|
|
279
|
-
|
|
280
258
|
var type = _ref.type,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
259
|
+
theme = _ref.theme;
|
|
260
|
+
_ref.size;
|
|
261
|
+
var href = _ref.href,
|
|
262
|
+
external = _ref.external,
|
|
263
|
+
direct = _ref.direct,
|
|
264
|
+
target = _ref.target,
|
|
265
|
+
label = _ref.label,
|
|
266
|
+
children = _ref.children,
|
|
267
|
+
focusable = _ref.focusable;
|
|
268
|
+
_ref.active;
|
|
269
|
+
var icon = _ref.icon,
|
|
270
|
+
iconPosition = _ref.iconPosition,
|
|
271
|
+
disabled = _ref.disabled,
|
|
272
|
+
loading = _ref.loading,
|
|
273
|
+
disableOnLoading = _ref.disableOnLoading;
|
|
274
|
+
_ref.withoutTheme;
|
|
275
|
+
var asLink = _ref.asLink,
|
|
276
|
+
onClick = _ref.onClick,
|
|
277
|
+
className = _ref.className,
|
|
278
|
+
iconClassName = _ref.iconClassName,
|
|
279
|
+
labelClassName = _ref.labelClassName,
|
|
280
|
+
refButton = _ref.refButton,
|
|
281
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
305
282
|
var finalLabel = label || children;
|
|
306
283
|
var text = finalLabel !== null ? /*#__PURE__*/React.createElement(Label, null, finalLabel) : null;
|
|
307
284
|
var hasChildren = label !== null && children !== null;
|
|
@@ -309,19 +286,14 @@ var Button = function Button(_ref) {
|
|
|
309
286
|
var hasInlineIcon = hasIcon && (iconPosition === 'inline' || text === null);
|
|
310
287
|
var hasIconColumns = hasIcon && !hasInlineIcon;
|
|
311
288
|
var buttonClassNames = classNames([styles$g.container, styles$g["icon-".concat(iconPosition)], (_ref2 = {}, _defineProperty(_ref2, styles$g.withIcon, hasIcon), _defineProperty(_ref2, styles$g.withIconColumns, hasIconColumns), _defineProperty(_ref2, styles$g.withText, text !== null), _defineProperty(_ref2, styles$g.isLink, href !== null), _defineProperty(_ref2, styles$g.asLink, asLink), _defineProperty(_ref2, styles$g.isDisabled, disabled), _defineProperty(_ref2, styles$g.isLoading, loading), _defineProperty(_ref2, className, className !== null), _ref2)]);
|
|
312
|
-
|
|
313
289
|
var _ref3 = theme || {},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
290
|
+
_ref3$colors = _ref3.colors,
|
|
291
|
+
colors = _ref3$colors === void 0 ? null : _ref3$colors;
|
|
317
292
|
var _ref4 = colors || {},
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
293
|
+
_ref4$primary = _ref4.primary,
|
|
294
|
+
brandPrimaryColor = _ref4$primary === void 0 ? null : _ref4$primary;
|
|
321
295
|
var primaryColor = getStyleFromColor(brandPrimaryColor, 'color');
|
|
322
|
-
|
|
323
296
|
var buttonStyles = _objectSpread({}, primaryColor);
|
|
324
|
-
|
|
325
297
|
var content = /*#__PURE__*/React.createElement(React.Fragment, null, hasInlineIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
326
298
|
className: classNames([styles$g.icon, _defineProperty({}, iconClassName, iconClassName !== null)])
|
|
327
299
|
}, icon), text !== null ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -333,7 +305,6 @@ var Button = function Button(_ref) {
|
|
|
333
305
|
}, text), iconPosition === 'right' ? /*#__PURE__*/React.createElement("span", {
|
|
334
306
|
className: classNames([styles$g.icon, styles$g.right, _defineProperty({}, iconClassName, iconClassName !== null && iconPosition === 'right')])
|
|
335
307
|
}, icon) : null, hasChildren ? children : null) : null, !hasIcon ? text : null, hasChildren ? children : null);
|
|
336
|
-
|
|
337
308
|
if (href !== null) {
|
|
338
309
|
var linkClassNames = classNames([buttonClassNames, _defineProperty({
|
|
339
310
|
disabled: disabled
|
|
@@ -355,7 +326,6 @@ var Button = function Button(_ref) {
|
|
|
355
326
|
tabIndex: focusable ? '' : '-1'
|
|
356
327
|
}), content);
|
|
357
328
|
}
|
|
358
|
-
|
|
359
329
|
return /*#__PURE__*/React.createElement("button", Object.assign({}, props, {
|
|
360
330
|
type: type,
|
|
361
331
|
className: buttonClassNames,
|
|
@@ -366,7 +336,6 @@ var Button = function Button(_ref) {
|
|
|
366
336
|
tabIndex: focusable ? '0' : '-1'
|
|
367
337
|
}), content);
|
|
368
338
|
};
|
|
369
|
-
|
|
370
339
|
Button.propTypes = propTypes$n;
|
|
371
340
|
Button.defaultProps = defaultProps$n;
|
|
372
341
|
|
|
@@ -379,18 +348,15 @@ var propTypes$m = {
|
|
|
379
348
|
var defaultProps$m = {
|
|
380
349
|
className: null
|
|
381
350
|
};
|
|
382
|
-
|
|
383
351
|
var IconButton = function IconButton(_ref) {
|
|
384
352
|
var className = _ref.className,
|
|
385
|
-
|
|
386
|
-
|
|
353
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
387
354
|
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
388
355
|
className: classNames([styles$f.container, _defineProperty({}, className, className !== null)]),
|
|
389
356
|
labelClassName: styles$f.label,
|
|
390
357
|
iconClassName: styles$f.icon
|
|
391
358
|
}, props));
|
|
392
359
|
};
|
|
393
|
-
|
|
394
360
|
IconButton.propTypes = propTypes$m;
|
|
395
361
|
IconButton.defaultProps = defaultProps$m;
|
|
396
362
|
|
|
@@ -401,11 +367,9 @@ var propTypes$l = {
|
|
|
401
367
|
var defaultProps$l = {
|
|
402
368
|
className: null
|
|
403
369
|
};
|
|
404
|
-
|
|
405
370
|
var CloseButton = function CloseButton(_ref) {
|
|
406
371
|
var className = _ref.className,
|
|
407
|
-
|
|
408
|
-
|
|
372
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
409
373
|
var intl = useIntl();
|
|
410
374
|
return /*#__PURE__*/React.createElement(IconButton, Object.assign({
|
|
411
375
|
className: classNames([_defineProperty({}, className, className !== null)]),
|
|
@@ -427,7 +391,6 @@ var CloseButton = function CloseButton(_ref) {
|
|
|
427
391
|
}))
|
|
428
392
|
}, props));
|
|
429
393
|
};
|
|
430
|
-
|
|
431
394
|
CloseButton.propTypes = propTypes$l;
|
|
432
395
|
CloseButton.defaultProps = defaultProps$l;
|
|
433
396
|
|
|
@@ -438,11 +401,9 @@ var propTypes$k = {
|
|
|
438
401
|
var defaultProps$k = {
|
|
439
402
|
className: null
|
|
440
403
|
};
|
|
441
|
-
|
|
442
404
|
var MenuButton = function MenuButton(_ref) {
|
|
443
405
|
var className = _ref.className,
|
|
444
|
-
|
|
445
|
-
|
|
406
|
+
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
446
407
|
var intl = useIntl();
|
|
447
408
|
return /*#__PURE__*/React.createElement(IconButton, Object.assign({
|
|
448
409
|
className: classNames([_defineProperty({}, className, className !== null)]),
|
|
@@ -466,7 +427,6 @@ var MenuButton = function MenuButton(_ref) {
|
|
|
466
427
|
}))
|
|
467
428
|
}, props));
|
|
468
429
|
};
|
|
469
|
-
|
|
470
430
|
MenuButton.propTypes = propTypes$k;
|
|
471
431
|
MenuButton.defaultProps = defaultProps$k;
|
|
472
432
|
|
|
@@ -477,11 +437,9 @@ var propTypes$j = {
|
|
|
477
437
|
var defaultProps$j = {
|
|
478
438
|
className: null
|
|
479
439
|
};
|
|
480
|
-
|
|
481
440
|
var ShareButton = function ShareButton(_ref) {
|
|
482
441
|
var className = _ref.className,
|
|
483
|
-
|
|
484
|
-
|
|
442
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
485
443
|
var intl = useIntl();
|
|
486
444
|
return /*#__PURE__*/React.createElement(IconButton, Object.assign({
|
|
487
445
|
className: classNames([_defineProperty({}, className, className !== null)]),
|
|
@@ -506,7 +464,6 @@ var ShareButton = function ShareButton(_ref) {
|
|
|
506
464
|
}))
|
|
507
465
|
}, props));
|
|
508
466
|
};
|
|
509
|
-
|
|
510
467
|
ShareButton.propTypes = propTypes$j;
|
|
511
468
|
ShareButton.defaultProps = defaultProps$j;
|
|
512
469
|
|
|
@@ -527,13 +484,12 @@ var defaultProps$i = {
|
|
|
527
484
|
toggledButton: null,
|
|
528
485
|
toggledButtonClassName: null
|
|
529
486
|
};
|
|
530
|
-
|
|
531
487
|
var ToggleButton = function ToggleButton(_ref) {
|
|
532
488
|
var className = _ref.className,
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
489
|
+
progressSpring = _ref.progressSpring,
|
|
490
|
+
button = _ref.button,
|
|
491
|
+
toggledButton = _ref.toggledButton,
|
|
492
|
+
toggledButtonClassName = _ref.toggledButtonClassName;
|
|
537
493
|
if (button === null) return false;
|
|
538
494
|
return /*#__PURE__*/React.createElement("div", {
|
|
539
495
|
className: classNames([styles$e.container, _defineProperty({}, className, className !== null)])
|
|
@@ -553,7 +509,6 @@ var ToggleButton = function ToggleButton(_ref) {
|
|
|
553
509
|
}
|
|
554
510
|
}, toggledButton));
|
|
555
511
|
};
|
|
556
|
-
|
|
557
512
|
ToggleButton.propTypes = propTypes$i;
|
|
558
513
|
ToggleButton.defaultProps = defaultProps$i;
|
|
559
514
|
|
|
@@ -572,21 +527,17 @@ var defaultProps$h = {
|
|
|
572
527
|
theme: null,
|
|
573
528
|
children: null
|
|
574
529
|
};
|
|
575
|
-
|
|
576
530
|
var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
|
|
577
531
|
var className = _ref.className,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
532
|
+
progressSpring = _ref.progressSpring,
|
|
533
|
+
viewerTheme = _ref.theme,
|
|
534
|
+
children = _ref.children;
|
|
582
535
|
var _ref2 = viewerTheme || {},
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
536
|
+
_ref2$background = _ref2.background,
|
|
537
|
+
background = _ref2$background === void 0 ? null : _ref2$background;
|
|
586
538
|
var _ref3 = background || {},
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
539
|
+
_ref3$color = _ref3.color,
|
|
540
|
+
brandBackgroundColor = _ref3$color === void 0 ? null : _ref3$color;
|
|
590
541
|
var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
|
|
591
542
|
return /*#__PURE__*/React.createElement("div", {
|
|
592
543
|
className: classNames([styles$d.container, _defineProperty({}, className, className !== null)]),
|
|
@@ -616,7 +567,6 @@ var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
|
|
|
616
567
|
}
|
|
617
568
|
}));
|
|
618
569
|
};
|
|
619
|
-
|
|
620
570
|
ViewerMenuContainer.propTypes = propTypes$h;
|
|
621
571
|
ViewerMenuContainer.defaultProps = defaultProps$h;
|
|
622
572
|
|
|
@@ -645,38 +595,33 @@ var defaultProps$g = {
|
|
|
645
595
|
onClick: null,
|
|
646
596
|
className: null
|
|
647
597
|
};
|
|
648
|
-
|
|
649
598
|
var ViewerMenuDot = function ViewerMenuDot(_ref) {
|
|
650
599
|
var _ref3;
|
|
651
|
-
|
|
652
600
|
var current = _ref.current,
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
601
|
+
active = _ref.active,
|
|
602
|
+
colors = _ref.colors,
|
|
603
|
+
count = _ref.count,
|
|
604
|
+
subIndex = _ref.subIndex,
|
|
605
|
+
vertical = _ref.vertical,
|
|
606
|
+
onClick = _ref.onClick,
|
|
607
|
+
className = _ref.className;
|
|
661
608
|
var _ref2 = colors || {},
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
609
|
+
_ref2$primary = _ref2.primary,
|
|
610
|
+
primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
|
|
611
|
+
_ref2$secondary = _ref2.secondary,
|
|
612
|
+
secondary = _ref2$secondary === void 0 ? 'rgba(255, 255, 255, 0.25)' : _ref2$secondary;
|
|
667
613
|
var _useSpring = useSpring(function () {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
614
|
+
return {
|
|
615
|
+
scaleX: 0,
|
|
616
|
+
config: {
|
|
617
|
+
tension: 200,
|
|
618
|
+
friction: 30
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
}),
|
|
622
|
+
_useSpring2 = _slicedToArray(_useSpring, 2),
|
|
623
|
+
dotSpringStyles = _useSpring2[0],
|
|
624
|
+
setDotSpringProps = _useSpring2[1];
|
|
680
625
|
useEffect(function () {
|
|
681
626
|
var activeRatio = active ? 1 : 0;
|
|
682
627
|
var ratio = count > 1 && current ? (subIndex + 1) / count : activeRatio;
|
|
@@ -706,11 +651,10 @@ var ViewerMenuDot = function ViewerMenuDot(_ref) {
|
|
|
706
651
|
})
|
|
707
652
|
}))));
|
|
708
653
|
};
|
|
709
|
-
|
|
710
654
|
ViewerMenuDot.propTypes = propTypes$g;
|
|
711
655
|
ViewerMenuDot.defaultProps = defaultProps$g;
|
|
712
656
|
|
|
713
|
-
var styles$b = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","
|
|
657
|
+
var styles$b = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","items":"micromag-viewer-menus-menu-dots-items","item":"micromag-viewer-menus-menu-dots-item","vertical":"micromag-viewer-menus-menu-dots-vertical"};
|
|
714
658
|
|
|
715
659
|
var _excluded$3 = ["direction", "items", "onClickDot", "onClickScreensMenu", "colors", "closeable", "withItemClick", "withoutScreensMenu", "onClose", "className"];
|
|
716
660
|
var propTypes$f = {
|
|
@@ -740,36 +684,30 @@ var defaultProps$f = {
|
|
|
740
684
|
onClose: null,
|
|
741
685
|
className: null
|
|
742
686
|
};
|
|
743
|
-
|
|
744
687
|
var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
745
688
|
var _ref5;
|
|
746
|
-
|
|
747
689
|
var direction = _ref.direction,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
690
|
+
items = _ref.items,
|
|
691
|
+
onClickDot = _ref.onClickDot,
|
|
692
|
+
onClickScreensMenu = _ref.onClickScreensMenu,
|
|
693
|
+
colors = _ref.colors,
|
|
694
|
+
closeable = _ref.closeable,
|
|
695
|
+
withItemClick = _ref.withItemClick,
|
|
696
|
+
withoutScreensMenu = _ref.withoutScreensMenu,
|
|
697
|
+
onClose = _ref.onClose,
|
|
698
|
+
className = _ref.className,
|
|
699
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
759
700
|
var _ref2 = colors || {},
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
701
|
+
_ref2$primary = _ref2.primary,
|
|
702
|
+
primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary;
|
|
763
703
|
var intl = useIntl();
|
|
764
704
|
var currentIndex = items.findIndex(function (_ref3) {
|
|
765
705
|
var _ref3$current = _ref3.current,
|
|
766
|
-
|
|
706
|
+
current = _ref3$current === void 0 ? false : _ref3$current;
|
|
767
707
|
return current;
|
|
768
708
|
});
|
|
769
|
-
|
|
770
709
|
var _ref4 = props || {},
|
|
771
|
-
|
|
772
|
-
|
|
710
|
+
style = _ref4.style;
|
|
773
711
|
return /*#__PURE__*/React.createElement("nav", {
|
|
774
712
|
className: classNames([styles$b.container, (_ref5 = {}, _defineProperty(_ref5, className, className !== null), _defineProperty(_ref5, styles$b.vertical, direction === 'vertical'), _ref5)]),
|
|
775
713
|
"aria-label": intl.formatMessage({
|
|
@@ -799,13 +737,12 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
|
799
737
|
className: styles$b.items
|
|
800
738
|
}, items.map(function (item, index) {
|
|
801
739
|
var _ref6 = item || {},
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
740
|
+
_ref6$current = _ref6.current,
|
|
741
|
+
current = _ref6$current === void 0 ? false : _ref6$current,
|
|
742
|
+
_ref6$count = _ref6.count,
|
|
743
|
+
count = _ref6$count === void 0 ? 1 : _ref6$count,
|
|
744
|
+
_ref6$subIndex = _ref6.subIndex,
|
|
745
|
+
subIndex = _ref6$subIndex === void 0 ? 0 : _ref6$subIndex;
|
|
809
746
|
return /*#__PURE__*/React.createElement(ViewerMenuDot, {
|
|
810
747
|
key: "item-".concat(index + 1),
|
|
811
748
|
current: current,
|
|
@@ -849,7 +786,6 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
|
849
786
|
icon: faTimes
|
|
850
787
|
}))) : null));
|
|
851
788
|
};
|
|
852
|
-
|
|
853
789
|
ViewerMenuDots.propTypes = propTypes$f;
|
|
854
790
|
ViewerMenuDots.defaultProps = defaultProps$f;
|
|
855
791
|
|
|
@@ -859,7 +795,6 @@ var propTypes$e = {
|
|
|
859
795
|
var defaultProps$e = {
|
|
860
796
|
className: null
|
|
861
797
|
};
|
|
862
|
-
|
|
863
798
|
var StackIcon = function StackIcon(_ref) {
|
|
864
799
|
var className = _ref.className;
|
|
865
800
|
return /*#__PURE__*/React.createElement("svg", {
|
|
@@ -875,7 +810,6 @@ var StackIcon = function StackIcon(_ref) {
|
|
|
875
810
|
points: "10.5 1.5 10.5 16.5 1.5 16.5 1.5 17.5 11.5 17.5 11.5 1.5 10.5 1.5"
|
|
876
811
|
}));
|
|
877
812
|
};
|
|
878
|
-
|
|
879
813
|
StackIcon.propTypes = propTypes$e;
|
|
880
814
|
StackIcon.defaultProps = defaultProps$e;
|
|
881
815
|
|
|
@@ -897,29 +831,24 @@ var defaultProps$d = {
|
|
|
897
831
|
screenSize: null,
|
|
898
832
|
focusable: true
|
|
899
833
|
};
|
|
900
|
-
|
|
901
834
|
var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
|
|
902
835
|
var _ref4;
|
|
903
|
-
|
|
904
836
|
var className = _ref.className,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
837
|
+
item = _ref.item,
|
|
838
|
+
index = _ref.index,
|
|
839
|
+
_onClick = _ref.onClick,
|
|
840
|
+
screenSize = _ref.screenSize,
|
|
841
|
+
focusable = _ref.focusable;
|
|
910
842
|
var intl = useIntl();
|
|
911
|
-
|
|
912
843
|
var _ref2 = item || {},
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
844
|
+
_ref2$current = _ref2.current,
|
|
845
|
+
current = _ref2$current === void 0 ? false : _ref2$current,
|
|
846
|
+
screen = _ref2.screen,
|
|
847
|
+
_ref2$count = _ref2.count,
|
|
848
|
+
count = _ref2$count === void 0 ? 1 : _ref2$count;
|
|
919
849
|
var _ref3 = screenSize || {},
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
850
|
+
screenWidth = _ref3.width,
|
|
851
|
+
screenHeight = _ref3.height;
|
|
923
852
|
var screenAriaLabel = "".concat(intl.formatMessage({
|
|
924
853
|
id: "LkVfwW",
|
|
925
854
|
defaultMessage: [{
|
|
@@ -971,11 +900,10 @@ var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
|
|
|
971
900
|
withSize: true
|
|
972
901
|
}) : null));
|
|
973
902
|
};
|
|
974
|
-
|
|
975
903
|
ViewerMenuScreen.propTypes = propTypes$d;
|
|
976
904
|
ViewerMenuScreen.defaultProps = defaultProps$d;
|
|
977
905
|
|
|
978
|
-
var styles$9 = {"scroll":"micromag-viewer-menus-menu-preview-scroll","container":"micromag-viewer-menus-menu-preview-container","disabled":"micromag-viewer-menus-menu-preview-disabled","screenButton":"micromag-viewer-menus-menu-preview-screenButton","content":"micromag-viewer-menus-menu-preview-content","buttons":"micromag-viewer-menus-menu-preview-buttons","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","title":"micromag-viewer-menus-menu-preview-title","nav":"micromag-viewer-menus-menu-preview-nav","
|
|
906
|
+
var styles$9 = {"scroll":"micromag-viewer-menus-menu-preview-scroll","container":"micromag-viewer-menus-menu-preview-container","disabled":"micromag-viewer-menus-menu-preview-disabled","screenButton":"micromag-viewer-menus-menu-preview-screenButton","content":"micromag-viewer-menus-menu-preview-content","buttons":"micromag-viewer-menus-menu-preview-buttons","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","title":"micromag-viewer-menus-menu-preview-title","nav":"micromag-viewer-menus-menu-preview-nav","items":"micromag-viewer-menus-menu-preview-items","item":"micromag-viewer-menus-menu-preview-item","inner":"micromag-viewer-menus-menu-preview-inner","frame":"micromag-viewer-menus-menu-preview-frame","screen":"micromag-viewer-menus-menu-preview-screen","intro":"micromag-viewer-menus-menu-preview-intro"};
|
|
979
907
|
|
|
980
908
|
var propTypes$c = {
|
|
981
909
|
viewerTheme: PropTypes$1.viewerTheme,
|
|
@@ -1010,59 +938,54 @@ var defaultProps$c = {
|
|
|
1010
938
|
// fullscreenEnabled: false,
|
|
1011
939
|
className: null
|
|
1012
940
|
};
|
|
1013
|
-
|
|
1014
941
|
var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
1015
942
|
var viewerTheme = _ref.viewerTheme,
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
943
|
+
screenSize = _ref.screenSize,
|
|
944
|
+
menuWidth = _ref.menuWidth,
|
|
945
|
+
items = _ref.items,
|
|
946
|
+
focusable = _ref.focusable,
|
|
947
|
+
onClickScreen = _ref.onClickScreen,
|
|
948
|
+
maxThumbsWidth = _ref.maxThumbsWidth,
|
|
949
|
+
paddingTop = _ref.paddingTop,
|
|
950
|
+
scrollDisabled = _ref.scrollDisabled,
|
|
951
|
+
className = _ref.className;
|
|
1026
952
|
var _useDimensionObserver = useDimensionObserver(),
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
953
|
+
containerRef = _useDimensionObserver.ref,
|
|
954
|
+
_useDimensionObserver2 = _useDimensionObserver.width,
|
|
955
|
+
contentWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
|
|
1031
956
|
var thumbsPerLine = Math.max(Math.floor(contentWidth / maxThumbsWidth), 3); // @note cool, should be in recipes
|
|
957
|
+
|
|
1032
958
|
// @todo reimplement the brand logo
|
|
1033
959
|
// const { background = null, logo: brandLogo = null } = viewerTheme || {};
|
|
1034
|
-
|
|
1035
960
|
var _ref2 = viewerTheme || {},
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
961
|
+
_ref2$background = _ref2.background,
|
|
962
|
+
background = _ref2$background === void 0 ? null : _ref2$background;
|
|
1039
963
|
var _ref3 = background || {},
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
964
|
+
_ref3$image = _ref3.image,
|
|
965
|
+
image = _ref3$image === void 0 ? null : _ref3$image;
|
|
1043
966
|
var _ref4 = image || {},
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
967
|
+
_ref4$url = _ref4.url,
|
|
968
|
+
brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
|
|
1047
969
|
var brandImageStyle = brandImageUrl !== null ? {
|
|
1048
970
|
backgroundImage: "url(".concat(brandImageUrl, ")")
|
|
1049
|
-
} : null;
|
|
971
|
+
} : null;
|
|
1050
972
|
|
|
973
|
+
// const { url: brandLogoUrl = null } = brandLogo || {};
|
|
1051
974
|
var _useState = useState([]),
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
975
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
976
|
+
screensMounted = _useState2[0],
|
|
977
|
+
setScreensMounted = _useState2[1];
|
|
978
|
+
|
|
979
|
+
// @todo optimize all of this the proper way
|
|
1055
980
|
// const finalItems = useMemo(
|
|
1056
981
|
// () => (!focusable ? items.map((s, i) => (i > 6 ? { screenId: s.screenId } : s)) : items),
|
|
1057
982
|
// [items, focusable],
|
|
1058
983
|
// );
|
|
1059
984
|
|
|
1060
|
-
|
|
1061
985
|
useEffect(function () {
|
|
1062
986
|
if (items.length === screensMounted.length) {
|
|
1063
987
|
return function () {};
|
|
1064
988
|
}
|
|
1065
|
-
|
|
1066
989
|
var timeout = setTimeout(function () {
|
|
1067
990
|
setScreensMounted([].concat(_toConsumableArray(screensMounted), [true]));
|
|
1068
991
|
}, 40);
|
|
@@ -1091,16 +1014,13 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1091
1014
|
className: styles$9.items
|
|
1092
1015
|
}, items.map(function (item, index) {
|
|
1093
1016
|
var _ref6 = item || {},
|
|
1094
|
-
|
|
1095
|
-
|
|
1017
|
+
screenId = _ref6.screenId;
|
|
1096
1018
|
var itemStyles = {
|
|
1097
1019
|
width: "".concat(100 / thumbsPerLine, "%")
|
|
1098
1020
|
};
|
|
1099
|
-
|
|
1100
1021
|
var _ref7 = screenSize || {},
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1022
|
+
screenWidth = _ref7.width,
|
|
1023
|
+
screenHeight = _ref7.height;
|
|
1104
1024
|
var screenMounted = screensMounted[index] || false;
|
|
1105
1025
|
return /*#__PURE__*/React.createElement("li", {
|
|
1106
1026
|
key: "item-".concat(screenId),
|
|
@@ -1123,7 +1043,6 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1123
1043
|
}) : null)));
|
|
1124
1044
|
}))))));
|
|
1125
1045
|
};
|
|
1126
|
-
|
|
1127
1046
|
ViewerMenuPreview.propTypes = propTypes$c;
|
|
1128
1047
|
ViewerMenuPreview.defaultProps = defaultProps$c;
|
|
1129
1048
|
|
|
@@ -1143,13 +1062,12 @@ var defaultProps$b = {
|
|
|
1143
1062
|
description: null,
|
|
1144
1063
|
className: null
|
|
1145
1064
|
};
|
|
1146
|
-
|
|
1147
1065
|
var MicromagPreview = function MicromagPreview(_ref) {
|
|
1148
1066
|
var screen = _ref.screen,
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1067
|
+
title = _ref.title,
|
|
1068
|
+
url = _ref.url,
|
|
1069
|
+
description = _ref.description,
|
|
1070
|
+
className = _ref.className;
|
|
1153
1071
|
return /*#__PURE__*/React.createElement("div", {
|
|
1154
1072
|
className: classNames([styles$8.container, _defineProperty({}, className, className)])
|
|
1155
1073
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1167,7 +1085,6 @@ var MicromagPreview = function MicromagPreview(_ref) {
|
|
|
1167
1085
|
className: styles$8.url
|
|
1168
1086
|
}, url) : null, /*#__PURE__*/React.createElement("p", null, description)));
|
|
1169
1087
|
};
|
|
1170
|
-
|
|
1171
1088
|
MicromagPreview.propTypes = propTypes$b;
|
|
1172
1089
|
MicromagPreview.defaultProps = defaultProps$b;
|
|
1173
1090
|
|
|
@@ -1199,75 +1116,62 @@ var defaultProps$a = {
|
|
|
1199
1116
|
onShare: null,
|
|
1200
1117
|
className: null
|
|
1201
1118
|
};
|
|
1202
|
-
|
|
1203
1119
|
var ViewerMenuShare = function ViewerMenuShare(_ref) {
|
|
1204
1120
|
var viewerTheme = _ref.viewerTheme,
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1121
|
+
menuWidth = _ref.menuWidth,
|
|
1122
|
+
title = _ref.title,
|
|
1123
|
+
description = _ref.description,
|
|
1124
|
+
items = _ref.items,
|
|
1125
|
+
focusable = _ref.focusable,
|
|
1126
|
+
paddingTop = _ref.paddingTop,
|
|
1127
|
+
currentScreenIndex = _ref.currentScreenIndex,
|
|
1128
|
+
shareUrl = _ref.shareUrl,
|
|
1129
|
+
onShare = _ref.onShare,
|
|
1130
|
+
className = _ref.className;
|
|
1216
1131
|
// Viewer theme
|
|
1217
1132
|
var _ref2 = viewerTheme || {},
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1133
|
+
_ref2$background = _ref2.background,
|
|
1134
|
+
background = _ref2$background === void 0 ? null : _ref2$background;
|
|
1221
1135
|
var _ref3 = background || {},
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1136
|
+
_ref3$image = _ref3.image,
|
|
1137
|
+
image = _ref3$image === void 0 ? null : _ref3$image;
|
|
1225
1138
|
var _ref4 = image || {},
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1139
|
+
_ref4$url = _ref4.url,
|
|
1140
|
+
brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
|
|
1229
1141
|
var brandImageStyle = brandImageUrl !== null ? {
|
|
1230
1142
|
backgroundImage: "url(".concat(brandImageUrl, ")")
|
|
1231
1143
|
} : null;
|
|
1232
1144
|
var coverScreen = useMemo(function () {
|
|
1233
1145
|
var _ref5 = items[0] || {},
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1146
|
+
_ref5$screen = _ref5.screen,
|
|
1147
|
+
screen = _ref5$screen === void 0 ? null : _ref5$screen;
|
|
1237
1148
|
return screen;
|
|
1238
1149
|
}, [items]);
|
|
1239
1150
|
var currentScreen = useMemo(function () {
|
|
1240
1151
|
var found = items.find(function (item) {
|
|
1241
1152
|
var _ref6 = item || {},
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1153
|
+
_ref6$current = _ref6.current,
|
|
1154
|
+
current = _ref6$current === void 0 ? false : _ref6$current;
|
|
1245
1155
|
return current;
|
|
1246
1156
|
});
|
|
1247
|
-
|
|
1248
1157
|
var _ref7 = found || {},
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1158
|
+
_ref7$screen = _ref7.screen,
|
|
1159
|
+
screen = _ref7$screen === void 0 ? null : _ref7$screen;
|
|
1252
1160
|
return screen;
|
|
1253
1161
|
}, [items, currentScreenIndex, focusable]);
|
|
1254
|
-
|
|
1255
1162
|
var _useState = useState(false),
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1163
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1164
|
+
shareCurrentScreen = _useState2[0],
|
|
1165
|
+
setShareCurrentScreen = _useState2[1];
|
|
1260
1166
|
var onShareModeChange = useCallback(function () {
|
|
1261
1167
|
setShareCurrentScreen(function (value) {
|
|
1262
1168
|
return !value;
|
|
1263
1169
|
});
|
|
1264
1170
|
}, [setShareCurrentScreen]);
|
|
1265
|
-
|
|
1266
1171
|
var _useState3 = useState(shareUrl),
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1172
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1173
|
+
finalShareUrl = _useState4[0],
|
|
1174
|
+
setFinalShareUrl = _useState4[1];
|
|
1271
1175
|
useEffect(function () {
|
|
1272
1176
|
setFinalShareUrl(shareCurrentScreen && currentScreenIndex !== 0 ? "".concat(shareUrl, "/").concat(currentScreenIndex + 1) : shareUrl);
|
|
1273
1177
|
}, [shareCurrentScreen, currentScreenIndex, setFinalShareUrl]);
|
|
@@ -1320,11 +1224,10 @@ var ViewerMenuShare = function ViewerMenuShare(_ref) {
|
|
|
1320
1224
|
shareCurrentScreen: shareCurrentScreen
|
|
1321
1225
|
})))));
|
|
1322
1226
|
};
|
|
1323
|
-
|
|
1324
1227
|
ViewerMenuShare.propTypes = propTypes$a;
|
|
1325
1228
|
ViewerMenuShare.defaultProps = defaultProps$a;
|
|
1326
1229
|
|
|
1327
|
-
var styles$6 = {"container":"micromag-viewer-container","
|
|
1230
|
+
var styles$6 = {"container":"micromag-viewer-container","screenContainer":"micromag-viewer-screenContainer","screensFrame":"micromag-viewer-screensFrame","menuShare":"micromag-viewer-menuShare","menuPreview":"micromag-viewer-menuPreview","menuContainer":"micromag-viewer-menuContainer","landscape":"micromag-viewer-landscape","hideMenu":"micromag-viewer-hideMenu","menuNavContainer":"micromag-viewer-menuNavContainer","menuTopContainer":"micromag-viewer-menuTopContainer","dots":"micromag-viewer-dots","disableMenu":"micromag-viewer-disableMenu","content":"micromag-viewer-content","withoutGestures":"micromag-viewer-withoutGestures","fadeMenu":"micromag-viewer-fadeMenu","withShadow":"micromag-viewer-withShadow","isOpened":"micromag-viewer-isOpened","menuItem":"micromag-viewer-menuItem","menuButton":"micromag-viewer-menuButton","slidingButton":"micromag-viewer-slidingButton","screensMenuButtonToggled":"micromag-viewer-screensMenuButtonToggled","navButton":"micromag-viewer-navButton","previous":"micromag-viewer-previous","next":"micromag-viewer-next","screen":"micromag-viewer-screen","current":"micromag-viewer-current","playbackControls":"micromag-viewer-playbackControls","arrowHint":"micromag-viewer-arrowHint","webView":"micromag-viewer-webView","shareIncentiveContainer":"micromag-viewer-shareIncentiveContainer","shareIncentive":"micromag-viewer-shareIncentive","shareIncentiveVisible":"micromag-viewer-shareIncentiveVisible"};
|
|
1328
1231
|
|
|
1329
1232
|
var propTypes$9 = {
|
|
1330
1233
|
story: PropTypes$1.story.isRequired,
|
|
@@ -1347,9 +1250,9 @@ var propTypes$9 = {
|
|
|
1347
1250
|
onClickCloseViewer: PropTypes.func,
|
|
1348
1251
|
refDots: PropTypes.shape({
|
|
1349
1252
|
current: PropTypes.any // eslint-disable-line
|
|
1350
|
-
|
|
1351
1253
|
})
|
|
1352
1254
|
};
|
|
1255
|
+
|
|
1353
1256
|
var defaultProps$9 = {
|
|
1354
1257
|
currentScreenIndex: 0,
|
|
1355
1258
|
toggleFullscreen: null,
|
|
@@ -1370,75 +1273,63 @@ var defaultProps$9 = {
|
|
|
1370
1273
|
onClickCloseViewer: null,
|
|
1371
1274
|
refDots: null
|
|
1372
1275
|
};
|
|
1373
|
-
|
|
1374
1276
|
var ViewerMenu = function ViewerMenu(_ref) {
|
|
1375
1277
|
var _ref11;
|
|
1376
|
-
|
|
1377
1278
|
var story = _ref.story,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1279
|
+
currentScreenIndex = _ref.currentScreenIndex,
|
|
1280
|
+
toggleFullscreen = _ref.toggleFullscreen,
|
|
1281
|
+
fullscreenActive = _ref.fullscreenActive,
|
|
1282
|
+
fullscreenEnabled = _ref.fullscreenEnabled,
|
|
1283
|
+
closeable = _ref.closeable,
|
|
1284
|
+
withShadow = _ref.withShadow,
|
|
1285
|
+
shareBasePath = _ref.shareBasePath,
|
|
1286
|
+
trackingEnabled = _ref.trackingEnabled,
|
|
1287
|
+
viewerTheme = _ref.theme,
|
|
1288
|
+
screenSize = _ref.screenSize,
|
|
1289
|
+
menuWidth = _ref.menuWidth,
|
|
1290
|
+
withDotItemClick = _ref.withDotItemClick,
|
|
1291
|
+
withoutScreensMenu = _ref.withoutScreensMenu,
|
|
1292
|
+
withoutShareMenu = _ref.withoutShareMenu,
|
|
1293
|
+
customOnClickScreen = _ref.onClickScreen;
|
|
1294
|
+
_ref.onClickMenu;
|
|
1295
|
+
var onClickCloseViewer = _ref.onClickCloseViewer,
|
|
1296
|
+
refDots = _ref.refDots;
|
|
1396
1297
|
var _story$components = story.components,
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1298
|
+
screens = _story$components === void 0 ? [] : _story$components,
|
|
1299
|
+
_story$title = story.title,
|
|
1300
|
+
title = _story$title === void 0 ? null : _story$title,
|
|
1301
|
+
_story$metadata = story.metadata,
|
|
1302
|
+
metadata = _story$metadata === void 0 ? null : _story$metadata;
|
|
1403
1303
|
var _ref2 = metadata || {},
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1304
|
+
_ref2$description = _ref2.description,
|
|
1305
|
+
description = _ref2$description === void 0 ? null : _ref2$description;
|
|
1407
1306
|
var currentScreen = screens !== null ? screens[currentScreenIndex] || null : null;
|
|
1408
|
-
|
|
1409
1307
|
var _ref3 = currentScreen || {},
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1308
|
+
_ref3$id = _ref3.id,
|
|
1309
|
+
screenId = _ref3$id === void 0 ? null : _ref3$id,
|
|
1310
|
+
_ref3$type = _ref3.type,
|
|
1311
|
+
screenType = _ref3$type === void 0 ? null : _ref3$type;
|
|
1415
1312
|
var _ref4 = viewerTheme || {},
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1313
|
+
_ref4$menuTheme = _ref4.menuTheme,
|
|
1314
|
+
menuTheme = _ref4$menuTheme === void 0 ? null : _ref4$menuTheme;
|
|
1419
1315
|
var _useViewerSize = useViewerSize(),
|
|
1420
|
-
|
|
1421
|
-
|
|
1316
|
+
viewerHeight = _useViewerSize.height;
|
|
1422
1317
|
var _useState = useState(false),
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1318
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1319
|
+
menuOpened = _useState2[0],
|
|
1320
|
+
setMenuOpened = _useState2[1];
|
|
1427
1321
|
var _useState3 = useState(false),
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1322
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1323
|
+
shareOpened = _useState4[0],
|
|
1324
|
+
setShareOpened = _useState4[1];
|
|
1432
1325
|
var _useState5 = useState(false),
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1326
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1327
|
+
menuMounted = _useState6[0],
|
|
1328
|
+
setMenuMounted = _useState6[1];
|
|
1437
1329
|
var _useDimensionObserver = useDimensionObserver(),
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1330
|
+
navContainerRef = _useDimensionObserver.ref,
|
|
1331
|
+
_useDimensionObserver2 = _useDimensionObserver.height,
|
|
1332
|
+
navContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
|
|
1442
1333
|
var items = useMemo(function () {
|
|
1443
1334
|
return screens.map(function (it) {
|
|
1444
1335
|
var children = screens.filter(function (s) {
|
|
@@ -1460,7 +1351,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1460
1351
|
};
|
|
1461
1352
|
}).filter(function (_ref5) {
|
|
1462
1353
|
var _ref5$visible = _ref5.visible,
|
|
1463
|
-
|
|
1354
|
+
visible = _ref5$visible === void 0 ? true : _ref5$visible;
|
|
1464
1355
|
return visible;
|
|
1465
1356
|
});
|
|
1466
1357
|
}, [screens, screenId]);
|
|
@@ -1505,11 +1396,9 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1505
1396
|
}, [setShareOpened, setMenuOpened, trackScreenEvent]);
|
|
1506
1397
|
var onClickScreen = useCallback(function (screen) {
|
|
1507
1398
|
setMenuOpened(false);
|
|
1508
|
-
|
|
1509
1399
|
if (customOnClickScreen !== null) {
|
|
1510
1400
|
customOnClickScreen(screen);
|
|
1511
1401
|
}
|
|
1512
|
-
|
|
1513
1402
|
var index = items.findIndex(function (_ref6) {
|
|
1514
1403
|
var id = _ref6.id;
|
|
1515
1404
|
return id === screenId;
|
|
@@ -1522,40 +1411,34 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1522
1411
|
}, [trackScreenEvent]);
|
|
1523
1412
|
var computeShareProgress = useCallback(function (_ref7) {
|
|
1524
1413
|
var active = _ref7.active,
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1414
|
+
_ref7$direction = _slicedToArray(_ref7.direction, 2),
|
|
1415
|
+
dy = _ref7$direction[1],
|
|
1416
|
+
_ref7$movement = _slicedToArray(_ref7.movement, 2),
|
|
1417
|
+
my = _ref7$movement[1],
|
|
1418
|
+
_ref7$velocity = _slicedToArray(_ref7.velocity, 2),
|
|
1419
|
+
vy = _ref7$velocity[1];
|
|
1532
1420
|
var progress = Math.max(0, my) / (viewerHeight * 0.8);
|
|
1533
1421
|
var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
|
|
1534
|
-
|
|
1535
1422
|
if (!active) {
|
|
1536
1423
|
if (reachedThreshold) onOpenShare();
|
|
1537
1424
|
return reachedThreshold ? 1 : 0;
|
|
1538
1425
|
}
|
|
1539
|
-
|
|
1540
1426
|
return progress;
|
|
1541
1427
|
}, [onOpenShare, viewerHeight]);
|
|
1542
1428
|
var computeShareProgressClose = useCallback(function (_ref8) {
|
|
1543
1429
|
var active = _ref8.active,
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1430
|
+
_ref8$direction = _slicedToArray(_ref8.direction, 2),
|
|
1431
|
+
dy = _ref8$direction[1],
|
|
1432
|
+
_ref8$movement = _slicedToArray(_ref8.movement, 2),
|
|
1433
|
+
my = _ref8$movement[1],
|
|
1434
|
+
_ref8$velocity = _slicedToArray(_ref8.velocity, 2),
|
|
1435
|
+
vy = _ref8$velocity[1];
|
|
1551
1436
|
var progress = Math.max(0, my) / (viewerHeight * 0.8);
|
|
1552
1437
|
var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
|
|
1553
|
-
|
|
1554
1438
|
if (!active) {
|
|
1555
1439
|
if (reachedThreshold) onCloseShare();
|
|
1556
1440
|
return reachedThreshold ? 0 : 1;
|
|
1557
1441
|
}
|
|
1558
|
-
|
|
1559
1442
|
return 1 - progress;
|
|
1560
1443
|
}, [onCloseShare, viewerHeight]);
|
|
1561
1444
|
var springParams = useMemo(function () {
|
|
@@ -1566,64 +1449,54 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1566
1449
|
}
|
|
1567
1450
|
};
|
|
1568
1451
|
}, []);
|
|
1569
|
-
|
|
1570
1452
|
var _useDragProgress = useDragProgress({
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1453
|
+
progress: shareOpened ? 1 : 0,
|
|
1454
|
+
computeProgress: shareOpened ? computeShareProgressClose : computeShareProgress,
|
|
1455
|
+
springParams: springParams
|
|
1456
|
+
}),
|
|
1457
|
+
bindShareDrag = _useDragProgress.bind,
|
|
1458
|
+
draggingShare = _useDragProgress.dragging,
|
|
1459
|
+
shareOpenedProgress = _useDragProgress.progress;
|
|
1579
1460
|
var computeMenuProgress = useCallback(function (_ref9) {
|
|
1580
1461
|
var active = _ref9.active,
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1462
|
+
_ref9$direction = _slicedToArray(_ref9.direction, 2),
|
|
1463
|
+
dy = _ref9$direction[1],
|
|
1464
|
+
_ref9$movement = _slicedToArray(_ref9.movement, 2),
|
|
1465
|
+
my = _ref9$movement[1],
|
|
1466
|
+
_ref9$velocity = _slicedToArray(_ref9.velocity, 2),
|
|
1467
|
+
vy = _ref9$velocity[1];
|
|
1588
1468
|
var progress = Math.max(0, my) / (window.innerHeight * 0.8);
|
|
1589
1469
|
var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
|
|
1590
|
-
|
|
1591
1470
|
if (!active) {
|
|
1592
1471
|
if (reachedThreshold) onOpenMenu();
|
|
1593
1472
|
return reachedThreshold ? 1 : 0;
|
|
1594
1473
|
}
|
|
1595
|
-
|
|
1596
1474
|
return progress;
|
|
1597
1475
|
}, [onOpenMenu]);
|
|
1598
1476
|
var computeMenuProgressClose = useCallback(function (_ref10) {
|
|
1599
1477
|
var active = _ref10.active,
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1478
|
+
_ref10$direction = _slicedToArray(_ref10.direction, 2),
|
|
1479
|
+
dy = _ref10$direction[1],
|
|
1480
|
+
_ref10$movement = _slicedToArray(_ref10.movement, 2),
|
|
1481
|
+
my = _ref10$movement[1],
|
|
1482
|
+
_ref10$velocity = _slicedToArray(_ref10.velocity, 2),
|
|
1483
|
+
vy = _ref10$velocity[1];
|
|
1607
1484
|
var progress = Math.max(0, my) / (window.innerHeight * 0.8);
|
|
1608
1485
|
var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
|
|
1609
|
-
|
|
1610
1486
|
if (!active) {
|
|
1611
1487
|
if (reachedThreshold) onCloseMenu();
|
|
1612
1488
|
return reachedThreshold ? 0 : 1;
|
|
1613
1489
|
}
|
|
1614
|
-
|
|
1615
1490
|
return 1 - progress;
|
|
1616
1491
|
}, [onCloseMenu]);
|
|
1617
|
-
|
|
1618
1492
|
var _useDragProgress2 = useDragProgress({
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1493
|
+
progress: menuOpened ? 1 : 0,
|
|
1494
|
+
computeProgress: menuOpened ? computeMenuProgressClose : computeMenuProgress,
|
|
1495
|
+
springParams: springParams
|
|
1496
|
+
}),
|
|
1497
|
+
bindMenuDrag = _useDragProgress2.bind,
|
|
1498
|
+
draggingMenu = _useDragProgress2.dragging,
|
|
1499
|
+
menuOpenedProgress = _useDragProgress2.progress;
|
|
1627
1500
|
var keyboardShortcuts = useMemo(function () {
|
|
1628
1501
|
return {
|
|
1629
1502
|
m: function m() {
|
|
@@ -1636,9 +1509,12 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1636
1509
|
}, [menuOpened, onOpenMenu, onCloseMenu]);
|
|
1637
1510
|
useKeyboardShortcuts(keyboardShortcuts);
|
|
1638
1511
|
var menuOpenedProgressValue = menuOpenedProgress ? menuOpenedProgress.value || 0 : 0;
|
|
1639
|
-
var shareOpenedProgressValue = shareOpenedProgress ? shareOpenedProgress.value || 0 : 0;
|
|
1512
|
+
var shareOpenedProgressValue = shareOpenedProgress ? shareOpenedProgress.value || 0 : 0;
|
|
1513
|
+
|
|
1514
|
+
// should be zero if either screens menu or share menu is opened
|
|
1515
|
+
var dotsOpacity = Math.min(1, Math.max(0, 1 - (menuOpenedProgressValue + shareOpenedProgressValue)));
|
|
1640
1516
|
|
|
1641
|
-
|
|
1517
|
+
// console.log(dotsOpacity, menuProgressValue, shareProgressValue);
|
|
1642
1518
|
|
|
1643
1519
|
useEffect(function () {
|
|
1644
1520
|
if ((menuOpened || draggingMenu) && !menuMounted) {
|
|
@@ -1707,7 +1583,6 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1707
1583
|
className: styles$6.dots,
|
|
1708
1584
|
style: {
|
|
1709
1585
|
opacity: Math.pow(dotsOpacity, 5) // @note this is like a "quint" easing, meaning it'll go towards 1 slowly first and then fast as it approaches 1
|
|
1710
|
-
|
|
1711
1586
|
}
|
|
1712
1587
|
}))), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
|
|
1713
1588
|
className: styles$6.menuContainer,
|
|
@@ -1748,7 +1623,6 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1748
1623
|
fullscreenEnabled: fullscreenEnabled
|
|
1749
1624
|
}) : null));
|
|
1750
1625
|
};
|
|
1751
|
-
|
|
1752
1626
|
ViewerMenu.propTypes = propTypes$9;
|
|
1753
1627
|
ViewerMenu.defaultProps = defaultProps$9;
|
|
1754
1628
|
var ViewerMenu$1 = /*#__PURE__*/React.memo(ViewerMenu);
|
|
@@ -1783,34 +1657,29 @@ var defaultProps$8 = {
|
|
|
1783
1657
|
// withNavigationHint: false,
|
|
1784
1658
|
className: null
|
|
1785
1659
|
};
|
|
1786
|
-
|
|
1787
1660
|
function ViewerScreen(_ref) {
|
|
1788
1661
|
var screen = _ref.screen,
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1662
|
+
renderContext = _ref.renderContext,
|
|
1663
|
+
index = _ref.index,
|
|
1664
|
+
screenState = _ref.screenState,
|
|
1665
|
+
active = _ref.active,
|
|
1666
|
+
current = _ref.current,
|
|
1667
|
+
mediaRef = _ref.mediaRef,
|
|
1668
|
+
width = _ref.width,
|
|
1669
|
+
height = _ref.height,
|
|
1670
|
+
scale = _ref.scale,
|
|
1671
|
+
className = _ref.className;
|
|
1800
1672
|
var _useState = useState(active || current),
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1673
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1674
|
+
mounted = _useState2[0],
|
|
1675
|
+
setMounted = _useState2[1];
|
|
1805
1676
|
useEffect(function () {
|
|
1806
1677
|
var timeout = null;
|
|
1807
|
-
|
|
1808
1678
|
if (active !== mounted) {
|
|
1809
1679
|
timeout = setTimeout(function () {
|
|
1810
1680
|
setMounted(active);
|
|
1811
1681
|
}, 200);
|
|
1812
1682
|
}
|
|
1813
|
-
|
|
1814
1683
|
return function () {
|
|
1815
1684
|
if (timeout !== null) {
|
|
1816
1685
|
clearTimeout(timeout);
|
|
@@ -1838,7 +1707,6 @@ function ViewerScreen(_ref) {
|
|
|
1838
1707
|
mediaRef: mediaRef
|
|
1839
1708
|
}) : null));
|
|
1840
1709
|
}
|
|
1841
|
-
|
|
1842
1710
|
ViewerScreen.propTypes = propTypes$8;
|
|
1843
1711
|
ViewerScreen.defaultProps = defaultProps$8;
|
|
1844
1712
|
|
|
@@ -1854,11 +1722,10 @@ var defaultProps$7 = {
|
|
|
1854
1722
|
onClick: null,
|
|
1855
1723
|
className: null
|
|
1856
1724
|
};
|
|
1857
|
-
|
|
1858
1725
|
var NavigationButton = function NavigationButton(_ref) {
|
|
1859
1726
|
var direction = _ref.direction,
|
|
1860
|
-
|
|
1861
|
-
|
|
1727
|
+
onClick = _ref.onClick,
|
|
1728
|
+
className = _ref.className;
|
|
1862
1729
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
1863
1730
|
className: classNames([styles$4.container, styles$4[direction], _defineProperty({}, className, className !== null)]),
|
|
1864
1731
|
onClick: onClick,
|
|
@@ -1890,7 +1757,6 @@ var NavigationButton = function NavigationButton(_ref) {
|
|
|
1890
1757
|
}))
|
|
1891
1758
|
});
|
|
1892
1759
|
};
|
|
1893
|
-
|
|
1894
1760
|
NavigationButton.propTypes = propTypes$7;
|
|
1895
1761
|
NavigationButton.defaultProps = defaultProps$7;
|
|
1896
1762
|
|
|
@@ -1902,7 +1768,6 @@ var propTypes$6 = {
|
|
|
1902
1768
|
var defaultProps$6 = {
|
|
1903
1769
|
className: null
|
|
1904
1770
|
};
|
|
1905
|
-
|
|
1906
1771
|
var ArrowHint = function ArrowHint(_ref) {
|
|
1907
1772
|
var className = _ref.className;
|
|
1908
1773
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1923,7 +1788,6 @@ var ArrowHint = function ArrowHint(_ref) {
|
|
|
1923
1788
|
points: "9.62 4.62 5 0 0.38 4.62 1.44 5.68 4.25 2.87 4.25 14.39 5.75 14.39 5.75 2.87 8.56 5.68 9.62 4.62"
|
|
1924
1789
|
}))));
|
|
1925
1790
|
};
|
|
1926
|
-
|
|
1927
1791
|
ArrowHint.propTypes = propTypes$6;
|
|
1928
1792
|
ArrowHint.defaultProps = defaultProps$6;
|
|
1929
1793
|
|
|
@@ -1949,28 +1813,22 @@ var stopDragEventsPropagation = {
|
|
|
1949
1813
|
return e.stopPropagation();
|
|
1950
1814
|
}
|
|
1951
1815
|
};
|
|
1952
|
-
|
|
1953
1816
|
function getFormattedTimestamp() {
|
|
1954
1817
|
var secondsWithMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1955
|
-
|
|
1956
1818
|
if (secondsWithMs === null || secondsWithMs <= 0) {
|
|
1957
1819
|
return '00:00';
|
|
1958
1820
|
}
|
|
1959
|
-
|
|
1960
1821
|
var parts = "".concat(secondsWithMs).split('.');
|
|
1961
|
-
|
|
1962
1822
|
var _ref = parts || [],
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1823
|
+
_ref2 = _slicedToArray(_ref, 1),
|
|
1824
|
+
_ref2$ = _ref2[0],
|
|
1825
|
+
fullSeconds = _ref2$ === void 0 ? 0 : _ref2$;
|
|
1967
1826
|
var finalFullSeconds = Math.round(fullSeconds);
|
|
1968
1827
|
var seconds = finalFullSeconds % 60;
|
|
1969
1828
|
var diff = finalFullSeconds - seconds;
|
|
1970
1829
|
var minutes = diff > 0 ? diff / 60 : 0;
|
|
1971
1830
|
return "".concat(String(Math.round(minutes)).padStart(2, '0'), ":").concat(String(Math.round(seconds)).padStart(2, '0'));
|
|
1972
1831
|
}
|
|
1973
|
-
|
|
1974
1832
|
var SHOW_MILLISECONDS_THRESHOLD = 5; // show milliseconds when scrubbing if length of video is shorter than 5 seconds
|
|
1975
1833
|
|
|
1976
1834
|
var propTypes$5 = {
|
|
@@ -1978,6 +1836,7 @@ var propTypes$5 = {
|
|
|
1978
1836
|
current: PropTypes.any
|
|
1979
1837
|
}) // eslint-disable-line
|
|
1980
1838
|
]),
|
|
1839
|
+
|
|
1981
1840
|
playing: PropTypes.bool,
|
|
1982
1841
|
backgroundColor: PropTypes.string,
|
|
1983
1842
|
progressColor: PropTypes.string,
|
|
@@ -2000,63 +1859,53 @@ var defaultProps$5 = {
|
|
|
2000
1859
|
className: null,
|
|
2001
1860
|
withSeekHead: true
|
|
2002
1861
|
};
|
|
2003
|
-
|
|
2004
1862
|
var SeekBar = function SeekBar(_ref3) {
|
|
2005
1863
|
var _ref6;
|
|
2006
|
-
|
|
2007
1864
|
var media = _ref3.media,
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
1865
|
+
playing = _ref3.playing,
|
|
1866
|
+
backgroundColor = _ref3.backgroundColor,
|
|
1867
|
+
progressColor = _ref3.progressColor,
|
|
1868
|
+
onSeek = _ref3.onSeek,
|
|
1869
|
+
onSeekStart = _ref3.onSeekStart,
|
|
1870
|
+
onSeekEnd = _ref3.onSeekEnd,
|
|
1871
|
+
focusable = _ref3.focusable,
|
|
1872
|
+
className = _ref3.className,
|
|
1873
|
+
withSeekHead = _ref3.withSeekHead;
|
|
2017
1874
|
var intl = useIntl();
|
|
2018
1875
|
var progress = useMediaProgress(media, {
|
|
2019
1876
|
disabled: !playing
|
|
2020
1877
|
});
|
|
2021
|
-
|
|
2022
1878
|
var _ref4 = media || {},
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
1879
|
+
_ref4$currentTime = _ref4.currentTime,
|
|
1880
|
+
currentTime = _ref4$currentTime === void 0 ? null : _ref4$currentTime,
|
|
1881
|
+
_ref4$duration = _ref4.duration,
|
|
1882
|
+
duration = _ref4$duration === void 0 ? null : _ref4$duration;
|
|
2028
1883
|
var _useState = useState(false),
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
1884
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1885
|
+
showTimestamp = _useState2[0],
|
|
1886
|
+
setShowTimestamp = _useState2[1];
|
|
2033
1887
|
var onDrag = useCallback(function (_ref5) {
|
|
2034
1888
|
var _ref5$xy = _slicedToArray(_ref5.xy, 1),
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
1889
|
+
x = _ref5$xy[0],
|
|
1890
|
+
elapsedTime = _ref5.elapsedTime,
|
|
1891
|
+
active = _ref5.active,
|
|
1892
|
+
tap = _ref5.tap,
|
|
1893
|
+
currentTarget = _ref5.currentTarget;
|
|
2041
1894
|
if (!active && elapsedTime > 300) {
|
|
2042
1895
|
return;
|
|
2043
1896
|
}
|
|
2044
|
-
|
|
2045
1897
|
var _currentTarget$getBou = currentTarget.getBoundingClientRect(),
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
1898
|
+
_currentTarget$getBou2 = _currentTarget$getBou.left,
|
|
1899
|
+
elX = _currentTarget$getBou2 === void 0 ? 0 : _currentTarget$getBou2,
|
|
1900
|
+
_currentTarget$getBou3 = _currentTarget$getBou.width,
|
|
1901
|
+
elWidth = _currentTarget$getBou3 === void 0 ? 0 : _currentTarget$getBou3;
|
|
2051
1902
|
var newProgress = Math.max(0, Math.min(1, (x - elX) / elWidth));
|
|
2052
|
-
|
|
2053
1903
|
if (onSeek !== null) {
|
|
2054
1904
|
onSeek(newProgress, tap);
|
|
2055
1905
|
}
|
|
2056
1906
|
}, [onSeek]);
|
|
2057
1907
|
var onDragStart = useCallback(function () {
|
|
2058
1908
|
setShowTimestamp(true);
|
|
2059
|
-
|
|
2060
1909
|
if (onSeekStart !== null) {
|
|
2061
1910
|
onSeekStart();
|
|
2062
1911
|
}
|
|
@@ -2123,11 +1972,10 @@ var SeekBar = function SeekBar(_ref3) {
|
|
|
2123
1972
|
tabIndex: focusable ? '0' : '-1'
|
|
2124
1973
|
}))));
|
|
2125
1974
|
};
|
|
2126
|
-
|
|
2127
1975
|
SeekBar.propTypes = propTypes$5;
|
|
2128
1976
|
SeekBar.defaultProps = defaultProps$5;
|
|
2129
1977
|
|
|
2130
|
-
var styles$1 = {"
|
|
1978
|
+
var styles$1 = {"playPauseButton":"micromag-viewer-partials-playback-controls-playPauseButton","muteButton":"micromag-viewer-partials-playback-controls-muteButton","container":"micromag-viewer-partials-playback-controls-container","icon":"micromag-viewer-partials-playback-controls-icon","withPlayPause":"micromag-viewer-partials-playback-controls-withPlayPause","isCollapsed":"micromag-viewer-partials-playback-controls-isCollapsed","isMuted":"micromag-viewer-partials-playback-controls-isMuted","withMute":"micromag-viewer-partials-playback-controls-withMute","withSeekBar":"micromag-viewer-partials-playback-controls-withSeekBar","seekBar":"micromag-viewer-partials-playback-controls-seekBar","withSeekBarOnly":"micromag-viewer-partials-playback-controls-withSeekBarOnly"};
|
|
2131
1979
|
|
|
2132
1980
|
var propTypes$4 = {
|
|
2133
1981
|
className: PropTypes.string,
|
|
@@ -2137,46 +1985,39 @@ var defaultProps$4 = {
|
|
|
2137
1985
|
className: null,
|
|
2138
1986
|
collapsedClassName: null
|
|
2139
1987
|
};
|
|
2140
|
-
|
|
2141
1988
|
function PlaybackControls(_ref) {
|
|
2142
1989
|
var _ref4;
|
|
2143
|
-
|
|
2144
1990
|
var className = _ref.className,
|
|
2145
|
-
|
|
1991
|
+
collapsedClassName = _ref.collapsedClassName;
|
|
2146
1992
|
var intl = useIntl();
|
|
2147
|
-
|
|
2148
1993
|
var _usePlaybackContext = usePlaybackContext(),
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
1994
|
+
_usePlaybackContext$m = _usePlaybackContext.media,
|
|
1995
|
+
mediaElement = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m,
|
|
1996
|
+
_usePlaybackContext$h = _usePlaybackContext.hasAudio,
|
|
1997
|
+
hasAudio = _usePlaybackContext$h === void 0 ? null : _usePlaybackContext$h,
|
|
1998
|
+
_usePlaybackContext$p = _usePlaybackContext.playing,
|
|
1999
|
+
playing = _usePlaybackContext$p === void 0 ? false : _usePlaybackContext$p,
|
|
2000
|
+
_usePlaybackContext$m2 = _usePlaybackContext.muted,
|
|
2001
|
+
muted = _usePlaybackContext$m2 === void 0 ? true : _usePlaybackContext$m2,
|
|
2002
|
+
setPlaying = _usePlaybackContext.setPlaying,
|
|
2003
|
+
setMuted = _usePlaybackContext.setMuted,
|
|
2004
|
+
controls = _usePlaybackContext.controls,
|
|
2005
|
+
controlsVisible = _usePlaybackContext.controlsVisible,
|
|
2006
|
+
controlsTheme = _usePlaybackContext.controlsTheme,
|
|
2007
|
+
showControls = _usePlaybackContext.showControls;
|
|
2164
2008
|
var _useState = useState(null),
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2009
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2010
|
+
customControlsTheme = _useState2[0],
|
|
2011
|
+
setCustomControlsTheme = _useState2[1];
|
|
2169
2012
|
var _useState3 = useState(false),
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2013
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2014
|
+
wasPlaying = _useState4[0],
|
|
2015
|
+
setWasPlaying = _useState4[1];
|
|
2174
2016
|
useEffect(function () {
|
|
2175
2017
|
var _ref2 = controlsTheme || {},
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2018
|
+
color = _ref2.color,
|
|
2019
|
+
progressColor = _ref2.progressColor,
|
|
2020
|
+
seekBarOnly = _ref2.seekBarOnly;
|
|
2180
2021
|
setCustomControlsTheme({
|
|
2181
2022
|
color: getColorAsString(color),
|
|
2182
2023
|
progressColor: getColorAsString(progressColor),
|
|
@@ -2185,35 +2026,30 @@ function PlaybackControls(_ref) {
|
|
|
2185
2026
|
}, [controlsTheme, setCustomControlsTheme]);
|
|
2186
2027
|
var onPlay = useCallback(function () {
|
|
2187
2028
|
setPlaying(true);
|
|
2188
|
-
|
|
2189
2029
|
if (!controlsVisible && controls) {
|
|
2190
2030
|
showControls();
|
|
2191
2031
|
}
|
|
2192
2032
|
}, [setPlaying, controlsVisible, showControls]);
|
|
2193
2033
|
var onPause = useCallback(function () {
|
|
2194
2034
|
setPlaying(false);
|
|
2195
|
-
|
|
2196
2035
|
if (!controlsVisible && controls) {
|
|
2197
2036
|
showControls();
|
|
2198
2037
|
}
|
|
2199
2038
|
}, [setPlaying, controlsVisible, controls, showControls]);
|
|
2200
2039
|
var onMute = useCallback(function () {
|
|
2201
2040
|
setMuted(true);
|
|
2202
|
-
|
|
2203
2041
|
if (!controlsVisible && controls) {
|
|
2204
2042
|
showControls();
|
|
2205
2043
|
}
|
|
2206
2044
|
}, [setMuted, controlsVisible, showControls]);
|
|
2207
2045
|
var onUnmute = useCallback(function () {
|
|
2208
2046
|
setMuted(false);
|
|
2209
|
-
|
|
2210
2047
|
if (!controlsVisible && controls) {
|
|
2211
2048
|
showControls();
|
|
2212
2049
|
}
|
|
2213
2050
|
}, [setMuted, controlsVisible, showControls]);
|
|
2214
2051
|
var onSeekStart = useCallback(function () {
|
|
2215
2052
|
setWasPlaying(playing);
|
|
2216
|
-
|
|
2217
2053
|
if (playing) {
|
|
2218
2054
|
setPlaying(false);
|
|
2219
2055
|
}
|
|
@@ -2222,7 +2058,6 @@ function PlaybackControls(_ref) {
|
|
|
2222
2058
|
if (mediaElement !== null) {
|
|
2223
2059
|
mediaElement.currentTime = progress * mediaElement.duration;
|
|
2224
2060
|
}
|
|
2225
|
-
|
|
2226
2061
|
if (!controlsVisible && controls) {
|
|
2227
2062
|
showControls();
|
|
2228
2063
|
}
|
|
@@ -2234,12 +2069,10 @@ function PlaybackControls(_ref) {
|
|
|
2234
2069
|
}, [setPlaying, wasPlaying]);
|
|
2235
2070
|
var hasMedia = mediaElement !== null;
|
|
2236
2071
|
var mediaHasAudio = hasMedia && (hasAudio === null || hasAudio === true);
|
|
2237
|
-
|
|
2238
2072
|
var _ref3 = customControlsTheme || {},
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2073
|
+
color = _ref3.color,
|
|
2074
|
+
progressColor = _ref3.progressColor,
|
|
2075
|
+
seekBarOnly = _ref3.seekBarOnly;
|
|
2243
2076
|
var isCollapsed = controls && !controlsVisible && playing || !controls && mediaHasAudio;
|
|
2244
2077
|
return /*#__PURE__*/React.createElement("div", {
|
|
2245
2078
|
className: classNames([styles$1.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$1.withPlayPause, controls && !seekBarOnly), _defineProperty(_ref4, styles$1.withMute, hasMedia || controls), _defineProperty(_ref4, styles$1.withSeekBar, controls), _defineProperty(_ref4, styles$1.withSeekBarOnly, seekBarOnly), _defineProperty(_ref4, styles$1.isCollapsed, isCollapsed), _defineProperty(_ref4, styles$1.isMuted, muted), _defineProperty(_ref4, collapsedClassName, collapsedClassName !== null && isCollapsed), _ref4)])
|
|
@@ -2368,7 +2201,6 @@ function PlaybackControls(_ref) {
|
|
|
2368
2201
|
withoutBootstrapStyles: true
|
|
2369
2202
|
}));
|
|
2370
2203
|
}
|
|
2371
|
-
|
|
2372
2204
|
PlaybackControls.propTypes = propTypes$4;
|
|
2373
2205
|
PlaybackControls.defaultProps = defaultProps$4;
|
|
2374
2206
|
|
|
@@ -2383,38 +2215,31 @@ var defaultProps$3 = {
|
|
|
2383
2215
|
className: null,
|
|
2384
2216
|
style: null
|
|
2385
2217
|
};
|
|
2386
|
-
|
|
2387
2218
|
function WebViewContainer(_ref) {
|
|
2388
2219
|
var _ref2;
|
|
2389
|
-
|
|
2390
2220
|
var className = _ref.className,
|
|
2391
|
-
|
|
2392
|
-
|
|
2221
|
+
style = _ref.style;
|
|
2393
2222
|
var _useViewerWebView = useViewerWebView(),
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2223
|
+
opened = _useViewerWebView.opened,
|
|
2224
|
+
close = _useViewerWebView.close;
|
|
2225
|
+
_useViewerWebView.open;
|
|
2226
|
+
_useViewerWebView.update;
|
|
2227
|
+
var _useViewerWebView$url = _useViewerWebView.url,
|
|
2228
|
+
url = _useViewerWebView$url === void 0 ? null : _useViewerWebView$url,
|
|
2229
|
+
webViewProps = _objectWithoutProperties(_useViewerWebView, _excluded$2);
|
|
2402
2230
|
var _useViewerInteraction = useViewerInteraction(),
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2231
|
+
disableInteraction = _useViewerInteraction.disableInteraction,
|
|
2232
|
+
enableInteraction = _useViewerInteraction.enableInteraction;
|
|
2406
2233
|
var _usePlaybackContext = usePlaybackContext(),
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2234
|
+
playing = _usePlaybackContext.playing,
|
|
2235
|
+
setPlaying = _usePlaybackContext.setPlaying;
|
|
2410
2236
|
var wasPlayingRef = useRef(playing);
|
|
2411
|
-
|
|
2412
2237
|
var _useState = useState(url),
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2238
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2239
|
+
currentUrl = _useState2[0],
|
|
2240
|
+
setCurrentUrl = _useState2[1];
|
|
2417
2241
|
|
|
2242
|
+
// Handle current webview url
|
|
2418
2243
|
useEffect(function () {
|
|
2419
2244
|
if (url !== null) {
|
|
2420
2245
|
setCurrentUrl(url);
|
|
@@ -2424,19 +2249,18 @@ function WebViewContainer(_ref) {
|
|
|
2424
2249
|
if (url === null) {
|
|
2425
2250
|
setCurrentUrl(null);
|
|
2426
2251
|
}
|
|
2427
|
-
}, [url]);
|
|
2252
|
+
}, [url]);
|
|
2428
2253
|
|
|
2254
|
+
// Disable interaction and pause playback
|
|
2429
2255
|
useEffect(function () {
|
|
2430
2256
|
if (opened) {
|
|
2431
2257
|
disableInteraction();
|
|
2432
2258
|
wasPlayingRef.current = playing;
|
|
2433
|
-
|
|
2434
2259
|
if (playing) {
|
|
2435
2260
|
setPlaying(false);
|
|
2436
2261
|
}
|
|
2437
2262
|
} else {
|
|
2438
2263
|
enableInteraction();
|
|
2439
|
-
|
|
2440
2264
|
if (wasPlayingRef.current && !playing) {
|
|
2441
2265
|
wasPlayingRef.current = false;
|
|
2442
2266
|
setPlaying(true);
|
|
@@ -2455,15 +2279,14 @@ function WebViewContainer(_ref) {
|
|
|
2455
2279
|
onClose: close
|
|
2456
2280
|
})));
|
|
2457
2281
|
}
|
|
2458
|
-
|
|
2459
2282
|
WebViewContainer.propTypes = propTypes$3;
|
|
2460
2283
|
WebViewContainer.defaultProps = defaultProps$3;
|
|
2461
2284
|
|
|
2285
|
+
// @todo export from somewhere else; or use as props in possible component for screen transitions
|
|
2462
2286
|
var SPRING_CONFIG_TIGHT = {
|
|
2463
2287
|
tension: 300,
|
|
2464
2288
|
friction: 35
|
|
2465
2289
|
}; // tight
|
|
2466
|
-
|
|
2467
2290
|
var DRAG_PROGRESS_ACTIVATION_THRESHOLD = 0.3;
|
|
2468
2291
|
var DRAG_VELOCITY_ACTIVATION_THRESHOLD = 0.3;
|
|
2469
2292
|
var DEFAULT_TRANSITION_TYPE_LANDSCAPE = 'carousel';
|
|
@@ -2552,48 +2375,45 @@ var defaultProps$2 = {
|
|
|
2552
2375
|
screenSizeOptions: null,
|
|
2553
2376
|
className: null
|
|
2554
2377
|
};
|
|
2555
|
-
|
|
2556
2378
|
var Viewer = function Viewer(_ref) {
|
|
2557
2379
|
var _ref20;
|
|
2558
|
-
|
|
2559
2380
|
var story = _ref.story,
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2381
|
+
basePath = _ref.basePath,
|
|
2382
|
+
viewerTheme = _ref.theme,
|
|
2383
|
+
width = _ref.width,
|
|
2384
|
+
height = _ref.height,
|
|
2385
|
+
screenId = _ref.screen,
|
|
2386
|
+
screenState = _ref.screenState,
|
|
2387
|
+
deviceScreens = _ref.deviceScreens,
|
|
2388
|
+
renderContext = _ref.renderContext,
|
|
2389
|
+
tapNextScreenWidthPercent = _ref.tapNextScreenWidthPercent,
|
|
2390
|
+
storyIsParsed = _ref.storyIsParsed,
|
|
2391
|
+
neighborScreensActive = _ref.neighborScreensActive,
|
|
2392
|
+
neighborScreenOffset = _ref.neighborScreenOffset,
|
|
2393
|
+
neighborScreenScale = _ref.neighborScreenScale,
|
|
2394
|
+
withMetadata = _ref.withMetadata,
|
|
2395
|
+
withoutGestures = _ref.withoutGestures,
|
|
2396
|
+
withoutMenu = _ref.withoutMenu,
|
|
2397
|
+
withoutScreensMenu = _ref.withoutScreensMenu,
|
|
2398
|
+
withoutShareMenu = _ref.withoutShareMenu,
|
|
2399
|
+
withoutMenuShadow = _ref.withoutMenuShadow;
|
|
2400
|
+
_ref.withoutFullscreen;
|
|
2401
|
+
var withoutNavigationArrow = _ref.withoutNavigationArrow,
|
|
2402
|
+
withoutTransitions = _ref.withoutTransitions,
|
|
2403
|
+
withNeighborScreens = _ref.withNeighborScreens,
|
|
2404
|
+
withNavigationHint = _ref.withNavigationHint,
|
|
2405
|
+
withoutPlaybackControls = _ref.withoutPlaybackControls,
|
|
2406
|
+
menuIsScreenWidth = _ref.menuIsScreenWidth,
|
|
2407
|
+
closeable = _ref.closeable,
|
|
2408
|
+
onCloseViewer = _ref.onClose,
|
|
2409
|
+
onInteraction = _ref.onInteraction,
|
|
2410
|
+
onEnd = _ref.onEnd,
|
|
2411
|
+
onScreenChange = _ref.onScreenChange,
|
|
2412
|
+
onViewModeChange = _ref.onViewModeChange,
|
|
2413
|
+
currentScreenMedia = _ref.currentScreenMedia,
|
|
2414
|
+
screensMedias = _ref.screensMedias,
|
|
2415
|
+
screenSizeOptions = _ref.screenSizeOptions,
|
|
2416
|
+
className = _ref.className;
|
|
2597
2417
|
/**
|
|
2598
2418
|
* Screen Data + Processing
|
|
2599
2419
|
*/
|
|
@@ -2601,13 +2421,13 @@ var Viewer = function Viewer(_ref) {
|
|
|
2601
2421
|
disabled: storyIsParsed
|
|
2602
2422
|
}) || {};
|
|
2603
2423
|
var _parsedStory$componen = parsedStory.components,
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2424
|
+
screens = _parsedStory$componen === void 0 ? [] : _parsedStory$componen,
|
|
2425
|
+
_parsedStory$title = parsedStory.title,
|
|
2426
|
+
title = _parsedStory$title === void 0 ? null : _parsedStory$title,
|
|
2427
|
+
_parsedStory$metadata = parsedStory.metadata,
|
|
2428
|
+
metadata = _parsedStory$metadata === void 0 ? null : _parsedStory$metadata,
|
|
2429
|
+
_parsedStory$fonts = parsedStory.fonts,
|
|
2430
|
+
fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
|
|
2611
2431
|
var screensCount = screens.length;
|
|
2612
2432
|
var eventsManager = useMemo(function () {
|
|
2613
2433
|
return new EventEmitter();
|
|
@@ -2618,19 +2438,15 @@ var Viewer = function Viewer(_ref) {
|
|
|
2618
2438
|
}));
|
|
2619
2439
|
}, [screenId, screens]);
|
|
2620
2440
|
var currentScreen = screens[screenIndex] || null;
|
|
2621
|
-
|
|
2622
2441
|
var _ref2 = currentScreen || {},
|
|
2623
|
-
|
|
2624
|
-
|
|
2442
|
+
screenParameters = _ref2.parameters;
|
|
2625
2443
|
var _ref3 = screenParameters || {},
|
|
2626
|
-
|
|
2627
|
-
|
|
2444
|
+
screenMetadata = _ref3.metadata;
|
|
2628
2445
|
var _ref4 = screenMetadata || {},
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2446
|
+
_ref4$title = _ref4.title,
|
|
2447
|
+
screenTitle = _ref4$title === void 0 ? null : _ref4$title,
|
|
2448
|
+
_ref4$description = _ref4.description,
|
|
2449
|
+
screenDescription = _ref4$description === void 0 ? null : _ref4$description;
|
|
2634
2450
|
var finalTitle = screenTitle !== null ? screenTitle : title;
|
|
2635
2451
|
var finalMetadata = useMemo(function () {
|
|
2636
2452
|
return screenDescription !== null ? _objectSpread(_objectSpread({}, metadata), {}, {
|
|
@@ -2638,84 +2454,71 @@ var Viewer = function Viewer(_ref) {
|
|
|
2638
2454
|
}) : metadata;
|
|
2639
2455
|
}, [metadata, screenDescription]);
|
|
2640
2456
|
var screensMediasRef = useRef([]);
|
|
2641
|
-
|
|
2642
2457
|
if (currentScreenMedia !== null) {
|
|
2643
2458
|
currentScreenMedia.current = screensMediasRef.current[screenIndex] || null;
|
|
2644
2459
|
}
|
|
2645
|
-
|
|
2646
2460
|
if (screensMedias !== null) {
|
|
2647
2461
|
screensMedias.current = screensMediasRef.current;
|
|
2648
2462
|
}
|
|
2463
|
+
|
|
2649
2464
|
/**
|
|
2650
2465
|
* Screen Layout
|
|
2651
2466
|
*/
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
2467
|
var _ref5 = viewerTheme || {},
|
|
2655
|
-
|
|
2656
|
-
|
|
2468
|
+
textStyles = _ref5.textStyles;
|
|
2657
2469
|
var _ref6 = textStyles || {},
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2470
|
+
_ref6$title = _ref6.title,
|
|
2471
|
+
themeTextStyle = _ref6$title === void 0 ? null : _ref6$title;
|
|
2661
2472
|
var _ref7 = themeTextStyle || {},
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2473
|
+
_ref7$fontFamily = _ref7.fontFamily,
|
|
2474
|
+
themeFont = _ref7$fontFamily === void 0 ? null : _ref7$fontFamily;
|
|
2665
2475
|
|
|
2476
|
+
// Fonts
|
|
2666
2477
|
var finalFonts = useMemo(function () {
|
|
2667
2478
|
return [].concat(_toConsumableArray(fonts || []), [themeFont]).filter(function (font) {
|
|
2668
2479
|
return font !== null;
|
|
2669
2480
|
});
|
|
2670
2481
|
}, [fonts]);
|
|
2671
|
-
|
|
2672
2482
|
var _useLoadedFonts = useLoadedFonts(finalFonts);
|
|
2673
|
-
|
|
2674
|
-
|
|
2483
|
+
_useLoadedFonts.loaded; // eslint-disable-line
|
|
2675
2484
|
|
|
2676
2485
|
var isView = renderContext === 'view';
|
|
2677
2486
|
var isStatic = renderContext === 'static';
|
|
2678
2487
|
var isCapture = renderContext === 'capture';
|
|
2679
2488
|
var isEditor = renderContext === 'edit';
|
|
2680
2489
|
var withoutScreensTransforms = isStatic || isCapture;
|
|
2681
|
-
|
|
2682
2490
|
var _usePlaybackContext = usePlaybackContext(),
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2491
|
+
playing = _usePlaybackContext.playing,
|
|
2492
|
+
_usePlaybackContext$c = _usePlaybackContext.controls,
|
|
2493
|
+
playbackControls = _usePlaybackContext$c === void 0 ? false : _usePlaybackContext$c,
|
|
2494
|
+
_usePlaybackContext$c2 = _usePlaybackContext.controlsVisible,
|
|
2495
|
+
playbackcontrolsVisible = _usePlaybackContext$c2 === void 0 ? false : _usePlaybackContext$c2,
|
|
2496
|
+
_usePlaybackContext$m = _usePlaybackContext.media,
|
|
2497
|
+
playbackMedia = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m;
|
|
2691
2498
|
var _useDimensionObserver = useDimensionObserver(),
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2499
|
+
playbackControlsContainerRef = _useDimensionObserver.ref,
|
|
2500
|
+
_useDimensionObserver2 = _useDimensionObserver.height,
|
|
2501
|
+
playbackControlsContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
|
|
2696
2502
|
var trackScreenView = useTrackScreenView();
|
|
2697
|
-
|
|
2698
2503
|
var _useScreenSizeFromEle = useScreenSizeFromElement(_objectSpread({
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2504
|
+
width: width,
|
|
2505
|
+
height: height,
|
|
2506
|
+
screens: deviceScreens
|
|
2507
|
+
}, screenSizeOptions)),
|
|
2508
|
+
containerRef = _useScreenSizeFromEle.ref,
|
|
2509
|
+
viewerWidth = _useScreenSizeFromEle.fullWidth,
|
|
2510
|
+
viewerHeight = _useScreenSizeFromEle.fullHeight,
|
|
2511
|
+
screenSize = _useScreenSizeFromEle.screenSize,
|
|
2512
|
+
screenScale = _useScreenSizeFromEle.scale;
|
|
2709
2513
|
var _ref8 = screenSize || {},
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2514
|
+
_ref8$width = _ref8.width,
|
|
2515
|
+
screenWidth = _ref8$width === void 0 ? null : _ref8$width,
|
|
2516
|
+
_ref8$height = _ref8.height,
|
|
2517
|
+
screenHeight = _ref8$height === void 0 ? null : _ref8$height,
|
|
2518
|
+
_ref8$landscape = _ref8.landscape,
|
|
2519
|
+
landscape = _ref8$landscape === void 0 ? false : _ref8$landscape,
|
|
2520
|
+
_ref8$menuOverScreen = _ref8.menuOverScreen,
|
|
2521
|
+
menuOverScreen = _ref8$menuOverScreen === void 0 ? false : _ref8$menuOverScreen;
|
|
2719
2522
|
var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
|
|
2720
2523
|
var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
|
|
2721
2524
|
var hasSize = screenWidth > 0 && screenHeight > 0;
|
|
@@ -2734,38 +2537,34 @@ var Viewer = function Viewer(_ref) {
|
|
|
2734
2537
|
});
|
|
2735
2538
|
}
|
|
2736
2539
|
}, [ready, landscape, menuOverScreen, onViewModeChange]);
|
|
2540
|
+
|
|
2737
2541
|
/**
|
|
2738
2542
|
* Screen Transitions
|
|
2739
2543
|
*/
|
|
2740
|
-
|
|
2741
2544
|
var transitionType = landscape && withNeighborScreens ? DEFAULT_TRANSITION_TYPE_LANDSCAPE : DEFAULT_TRANSITION_TYPE_PORTRAIT;
|
|
2545
|
+
|
|
2742
2546
|
/**
|
|
2743
2547
|
* Screen Navigation
|
|
2744
2548
|
*/
|
|
2745
|
-
|
|
2746
2549
|
var changeIndex = useCallback(function (index) {
|
|
2747
2550
|
if (index === screenIndex) {
|
|
2748
2551
|
return;
|
|
2749
2552
|
}
|
|
2750
|
-
|
|
2751
2553
|
if (currentScreenMedia !== null) {
|
|
2752
2554
|
currentScreenMedia.current = screensMediasRef.current[index] || null;
|
|
2753
2555
|
}
|
|
2754
|
-
|
|
2755
2556
|
if (onScreenChange !== null) {
|
|
2756
2557
|
onScreenChange(screens[index], index);
|
|
2757
2558
|
}
|
|
2758
2559
|
}, [screenIndex, screens, onScreenChange]);
|
|
2759
2560
|
var onScreenNavigate = useCallback(function (_ref9) {
|
|
2760
2561
|
var index = _ref9.index,
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2562
|
+
newIndex = _ref9.newIndex,
|
|
2563
|
+
end = _ref9.end,
|
|
2564
|
+
direction = _ref9.direction;
|
|
2765
2565
|
if (end && onEnd !== null) {
|
|
2766
2566
|
onEnd();
|
|
2767
2567
|
}
|
|
2768
|
-
|
|
2769
2568
|
changeIndex(newIndex);
|
|
2770
2569
|
eventsManager.emit('navigate', {
|
|
2771
2570
|
index: index,
|
|
@@ -2773,57 +2572,52 @@ var Viewer = function Viewer(_ref) {
|
|
|
2773
2572
|
direction: direction,
|
|
2774
2573
|
end: end
|
|
2775
2574
|
});
|
|
2776
|
-
|
|
2777
2575
|
if (end) {
|
|
2778
2576
|
eventsManager.emit('navigate_end');
|
|
2779
2577
|
} else {
|
|
2780
2578
|
eventsManager.emit("navigate_".concat(direction), newIndex);
|
|
2781
2579
|
}
|
|
2782
2580
|
}, [onEnd, changeIndex]);
|
|
2783
|
-
var gotoPreviousScreen = useCallback(function () {
|
|
2581
|
+
var gotoPreviousScreen = useCallback(function (e) {
|
|
2582
|
+
e.stopPropagation();
|
|
2784
2583
|
changeIndex(Math.max(0, screenIndex - 1));
|
|
2785
2584
|
}, [changeIndex, screenIndex]);
|
|
2786
|
-
var gotoNextScreen = useCallback(function () {
|
|
2585
|
+
var gotoNextScreen = useCallback(function (e) {
|
|
2586
|
+
e.stopPropagation();
|
|
2787
2587
|
changeIndex(Math.min(screens.length - 1, screenIndex + 1));
|
|
2788
2588
|
}, [changeIndex, screenIndex]);
|
|
2789
|
-
|
|
2790
2589
|
var _useState = useState(false),
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2590
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2591
|
+
hasInteracted = _useState2[0],
|
|
2592
|
+
setHasInteracted = _useState2[1];
|
|
2795
2593
|
var onInteractionPrivate = useCallback(function () {
|
|
2796
2594
|
if (onInteraction !== null) {
|
|
2797
2595
|
onInteraction();
|
|
2798
2596
|
}
|
|
2799
|
-
|
|
2800
2597
|
if (!hasInteracted) {
|
|
2801
2598
|
setHasInteracted(true);
|
|
2802
2599
|
}
|
|
2803
2600
|
}, [onInteraction, hasInteracted, setHasInteracted]);
|
|
2804
|
-
|
|
2805
2601
|
var _useScreenInteraction = useScreenInteraction({
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2602
|
+
screens: screens,
|
|
2603
|
+
screenIndex: screenIndex,
|
|
2604
|
+
screenWidth: screenContainerWidth,
|
|
2605
|
+
disableCurrentScreenNavigation: !isView,
|
|
2606
|
+
nextScreenWidthPercent: tapNextScreenWidthPercent,
|
|
2607
|
+
onInteract: onInteractionPrivate,
|
|
2608
|
+
onNavigate: onScreenNavigate
|
|
2609
|
+
}),
|
|
2610
|
+
interactWithScreen = _useScreenInteraction.interact,
|
|
2611
|
+
currentScreenInteractionEnabled = _useScreenInteraction.currentScreenInteractionEnabled,
|
|
2612
|
+
enableInteraction = _useScreenInteraction.enableInteraction,
|
|
2613
|
+
disableInteraction = _useScreenInteraction.disableInteraction;
|
|
2819
2614
|
var onTap = useCallback(function (_ref10) {
|
|
2820
2615
|
var currentTarget = _ref10.currentTarget,
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2616
|
+
event = _ref10.event,
|
|
2617
|
+
target = _ref10.target,
|
|
2618
|
+
_ref10$xy = _slicedToArray(_ref10.xy, 2),
|
|
2619
|
+
x = _ref10$xy[0],
|
|
2620
|
+
y = _ref10$xy[1];
|
|
2827
2621
|
interactWithScreen({
|
|
2828
2622
|
event: event,
|
|
2829
2623
|
target: target,
|
|
@@ -2835,34 +2629,26 @@ var Viewer = function Viewer(_ref) {
|
|
|
2835
2629
|
}, [interactWithScreen, screenIndex]);
|
|
2836
2630
|
var computeScreenProgress = useCallback(function (_ref11) {
|
|
2837
2631
|
var active = _ref11.active,
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2632
|
+
_ref11$movement = _slicedToArray(_ref11.movement, 1),
|
|
2633
|
+
mx = _ref11$movement[0],
|
|
2634
|
+
_ref11$velocity = _slicedToArray(_ref11.velocity, 1),
|
|
2635
|
+
vx = _ref11$velocity[0];
|
|
2843
2636
|
var p = mx / screenContainerWidth; // drag "ratio": how much of the screen width has been swiped?
|
|
2844
|
-
|
|
2845
2637
|
var forwards = mx < 0; // true if swiping to left (to navigate forwards)
|
|
2846
|
-
|
|
2847
2638
|
var newIndex = !forwards ? screenIndex - 1 : screenIndex + 1; // which item index are we moving towards?
|
|
2848
|
-
|
|
2849
2639
|
var reachedThreshold = vx > DRAG_VELOCITY_ACTIVATION_THRESHOLD || Math.abs(p) > DRAG_PROGRESS_ACTIVATION_THRESHOLD;
|
|
2850
2640
|
var reachedBounds = newIndex < 0 || newIndex >= screensCount; // have we reached the end of the stack?
|
|
2851
|
-
|
|
2852
2641
|
var damper = reachedBounds ? 0.1 : 1;
|
|
2853
2642
|
var progress = Math.max(-1, Math.min(1, p * damper));
|
|
2854
|
-
|
|
2855
2643
|
if (!active) {
|
|
2856
2644
|
return reachedThreshold && !reachedBounds ? newIndex : screenIndex;
|
|
2857
2645
|
}
|
|
2858
|
-
|
|
2859
2646
|
return screenIndex - progress;
|
|
2860
2647
|
}, [screenContainerWidth, screenIndex]);
|
|
2861
2648
|
var onScreenProgress = useCallback(function (progress, _ref12) {
|
|
2862
2649
|
var active = _ref12.active;
|
|
2863
2650
|
var delta = Math.abs(progress - screenIndex);
|
|
2864
2651
|
var reachedBounds = progress < 0 || progress >= screensCount; // have we reached the end of the stack?
|
|
2865
|
-
|
|
2866
2652
|
if (!active && delta === 1 && !reachedBounds) {
|
|
2867
2653
|
onScreenNavigate({
|
|
2868
2654
|
index: screenIndex,
|
|
@@ -2870,25 +2656,38 @@ var Viewer = function Viewer(_ref) {
|
|
|
2870
2656
|
});
|
|
2871
2657
|
}
|
|
2872
2658
|
}, [onScreenNavigate, screenIndex]);
|
|
2659
|
+
var _useState3 = useState(true),
|
|
2660
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2661
|
+
transitioned = _useState4[0],
|
|
2662
|
+
setTransitioned = _useState4[1];
|
|
2663
|
+
var onTransitionStart = useCallback(function () {
|
|
2664
|
+
setTransitioned(false);
|
|
2665
|
+
}, [setTransitioned]);
|
|
2666
|
+
var onTransitionComplete = useCallback(function () {
|
|
2667
|
+
setTransitioned(true);
|
|
2668
|
+
}, [setTransitioned]);
|
|
2669
|
+
|
|
2670
|
+
// console.log({ transitioned });
|
|
2671
|
+
|
|
2873
2672
|
var springParams = useMemo(function () {
|
|
2874
2673
|
return {
|
|
2875
|
-
config: SPRING_CONFIG_TIGHT
|
|
2674
|
+
config: SPRING_CONFIG_TIGHT,
|
|
2675
|
+
onStart: onTransitionStart,
|
|
2676
|
+
onRest: onTransitionComplete
|
|
2876
2677
|
};
|
|
2877
|
-
}, []);
|
|
2878
|
-
|
|
2678
|
+
}, [onTransitionStart, onTransitionComplete]);
|
|
2879
2679
|
var _useDragProgress = useDragProgress({
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2680
|
+
progress: screenIndex,
|
|
2681
|
+
disabled: !isView || withoutTransitions,
|
|
2682
|
+
dragDisabled: withoutGestures,
|
|
2683
|
+
computeProgress: computeScreenProgress,
|
|
2684
|
+
onProgress: onScreenProgress,
|
|
2685
|
+
onTap: onTap,
|
|
2686
|
+
springParams: springParams
|
|
2687
|
+
}),
|
|
2688
|
+
isDragging = _useDragProgress.dragging,
|
|
2689
|
+
progressSpring = _useDragProgress.progress,
|
|
2690
|
+
dragContentBind = _useDragProgress.bind;
|
|
2892
2691
|
var getScreenStylesByIndex = function getScreenStylesByIndex(index, spring) {
|
|
2893
2692
|
if (transitionType === 'stack') {
|
|
2894
2693
|
return {
|
|
@@ -2914,7 +2713,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
2914
2713
|
})
|
|
2915
2714
|
};
|
|
2916
2715
|
}
|
|
2917
|
-
|
|
2918
2716
|
return {
|
|
2919
2717
|
opacity: spring.to(function (progress) {
|
|
2920
2718
|
var t = index - progress;
|
|
@@ -2931,19 +2729,18 @@ var Viewer = function Viewer(_ref) {
|
|
|
2931
2729
|
zIndex: screensCount - index
|
|
2932
2730
|
};
|
|
2933
2731
|
};
|
|
2934
|
-
|
|
2935
2732
|
var _useFullscreen = useFullscreen(containerRef.current || null),
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
var
|
|
2733
|
+
toggleFullscreen = _useFullscreen.toggle,
|
|
2734
|
+
fullscreenActive = _useFullscreen.active,
|
|
2735
|
+
fullscreenEnabled = _useFullscreen.enabled;
|
|
2736
|
+
var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
|
|
2737
|
+
var navigationDisabled = currentScreenInteractionEnabled === false;
|
|
2941
2738
|
|
|
2739
|
+
// Get element height
|
|
2942
2740
|
var _useDimensionObserver3 = useDimensionObserver(),
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2741
|
+
menuDotsContainerRef = _useDimensionObserver3.ref,
|
|
2742
|
+
_useDimensionObserver4 = _useDimensionObserver3.height,
|
|
2743
|
+
menuDotsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
|
|
2947
2744
|
var onClickScreen = useCallback(function (_ref13) {
|
|
2948
2745
|
var itemScreenId = _ref13.screenId;
|
|
2949
2746
|
onInteractionPrivate();
|
|
@@ -2958,10 +2755,10 @@ var Viewer = function Viewer(_ref) {
|
|
|
2958
2755
|
e.preventDefault();
|
|
2959
2756
|
return false;
|
|
2960
2757
|
}
|
|
2961
|
-
|
|
2962
2758
|
return true;
|
|
2963
|
-
}, [landscape]);
|
|
2759
|
+
}, [landscape]);
|
|
2964
2760
|
|
|
2761
|
+
// hmm?
|
|
2965
2762
|
var overscrollStyle = /*#__PURE__*/React.createElement("style", {
|
|
2966
2763
|
type: "text/css"
|
|
2967
2764
|
}, "body { overscroll-behavior: contain; }");
|
|
@@ -2984,46 +2781,36 @@ var Viewer = function Viewer(_ref) {
|
|
|
2984
2781
|
useKeyboardShortcuts(keyboardShortcuts, {
|
|
2985
2782
|
disabled: renderContext !== 'view'
|
|
2986
2783
|
});
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
shareIncentiveVisible = _useState6[0],
|
|
2996
|
-
setShareIncentiveVisible = _useState6[1];
|
|
2997
|
-
|
|
2784
|
+
var _useState5 = useState(null),
|
|
2785
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2786
|
+
currentShareIncentive = _useState6[0],
|
|
2787
|
+
setCurrentShareIncentive = _useState6[1];
|
|
2788
|
+
var _useState7 = useState(false),
|
|
2789
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2790
|
+
shareIncentiveVisible = _useState8[0],
|
|
2791
|
+
setShareIncentiveVisible = _useState8[1];
|
|
2998
2792
|
var _ref15 = currentScreen || {},
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2793
|
+
_ref15$shareIncentive = _ref15.shareIncentive,
|
|
2794
|
+
shareIncentive = _ref15$shareIncentive === void 0 ? null : _ref15$shareIncentive;
|
|
3002
2795
|
var _ref16 = shareIncentive || {},
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
2796
|
+
_ref16$active = _ref16.active,
|
|
2797
|
+
hasShareIncentive = _ref16$active === void 0 ? false : _ref16$active,
|
|
2798
|
+
_ref16$label = _ref16.label,
|
|
2799
|
+
shareIncentiveLabel = _ref16$label === void 0 ? null : _ref16$label;
|
|
3008
2800
|
var _ref17 = currentShareIncentive || {},
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
2801
|
+
_ref17$label = _ref17.label,
|
|
2802
|
+
currentShareIncentiveLabel = _ref17$label === void 0 ? null : _ref17$label;
|
|
3012
2803
|
var _ref18 = shareIncentiveLabel || {},
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
2804
|
+
_ref18$body = _ref18.body,
|
|
2805
|
+
incentiveLabel = _ref18$body === void 0 ? null : _ref18$body;
|
|
3016
2806
|
var _ref19 = currentShareIncentiveLabel || {},
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
2807
|
+
_ref19$body = _ref19.body,
|
|
2808
|
+
currentIncentiveLabel = _ref19$body === void 0 ? null : _ref19$body;
|
|
3020
2809
|
useEffect(function () {
|
|
3021
2810
|
setShareIncentiveVisible(true);
|
|
3022
|
-
|
|
3023
2811
|
if (hasShareIncentive && shareIncentiveLabel !== currentShareIncentiveLabel) {
|
|
3024
2812
|
setCurrentShareIncentive(shareIncentive);
|
|
3025
2813
|
}
|
|
3026
|
-
|
|
3027
2814
|
var timeout = setTimeout(function () {
|
|
3028
2815
|
if (isView) {
|
|
3029
2816
|
setShareIncentiveVisible(false);
|
|
@@ -3059,7 +2846,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3059
2846
|
}), /*#__PURE__*/React.createElement("div", {
|
|
3060
2847
|
className: classNames([styles$6.container, screenSize.screens.map(function (screenName) {
|
|
3061
2848
|
return "story-screen-".concat(screenName);
|
|
3062
|
-
}), (_ref20 = {}, _defineProperty(_ref20, styles$6.landscape, landscape), _defineProperty(_ref20, styles$6.withoutGestures, withoutGestures), _defineProperty(_ref20, styles$6.hideMenu, !menuVisible), _defineProperty(_ref20, styles$6.fadeMenu, playing && playbackControls && !playbackcontrolsVisible), _defineProperty(_ref20, styles$6.ready, ready || withoutScreensTransforms), _defineProperty(_ref20, styles$6.hasInteracted, hasInteracted), _defineProperty(_ref20, styles$6.isDragging, isDragging), _defineProperty(_ref20, className, className), _ref20)]),
|
|
2849
|
+
}), (_ref20 = {}, _defineProperty(_ref20, styles$6.landscape, landscape), _defineProperty(_ref20, styles$6.withoutGestures, withoutGestures), _defineProperty(_ref20, styles$6.hideMenu, !menuVisible), _defineProperty(_ref20, styles$6.disableMenu, navigationDisabled), _defineProperty(_ref20, styles$6.fadeMenu, playing && playbackControls && !playbackcontrolsVisible), _defineProperty(_ref20, styles$6.ready, ready || withoutScreensTransforms), _defineProperty(_ref20, styles$6.hasInteracted, hasInteracted), _defineProperty(_ref20, styles$6.isDragging, isDragging), _defineProperty(_ref20, className, className), _ref20)]),
|
|
3063
2850
|
ref: containerRef,
|
|
3064
2851
|
onContextMenu: onContextMenu
|
|
3065
2852
|
}, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu$1, {
|
|
@@ -3083,7 +2870,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3083
2870
|
refDots: menuDotsContainerRef
|
|
3084
2871
|
}) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", Object.assign({
|
|
3085
2872
|
className: styles$6.content
|
|
3086
|
-
}, dragContentBind()), !withoutNavigationArrow && !withNeighborScreens && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
|
|
2873
|
+
}, dragContentBind()), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
|
|
3087
2874
|
direction: "previous",
|
|
3088
2875
|
className: classNames([styles$6.navButton, styles$6.previous]),
|
|
3089
2876
|
onClick: gotoPreviousScreen
|
|
@@ -3109,6 +2896,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3109
2896
|
index: i,
|
|
3110
2897
|
current: current,
|
|
3111
2898
|
active: active,
|
|
2899
|
+
ready: current && transitioned,
|
|
3112
2900
|
mediaRef: function mediaRef(ref) {
|
|
3113
2901
|
screensMediasRef.current[i] = ref;
|
|
3114
2902
|
},
|
|
@@ -3117,7 +2905,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3117
2905
|
height: screenHeight,
|
|
3118
2906
|
scale: screenScale
|
|
3119
2907
|
}) : null);
|
|
3120
|
-
})), !withoutNavigationArrow && !withNeighborScreens && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
|
|
2908
|
+
})), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
|
|
3121
2909
|
direction: "next",
|
|
3122
2910
|
className: classNames([styles$6.navButton, styles$6.next]),
|
|
3123
2911
|
onClick: gotoNextScreen
|
|
@@ -3126,7 +2914,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3126
2914
|
ref: playbackControlsContainerRef
|
|
3127
2915
|
}, /*#__PURE__*/React.createElement(PlaybackControls, {
|
|
3128
2916
|
className: styles$6.controls
|
|
3129
|
-
})) : null, withNavigationHint && !withNeighborScreens && screenIndex === 0 && !hasInteracted ? /*#__PURE__*/React.createElement(ArrowHint, {
|
|
2917
|
+
})) : null, withNavigationHint && !withNeighborScreens && !navigationDisabled && screenIndex === 0 && !hasInteracted ? /*#__PURE__*/React.createElement(ArrowHint, {
|
|
3130
2918
|
className: styles$6.arrowHint
|
|
3131
2919
|
}) : null) : null, /*#__PURE__*/React.createElement("div", {
|
|
3132
2920
|
className: classNames([styles$6.shareIncentiveContainer, _defineProperty({}, styles$6.shareIncentiveVisible, hasShareIncentive && shareIncentiveVisible)]),
|
|
@@ -3142,7 +2930,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
3142
2930
|
}
|
|
3143
2931
|
})))));
|
|
3144
2932
|
};
|
|
3145
|
-
|
|
3146
2933
|
Viewer.propTypes = propTypes$2;
|
|
3147
2934
|
Viewer.defaultProps = defaultProps$2;
|
|
3148
2935
|
|
|
@@ -3160,21 +2947,17 @@ var defaultProps$1 = {
|
|
|
3160
2947
|
children: null,
|
|
3161
2948
|
onScreenChange: null
|
|
3162
2949
|
};
|
|
3163
|
-
|
|
3164
2950
|
var ViewerRoutes = function ViewerRoutes(_ref) {
|
|
3165
2951
|
var story = _ref.story,
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
2952
|
+
pathWithIndex = _ref.pathWithIndex;
|
|
2953
|
+
_ref.children;
|
|
2954
|
+
var onScreenChange = _ref.onScreenChange,
|
|
2955
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
3171
2956
|
var routes = useRoutes();
|
|
3172
2957
|
var push = useRoutePush();
|
|
3173
|
-
|
|
3174
2958
|
var _ref2 = story || {},
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
2959
|
+
_ref2$components = _ref2.components,
|
|
2960
|
+
screens = _ref2$components === void 0 ? [] : _ref2$components;
|
|
3178
2961
|
var finalOnScreenChange = useCallback(function (it) {
|
|
3179
2962
|
var screenIndex = screens.findIndex(function (screen) {
|
|
3180
2963
|
var screenId = screen.id;
|
|
@@ -3183,7 +2966,6 @@ var ViewerRoutes = function ViewerRoutes(_ref) {
|
|
|
3183
2966
|
push('screen', {
|
|
3184
2967
|
screen: pathWithIndex ? screenIndex + 1 : it.id
|
|
3185
2968
|
});
|
|
3186
|
-
|
|
3187
2969
|
if (onScreenChange !== null) {
|
|
3188
2970
|
onScreenChange(it);
|
|
3189
2971
|
}
|
|
@@ -3201,7 +2983,7 @@ var ViewerRoutes = function ViewerRoutes(_ref) {
|
|
|
3201
2983
|
path: routes.screen,
|
|
3202
2984
|
render: function render(_ref3) {
|
|
3203
2985
|
var _ref3$match$params$sc = _ref3.match.params.screen,
|
|
3204
|
-
|
|
2986
|
+
screenParam = _ref3$match$params$sc === void 0 ? null : _ref3$match$params$sc;
|
|
3205
2987
|
var screenFromIndex = pathWithIndex && screenParam !== null ? screens[parseInt(screenParam, 10) - 1] || null : null;
|
|
3206
2988
|
var screenId = pathWithIndex ? (screenFromIndex || {}).id || null : screenParam;
|
|
3207
2989
|
return /*#__PURE__*/React.createElement(Viewer, Object.assign({}, otherProps, {
|
|
@@ -3212,7 +2994,6 @@ var ViewerRoutes = function ViewerRoutes(_ref) {
|
|
|
3212
2994
|
}
|
|
3213
2995
|
}));
|
|
3214
2996
|
};
|
|
3215
|
-
|
|
3216
2997
|
ViewerRoutes.propTypes = propTypes$1;
|
|
3217
2998
|
ViewerRoutes.defaultProps = defaultProps$1;
|
|
3218
2999
|
|
|
@@ -3260,38 +3041,35 @@ var defaultProps = {
|
|
|
3260
3041
|
pathWithIndex: false,
|
|
3261
3042
|
children: null
|
|
3262
3043
|
};
|
|
3263
|
-
|
|
3264
3044
|
var ViewerContainer = function ViewerContainer(_ref) {
|
|
3265
3045
|
var story = _ref.story,
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3046
|
+
paused = _ref.paused,
|
|
3047
|
+
screenComponents = _ref.screenComponents,
|
|
3048
|
+
memoryRouter = _ref.memoryRouter,
|
|
3049
|
+
basePath = _ref.basePath,
|
|
3050
|
+
routes = _ref.routes,
|
|
3051
|
+
withoutRouter = _ref.withoutRouter,
|
|
3052
|
+
googleApiKey = _ref.googleApiKey,
|
|
3053
|
+
visitor = _ref.visitor,
|
|
3054
|
+
trackingVariables = _ref.trackingVariables,
|
|
3055
|
+
locale = _ref.locale,
|
|
3056
|
+
locales = _ref.locales,
|
|
3057
|
+
translations = _ref.translations,
|
|
3058
|
+
pathWithIndex = _ref.pathWithIndex,
|
|
3059
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
3281
3060
|
var Router = memoryRouter ? MemoryRouter : BrowserRouter;
|
|
3282
3061
|
var finalTrackingVariables = useMemo(function () {
|
|
3283
3062
|
if (story === null && trackingVariables === null) {
|
|
3284
3063
|
return null;
|
|
3285
3064
|
}
|
|
3286
|
-
|
|
3287
3065
|
var _story$id = story.id,
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3066
|
+
id = _story$id === void 0 ? null : _story$id,
|
|
3067
|
+
_story$slug = story.slug,
|
|
3068
|
+
slug = _story$slug === void 0 ? null : _story$slug,
|
|
3069
|
+
_story$title = story.title,
|
|
3070
|
+
title = _story$title === void 0 ? null : _story$title,
|
|
3071
|
+
_story$components = story.components,
|
|
3072
|
+
components = _story$components === void 0 ? [] : _story$components;
|
|
3295
3073
|
return _objectSpread({
|
|
3296
3074
|
storyId: id,
|
|
3297
3075
|
storySlug: slug,
|
|
@@ -3299,14 +3077,11 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
3299
3077
|
screensCount: (components || []).length
|
|
3300
3078
|
}, trackingVariables);
|
|
3301
3079
|
}, [story, trackingVariables]);
|
|
3302
|
-
|
|
3303
3080
|
var _ref2 = story || {},
|
|
3304
|
-
|
|
3305
|
-
|
|
3081
|
+
metadata = _ref2.metadata;
|
|
3306
3082
|
var _ref3 = metadata || {},
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3083
|
+
_ref3$language = _ref3.language,
|
|
3084
|
+
finalLocale = _ref3$language === void 0 ? locale : _ref3$language;
|
|
3310
3085
|
var content = /*#__PURE__*/React.createElement(IntlProvider, {
|
|
3311
3086
|
locale: finalLocale,
|
|
3312
3087
|
locales: locales,
|
|
@@ -3340,7 +3115,6 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
3340
3115
|
routes: routes
|
|
3341
3116
|
}, content));
|
|
3342
3117
|
};
|
|
3343
|
-
|
|
3344
3118
|
ViewerContainer.propTypes = propTypes;
|
|
3345
3119
|
ViewerContainer.defaultProps = defaultProps;
|
|
3346
3120
|
|