@micromag/viewer 0.3.779 → 0.3.783
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +30 -13
- package/package.json +10 -10
package/es/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { Helmet } from 'react-helmet';
|
|
|
19
19
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
20
20
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
21
21
|
import { Label, CloseIcon, ScreenPreview, Screen, ArrowIcon, Button as Button$1, PlayIcon, Spinner, UnmuteIcon, MuteIcon, PauseIcon, Meta, FontFaces } from '@micromag/core/components';
|
|
22
|
-
import { useIsVisible, useDimensionObserver, useTrackEvent, useDragProgress, useMediaProgress, useMediaCurrentTime, useMediaDuration, useMediaReady, useMediaState, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
|
|
22
|
+
import { useIsVisible, useDimensionObserver, useTrackEvent, useDragProgress, useMediaProgress, useMediaCurrentTime, useMediaDuration, useMediaReady, useMediaState, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen, useActivityDetector } from '@micromag/core/hooks';
|
|
23
23
|
import { getStyleFromColor, easings, getStyleFromText, getColorAsString, getDeviceScreens } from '@micromag/core/utils';
|
|
24
24
|
import { ShareIncentive } from '@micromag/elements/all';
|
|
25
25
|
import FocusLock from 'react-focus-lock';
|
|
@@ -1323,6 +1323,7 @@ var propTypes$c = {
|
|
|
1323
1323
|
title: PropTypes.string,
|
|
1324
1324
|
description: PropTypes.string,
|
|
1325
1325
|
items: PropTypes$1.menuItems,
|
|
1326
|
+
shareOptions: PropTypes.arrayOf(PropTypes.string),
|
|
1326
1327
|
focusable: PropTypes.bool,
|
|
1327
1328
|
paddingTop: PropTypes.number,
|
|
1328
1329
|
currentScreenIndex: PropTypes.number,
|
|
@@ -1336,6 +1337,7 @@ var defaultProps$c = {
|
|
|
1336
1337
|
title: null,
|
|
1337
1338
|
description: null,
|
|
1338
1339
|
items: [],
|
|
1340
|
+
shareOptions: null,
|
|
1339
1341
|
focusable: true,
|
|
1340
1342
|
paddingTop: null,
|
|
1341
1343
|
currentScreenIndex: 0,
|
|
@@ -1349,6 +1351,7 @@ var ViewerMenuShare = function ViewerMenuShare(_ref) {
|
|
|
1349
1351
|
title = _ref.title,
|
|
1350
1352
|
description = _ref.description,
|
|
1351
1353
|
items = _ref.items,
|
|
1354
|
+
shareOptions = _ref.shareOptions,
|
|
1352
1355
|
focusable = _ref.focusable,
|
|
1353
1356
|
paddingTop = _ref.paddingTop,
|
|
1354
1357
|
currentScreenIndex = _ref.currentScreenIndex,
|
|
@@ -1440,6 +1443,7 @@ var ViewerMenuShare = function ViewerMenuShare(_ref) {
|
|
|
1440
1443
|
itemClassName: styles$8.optionItem,
|
|
1441
1444
|
buttonClassName: styles$8.optionButton,
|
|
1442
1445
|
title: title,
|
|
1446
|
+
options: shareOptions,
|
|
1443
1447
|
url: finalShareUrl,
|
|
1444
1448
|
focusable: focusable,
|
|
1445
1449
|
onShare: onShare,
|
|
@@ -1464,6 +1468,7 @@ var propTypes$b = {
|
|
|
1464
1468
|
withShadow: PropTypes.bool,
|
|
1465
1469
|
trackingEnabled: PropTypes.bool,
|
|
1466
1470
|
shareBasePath: PropTypes.string,
|
|
1471
|
+
shareOptions: PropTypes.arrayOf(PropTypes.string),
|
|
1467
1472
|
theme: PropTypes$1.viewerTheme,
|
|
1468
1473
|
screenSize: PropTypes$1.screenSize,
|
|
1469
1474
|
menuWidth: PropTypes.number,
|
|
@@ -1494,6 +1499,7 @@ var defaultProps$b = {
|
|
|
1494
1499
|
withShadow: false,
|
|
1495
1500
|
trackingEnabled: false,
|
|
1496
1501
|
shareBasePath: null,
|
|
1502
|
+
shareOptions: null,
|
|
1497
1503
|
theme: null,
|
|
1498
1504
|
screenSize: null,
|
|
1499
1505
|
menuWidth: null,
|
|
@@ -1522,6 +1528,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1522
1528
|
closeable = _ref.closeable,
|
|
1523
1529
|
withShadow = _ref.withShadow,
|
|
1524
1530
|
shareBasePath = _ref.shareBasePath,
|
|
1531
|
+
shareOptions = _ref.shareOptions,
|
|
1525
1532
|
trackingEnabled = _ref.trackingEnabled,
|
|
1526
1533
|
viewerTheme = _ref.theme,
|
|
1527
1534
|
screenSize = _ref.screenSize,
|
|
@@ -1879,6 +1886,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1879
1886
|
paddingTop: navContainerHeight,
|
|
1880
1887
|
focusable: shareOpened,
|
|
1881
1888
|
items: items,
|
|
1889
|
+
shareOptions: shareOptions,
|
|
1882
1890
|
currentScreenIndex: currentScreenIndex,
|
|
1883
1891
|
shareUrl: shareUrl,
|
|
1884
1892
|
onShare: onShare,
|
|
@@ -2766,6 +2774,7 @@ var propTypes$2 = {
|
|
|
2766
2774
|
menuFooter: PropTypes.node,
|
|
2767
2775
|
menuItems: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.node])),
|
|
2768
2776
|
shareBasePath: PropTypes.string,
|
|
2777
|
+
shareOptions: PropTypes.arrayOf(PropTypes.string),
|
|
2769
2778
|
afterShareMenuButton: PropTypes.node,
|
|
2770
2779
|
beforeScreensMenuButton: PropTypes.node,
|
|
2771
2780
|
backToFirstScreenTimeout: PropTypes.number,
|
|
@@ -2826,6 +2835,7 @@ var defaultProps$2 = {
|
|
|
2826
2835
|
menuFooter: null,
|
|
2827
2836
|
menuItems: ['share', 'main'],
|
|
2828
2837
|
shareBasePath: null,
|
|
2838
|
+
shareOptions: null,
|
|
2829
2839
|
afterShareMenuButton: null,
|
|
2830
2840
|
beforeScreensMenuButton: null,
|
|
2831
2841
|
backToFirstScreenTimeout: null,
|
|
@@ -2882,6 +2892,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
2882
2892
|
menuFooter = _ref.menuFooter,
|
|
2883
2893
|
menuItems = _ref.menuItems,
|
|
2884
2894
|
shareBasePath = _ref.shareBasePath,
|
|
2895
|
+
shareOptions = _ref.shareOptions,
|
|
2885
2896
|
afterShareMenuButton = _ref.afterShareMenuButton,
|
|
2886
2897
|
beforeScreensMenuButton = _ref.beforeScreensMenuButton,
|
|
2887
2898
|
backToFirstScreenTimeout = _ref.backToFirstScreenTimeout,
|
|
@@ -3004,7 +3015,9 @@ var Viewer = function Viewer(_ref) {
|
|
|
3004
3015
|
_usePlaybackContext$m = _usePlaybackContext.media,
|
|
3005
3016
|
playbackMedia = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m,
|
|
3006
3017
|
_usePlaybackContext$c3 = _usePlaybackContext.completed,
|
|
3007
|
-
mediaCompleted = _usePlaybackContext$c3 === void 0 ? false : _usePlaybackContext$c3
|
|
3018
|
+
mediaCompleted = _usePlaybackContext$c3 === void 0 ? false : _usePlaybackContext$c3,
|
|
3019
|
+
_usePlaybackContext$i = _usePlaybackContext.isBackground,
|
|
3020
|
+
isBackgroundVideo = _usePlaybackContext$i === void 0 ? false : _usePlaybackContext$i;
|
|
3008
3021
|
var playbackHelpVisible = useMemo(function () {
|
|
3009
3022
|
return playbackControls && playbackControlsVisible;
|
|
3010
3023
|
}, [playbackControls, playbackControlsVisible]);
|
|
@@ -3261,13 +3274,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
3261
3274
|
}, [onTransitionStart, onTransitionComplete]);
|
|
3262
3275
|
var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
|
|
3263
3276
|
var navigationDisabled = currentScreenInteractionEnabled === false;
|
|
3264
|
-
|
|
3265
|
-
// console.log(
|
|
3266
|
-
// 'currentScreenInteractionEnabled',
|
|
3267
|
-
// currentScreenInteractionEnabled,
|
|
3268
|
-
// withoutGestures,
|
|
3269
|
-
// );
|
|
3270
|
-
|
|
3271
3277
|
var _useDragProgress = useDragProgress({
|
|
3272
3278
|
progress: screenIndex,
|
|
3273
3279
|
disabled: !isView || withoutTransitions,
|
|
@@ -3474,10 +3480,17 @@ var Viewer = function Viewer(_ref) {
|
|
|
3474
3480
|
bottomHeight = playbackControlsContainerHeight / screenScale;
|
|
3475
3481
|
}
|
|
3476
3482
|
var NavigationHint = withNavigationHint === 'hand' ? HandTap : ArrowHint;
|
|
3483
|
+
var _useActivityDetector = useActivityDetector({
|
|
3484
|
+
element: containerRef.current,
|
|
3485
|
+
disabled: !isView,
|
|
3486
|
+
timeout: 2000
|
|
3487
|
+
}),
|
|
3488
|
+
activityDetected = _useActivityDetector.detected;
|
|
3477
3489
|
useEffect(function () {
|
|
3478
3490
|
var timeout = null;
|
|
3479
|
-
|
|
3480
|
-
|
|
3491
|
+
// const looping = playbackMedia !== null ? playbackMedia.loop || false : false;
|
|
3492
|
+
var hasMediaCompleted = playbackMedia !== null && !isBackgroundVideo ? mediaCompleted : true;
|
|
3493
|
+
if (backToFirstScreenTimeout !== null && isView && screensCount > 1 && screenIndex !== 0 && hasMediaCompleted && !isDragging && !activityDetected) {
|
|
3481
3494
|
timeout = setTimeout(function () {
|
|
3482
3495
|
changeIndex(0);
|
|
3483
3496
|
}, backToFirstScreenTimeout);
|
|
@@ -3487,8 +3500,11 @@ var Viewer = function Viewer(_ref) {
|
|
|
3487
3500
|
clearTimeout(timeout);
|
|
3488
3501
|
}
|
|
3489
3502
|
};
|
|
3490
|
-
}, [backToFirstScreenTimeout, isView, screenIndex, screensCount, changeIndex, playbackMedia, mediaCompleted, isDragging]);
|
|
3491
|
-
|
|
3503
|
+
}, [backToFirstScreenTimeout, isView, screenIndex, screensCount, changeIndex, playbackMedia, mediaCompleted, isDragging, activityDetected, isBackgroundVideo]);
|
|
3504
|
+
|
|
3505
|
+
// console.log('mediaCompleted', mediaCompleted, playbackMedia);
|
|
3506
|
+
// console.log('activityDetected', activityDetected);
|
|
3507
|
+
|
|
3492
3508
|
return /*#__PURE__*/React.createElement(StoryProvider, {
|
|
3493
3509
|
story: parsedStory
|
|
3494
3510
|
}, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
|
|
@@ -3583,6 +3599,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
3583
3599
|
menuDotsButtons: menuDotsButtons,
|
|
3584
3600
|
closeable: closeable,
|
|
3585
3601
|
shareBasePath: shareBasePath || basePath,
|
|
3602
|
+
shareOptions: shareOptions,
|
|
3586
3603
|
screenSize: screenSize,
|
|
3587
3604
|
menuWidth: menuIsScreenWidth ? screenContainerWidth : null,
|
|
3588
3605
|
theme: viewerTheme,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/viewer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.783",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@babel/runtime": "^7.13.10",
|
|
66
66
|
"@folklore/routes": "^0.2.36",
|
|
67
|
-
"@micromag/core": "^0.3.
|
|
68
|
-
"@micromag/element-badge": "^0.3.
|
|
69
|
-
"@micromag/element-scroll": "^0.3.
|
|
70
|
-
"@micromag/element-share-options": "^0.3.
|
|
71
|
-
"@micromag/element-webview": "^0.3.
|
|
72
|
-
"@micromag/elements": "^0.3.
|
|
73
|
-
"@micromag/intl": "^0.3.
|
|
74
|
-
"@micromag/screens": "^0.3.
|
|
67
|
+
"@micromag/core": "^0.3.781",
|
|
68
|
+
"@micromag/element-badge": "^0.3.781",
|
|
69
|
+
"@micromag/element-scroll": "^0.3.781",
|
|
70
|
+
"@micromag/element-share-options": "^0.3.783",
|
|
71
|
+
"@micromag/element-webview": "^0.3.781",
|
|
72
|
+
"@micromag/elements": "^0.3.783",
|
|
73
|
+
"@micromag/intl": "^0.3.781",
|
|
74
|
+
"@micromag/screens": "^0.3.783",
|
|
75
75
|
"@react-spring/core": "^9.6.1",
|
|
76
76
|
"@react-spring/web": "^9.6.1",
|
|
77
77
|
"@use-gesture/react": "^10.3.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"access": "public",
|
|
92
92
|
"registry": "https://registry.npmjs.org/"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "e79f1240a3d905de33eb3dd873b772c11b6ebdb0"
|
|
95
95
|
}
|