@micromag/viewer 0.2.378 → 0.2.382
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 +37 -9
- package/lib/index.js +37 -9
- package/package.json +8 -8
package/es/index.js
CHANGED
|
@@ -41,7 +41,8 @@ var propTypes$8 = {
|
|
|
41
41
|
onPrevious: PropTypes.func,
|
|
42
42
|
onNext: PropTypes.func,
|
|
43
43
|
onEnableInteraction: PropTypes.func,
|
|
44
|
-
onDisableInteraction: PropTypes.func
|
|
44
|
+
onDisableInteraction: PropTypes.func,
|
|
45
|
+
getMediaRef: PropTypes.func
|
|
45
46
|
};
|
|
46
47
|
var defaultProps$8 = {
|
|
47
48
|
screen: null,
|
|
@@ -51,7 +52,8 @@ var defaultProps$8 = {
|
|
|
51
52
|
onPrevious: null,
|
|
52
53
|
onNext: null,
|
|
53
54
|
onEnableInteraction: null,
|
|
54
|
-
onDisableInteraction: null
|
|
55
|
+
onDisableInteraction: null,
|
|
56
|
+
getMediaRef: null
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
var ViewerScreen = function ViewerScreen(_ref) {
|
|
@@ -64,7 +66,8 @@ var ViewerScreen = function ViewerScreen(_ref) {
|
|
|
64
66
|
onPrevious = _ref.onPrevious,
|
|
65
67
|
onNext = _ref.onNext,
|
|
66
68
|
onEnableInteraction = _ref.onEnableInteraction,
|
|
67
|
-
onDisableInteraction = _ref.onDisableInteraction
|
|
69
|
+
onDisableInteraction = _ref.onDisableInteraction,
|
|
70
|
+
getMediaRef = _ref.getMediaRef;
|
|
68
71
|
return screen !== null ? /*#__PURE__*/React.createElement("div", {
|
|
69
72
|
className: classNames([styles$6.container, (_ref2 = {}, _defineProperty(_ref2, styles$6.active, active), _defineProperty(_ref2, styles$6.current, current), _ref2)]),
|
|
70
73
|
"aria-hidden": current ? null : 'true'
|
|
@@ -76,7 +79,8 @@ var ViewerScreen = function ViewerScreen(_ref) {
|
|
|
76
79
|
onPrevious: onPrevious,
|
|
77
80
|
onNext: onNext,
|
|
78
81
|
onEnableInteraction: onEnableInteraction,
|
|
79
|
-
onDisableInteraction: onDisableInteraction
|
|
82
|
+
onDisableInteraction: onDisableInteraction,
|
|
83
|
+
getMediaRef: getMediaRef
|
|
80
84
|
})) : null;
|
|
81
85
|
};
|
|
82
86
|
|
|
@@ -773,6 +777,8 @@ var propTypes$2 = {
|
|
|
773
777
|
onInteraction: PropTypes.func,
|
|
774
778
|
onEnd: PropTypes.func,
|
|
775
779
|
onViewModeChange: PropTypes.func,
|
|
780
|
+
currentScreenMedia: PropTypes$1.ref,
|
|
781
|
+
screensMedias: PropTypes$1.ref,
|
|
776
782
|
className: PropTypes.string
|
|
777
783
|
};
|
|
778
784
|
var defaultProps$2 = {
|
|
@@ -797,6 +803,8 @@ var defaultProps$2 = {
|
|
|
797
803
|
onInteraction: null,
|
|
798
804
|
onEnd: null,
|
|
799
805
|
onViewModeChange: null,
|
|
806
|
+
currentScreenMedia: null,
|
|
807
|
+
screensMedias: null,
|
|
800
808
|
className: null
|
|
801
809
|
};
|
|
802
810
|
|
|
@@ -824,6 +832,8 @@ var Viewer = function Viewer(_ref) {
|
|
|
824
832
|
onInteraction = _ref.onInteraction,
|
|
825
833
|
onEnd = _ref.onEnd,
|
|
826
834
|
onViewModeChange = _ref.onViewModeChange,
|
|
835
|
+
currentScreenMedia = _ref.currentScreenMedia,
|
|
836
|
+
screensMedias = _ref.screensMedias,
|
|
827
837
|
className = _ref.className;
|
|
828
838
|
var intl = useIntl();
|
|
829
839
|
var parsedStory = useParsedStory(story, {
|
|
@@ -892,7 +902,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
892
902
|
menuOverScreen = _ref5$menuOverScreen === void 0 ? false : _ref5$menuOverScreen;
|
|
893
903
|
|
|
894
904
|
var hasSize = screenWidth > 0 && screenHeight > 0;
|
|
895
|
-
var ready = hasSize; // && fontsLoaded;
|
|
905
|
+
var ready = hasSize; // && fontsLoaded;
|
|
896
906
|
|
|
897
907
|
useEffect(function () {
|
|
898
908
|
if (ready && onViewModeChange !== null) {
|
|
@@ -917,19 +927,33 @@ var Viewer = function Viewer(_ref) {
|
|
|
917
927
|
|
|
918
928
|
var _ref7 = menuPreviewContainerRect || {},
|
|
919
929
|
_ref7$height = _ref7.height,
|
|
920
|
-
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
930
|
+
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
921
931
|
|
|
932
|
+
var screensMediasRef = useRef([]); // Screen index
|
|
922
933
|
|
|
923
934
|
var screenIndex = useMemo(function () {
|
|
924
935
|
return Math.max(0, screens.findIndex(function (it) {
|
|
925
936
|
return String(it.id) === String(screenId);
|
|
926
937
|
}));
|
|
927
938
|
}, [screenId, screens]);
|
|
939
|
+
|
|
940
|
+
if (currentScreenMedia !== null) {
|
|
941
|
+
currentScreenMedia.current = screensMediasRef.current[screenIndex];
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
if (screensMedias !== null) {
|
|
945
|
+
screensMedias.current = screensMediasRef.current;
|
|
946
|
+
}
|
|
947
|
+
|
|
928
948
|
var changeIndex = useCallback(function (index) {
|
|
929
949
|
if (index === screenIndex) {
|
|
930
950
|
return;
|
|
931
951
|
}
|
|
932
952
|
|
|
953
|
+
if (currentScreenMedia !== null) {
|
|
954
|
+
currentScreenMedia.current = screensMediasRef.current[index];
|
|
955
|
+
}
|
|
956
|
+
|
|
933
957
|
if (onScreenChange !== null) {
|
|
934
958
|
onScreenChange(screens[index], index);
|
|
935
959
|
}
|
|
@@ -1346,11 +1370,16 @@ var Viewer = function Viewer(_ref) {
|
|
|
1346
1370
|
onPrevious: onScreenPrevious,
|
|
1347
1371
|
onNext: onScreenNext,
|
|
1348
1372
|
onEnableInteraction: onEnableInteraction,
|
|
1349
|
-
onDisableInteraction: onDisableInteraction
|
|
1373
|
+
onDisableInteraction: onDisableInteraction,
|
|
1374
|
+
getMediaRef: function getMediaRef(mediaRef) {
|
|
1375
|
+
screensMediasRef.current[i] = mediaRef;
|
|
1376
|
+
}
|
|
1350
1377
|
});
|
|
1351
1378
|
var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
|
|
1352
1379
|
var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
|
|
1353
|
-
return /*#__PURE__*/React.createElement(React.Fragment,
|
|
1380
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
1381
|
+
key: key
|
|
1382
|
+
}, current && screenIndex > 0 ? /*#__PURE__*/React.createElement("button", {
|
|
1354
1383
|
type: "button",
|
|
1355
1384
|
className: "sr-only",
|
|
1356
1385
|
onClick: onScreenPrevious,
|
|
@@ -1363,7 +1392,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
1363
1392
|
}]
|
|
1364
1393
|
}), "Go to previous screen") : null, /*#__PURE__*/React.createElement("div", {
|
|
1365
1394
|
ref: current ? currentScreenRef : null,
|
|
1366
|
-
key: key,
|
|
1367
1395
|
style: {
|
|
1368
1396
|
width: landscape ? screenWidth : null,
|
|
1369
1397
|
height: landscape ? screenHeight : null,
|
package/lib/index.js
CHANGED
|
@@ -58,7 +58,8 @@ var propTypes$8 = {
|
|
|
58
58
|
onPrevious: PropTypes__default["default"].func,
|
|
59
59
|
onNext: PropTypes__default["default"].func,
|
|
60
60
|
onEnableInteraction: PropTypes__default["default"].func,
|
|
61
|
-
onDisableInteraction: PropTypes__default["default"].func
|
|
61
|
+
onDisableInteraction: PropTypes__default["default"].func,
|
|
62
|
+
getMediaRef: PropTypes__default["default"].func
|
|
62
63
|
};
|
|
63
64
|
var defaultProps$8 = {
|
|
64
65
|
screen: null,
|
|
@@ -68,7 +69,8 @@ var defaultProps$8 = {
|
|
|
68
69
|
onPrevious: null,
|
|
69
70
|
onNext: null,
|
|
70
71
|
onEnableInteraction: null,
|
|
71
|
-
onDisableInteraction: null
|
|
72
|
+
onDisableInteraction: null,
|
|
73
|
+
getMediaRef: null
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
var ViewerScreen = function ViewerScreen(_ref) {
|
|
@@ -81,7 +83,8 @@ var ViewerScreen = function ViewerScreen(_ref) {
|
|
|
81
83
|
onPrevious = _ref.onPrevious,
|
|
82
84
|
onNext = _ref.onNext,
|
|
83
85
|
onEnableInteraction = _ref.onEnableInteraction,
|
|
84
|
-
onDisableInteraction = _ref.onDisableInteraction
|
|
86
|
+
onDisableInteraction = _ref.onDisableInteraction,
|
|
87
|
+
getMediaRef = _ref.getMediaRef;
|
|
85
88
|
return screen !== null ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86
89
|
className: classNames__default["default"]([styles$6.container, (_ref2 = {}, _defineProperty__default["default"](_ref2, styles$6.active, active), _defineProperty__default["default"](_ref2, styles$6.current, current), _ref2)]),
|
|
87
90
|
"aria-hidden": current ? null : 'true'
|
|
@@ -93,7 +96,8 @@ var ViewerScreen = function ViewerScreen(_ref) {
|
|
|
93
96
|
onPrevious: onPrevious,
|
|
94
97
|
onNext: onNext,
|
|
95
98
|
onEnableInteraction: onEnableInteraction,
|
|
96
|
-
onDisableInteraction: onDisableInteraction
|
|
99
|
+
onDisableInteraction: onDisableInteraction,
|
|
100
|
+
getMediaRef: getMediaRef
|
|
97
101
|
})) : null;
|
|
98
102
|
};
|
|
99
103
|
|
|
@@ -790,6 +794,8 @@ var propTypes$2 = {
|
|
|
790
794
|
onInteraction: PropTypes__default["default"].func,
|
|
791
795
|
onEnd: PropTypes__default["default"].func,
|
|
792
796
|
onViewModeChange: PropTypes__default["default"].func,
|
|
797
|
+
currentScreenMedia: core.PropTypes.ref,
|
|
798
|
+
screensMedias: core.PropTypes.ref,
|
|
793
799
|
className: PropTypes__default["default"].string
|
|
794
800
|
};
|
|
795
801
|
var defaultProps$2 = {
|
|
@@ -814,6 +820,8 @@ var defaultProps$2 = {
|
|
|
814
820
|
onInteraction: null,
|
|
815
821
|
onEnd: null,
|
|
816
822
|
onViewModeChange: null,
|
|
823
|
+
currentScreenMedia: null,
|
|
824
|
+
screensMedias: null,
|
|
817
825
|
className: null
|
|
818
826
|
};
|
|
819
827
|
|
|
@@ -841,6 +849,8 @@ var Viewer = function Viewer(_ref) {
|
|
|
841
849
|
onInteraction = _ref.onInteraction,
|
|
842
850
|
onEnd = _ref.onEnd,
|
|
843
851
|
onViewModeChange = _ref.onViewModeChange,
|
|
852
|
+
currentScreenMedia = _ref.currentScreenMedia,
|
|
853
|
+
screensMedias = _ref.screensMedias,
|
|
844
854
|
className = _ref.className;
|
|
845
855
|
var intl = reactIntl.useIntl();
|
|
846
856
|
var parsedStory = hooks.useParsedStory(story, {
|
|
@@ -909,7 +919,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
909
919
|
menuOverScreen = _ref5$menuOverScreen === void 0 ? false : _ref5$menuOverScreen;
|
|
910
920
|
|
|
911
921
|
var hasSize = screenWidth > 0 && screenHeight > 0;
|
|
912
|
-
var ready = hasSize; // && fontsLoaded;
|
|
922
|
+
var ready = hasSize; // && fontsLoaded;
|
|
913
923
|
|
|
914
924
|
React.useEffect(function () {
|
|
915
925
|
if (ready && onViewModeChange !== null) {
|
|
@@ -934,19 +944,33 @@ var Viewer = function Viewer(_ref) {
|
|
|
934
944
|
|
|
935
945
|
var _ref7 = menuPreviewContainerRect || {},
|
|
936
946
|
_ref7$height = _ref7.height,
|
|
937
|
-
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
947
|
+
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
938
948
|
|
|
949
|
+
var screensMediasRef = React.useRef([]); // Screen index
|
|
939
950
|
|
|
940
951
|
var screenIndex = React.useMemo(function () {
|
|
941
952
|
return Math.max(0, screens.findIndex(function (it) {
|
|
942
953
|
return String(it.id) === String(screenId);
|
|
943
954
|
}));
|
|
944
955
|
}, [screenId, screens]);
|
|
956
|
+
|
|
957
|
+
if (currentScreenMedia !== null) {
|
|
958
|
+
currentScreenMedia.current = screensMediasRef.current[screenIndex];
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (screensMedias !== null) {
|
|
962
|
+
screensMedias.current = screensMediasRef.current;
|
|
963
|
+
}
|
|
964
|
+
|
|
945
965
|
var changeIndex = React.useCallback(function (index) {
|
|
946
966
|
if (index === screenIndex) {
|
|
947
967
|
return;
|
|
948
968
|
}
|
|
949
969
|
|
|
970
|
+
if (currentScreenMedia !== null) {
|
|
971
|
+
currentScreenMedia.current = screensMediasRef.current[index];
|
|
972
|
+
}
|
|
973
|
+
|
|
950
974
|
if (onScreenChange !== null) {
|
|
951
975
|
onScreenChange(screens[index], index);
|
|
952
976
|
}
|
|
@@ -1363,11 +1387,16 @@ var Viewer = function Viewer(_ref) {
|
|
|
1363
1387
|
onPrevious: onScreenPrevious,
|
|
1364
1388
|
onNext: onScreenNext,
|
|
1365
1389
|
onEnableInteraction: onEnableInteraction,
|
|
1366
|
-
onDisableInteraction: onDisableInteraction
|
|
1390
|
+
onDisableInteraction: onDisableInteraction,
|
|
1391
|
+
getMediaRef: function getMediaRef(mediaRef) {
|
|
1392
|
+
screensMediasRef.current[i] = mediaRef;
|
|
1393
|
+
}
|
|
1367
1394
|
});
|
|
1368
1395
|
var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
|
|
1369
1396
|
var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
|
|
1370
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment,
|
|
1397
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
1398
|
+
key: key
|
|
1399
|
+
}, current && screenIndex > 0 ? /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1371
1400
|
type: "button",
|
|
1372
1401
|
className: "sr-only",
|
|
1373
1402
|
onClick: onScreenPrevious,
|
|
@@ -1380,7 +1409,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
1380
1409
|
}]
|
|
1381
1410
|
}), "Go to previous screen") : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1382
1411
|
ref: current ? currentScreenRef : null,
|
|
1383
|
-
key: key,
|
|
1384
1412
|
style: {
|
|
1385
1413
|
width: landscape ? screenWidth : null,
|
|
1386
1414
|
height: landscape ? screenHeight : null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/viewer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.382",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
56
56
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
57
57
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
58
|
-
"@micromag/core": "^0.2.
|
|
59
|
-
"@micromag/element-scroll": "^0.2.
|
|
60
|
-
"@micromag/elements": "^0.2.
|
|
61
|
-
"@micromag/fields": "^0.2.
|
|
62
|
-
"@micromag/intl": "^0.2.
|
|
63
|
-
"@micromag/screens": "^0.2.
|
|
58
|
+
"@micromag/core": "^0.2.379",
|
|
59
|
+
"@micromag/element-scroll": "^0.2.379",
|
|
60
|
+
"@micromag/elements": "^0.2.379",
|
|
61
|
+
"@micromag/fields": "^0.2.379",
|
|
62
|
+
"@micromag/intl": "^0.2.379",
|
|
63
|
+
"@micromag/screens": "^0.2.382",
|
|
64
64
|
"@react-spring/core": "^9.1.1",
|
|
65
65
|
"@react-spring/web": "^9.1.1",
|
|
66
66
|
"classnames": "^2.2.6",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "45fb095754e40c8cc89b4e0ed04c69c04b1033dc"
|
|
80
80
|
}
|