@micromag/viewer 0.2.379 → 0.2.383
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 +21 -9
- package/lib/index.js +21 -9
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -777,7 +777,8 @@ var propTypes$2 = {
|
|
|
777
777
|
onInteraction: PropTypes.func,
|
|
778
778
|
onEnd: PropTypes.func,
|
|
779
779
|
onViewModeChange: PropTypes.func,
|
|
780
|
-
|
|
780
|
+
currentScreenMedia: PropTypes$1.ref,
|
|
781
|
+
screensMedias: PropTypes$1.ref,
|
|
781
782
|
className: PropTypes.string
|
|
782
783
|
};
|
|
783
784
|
var defaultProps$2 = {
|
|
@@ -802,7 +803,8 @@ var defaultProps$2 = {
|
|
|
802
803
|
onInteraction: null,
|
|
803
804
|
onEnd: null,
|
|
804
805
|
onViewModeChange: null,
|
|
805
|
-
|
|
806
|
+
currentScreenMedia: null,
|
|
807
|
+
screensMedias: null,
|
|
806
808
|
className: null
|
|
807
809
|
};
|
|
808
810
|
|
|
@@ -830,7 +832,8 @@ var Viewer = function Viewer(_ref) {
|
|
|
830
832
|
onInteraction = _ref.onInteraction,
|
|
831
833
|
onEnd = _ref.onEnd,
|
|
832
834
|
onViewModeChange = _ref.onViewModeChange,
|
|
833
|
-
|
|
835
|
+
currentScreenMedia = _ref.currentScreenMedia,
|
|
836
|
+
screensMedias = _ref.screensMedias,
|
|
834
837
|
className = _ref.className;
|
|
835
838
|
var intl = useIntl();
|
|
836
839
|
var parsedStory = useParsedStory(story, {
|
|
@@ -926,7 +929,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
926
929
|
_ref7$height = _ref7.height,
|
|
927
930
|
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
928
931
|
|
|
929
|
-
var
|
|
932
|
+
var screensMediasRef = useRef([]); // Screen index
|
|
930
933
|
|
|
931
934
|
var screenIndex = useMemo(function () {
|
|
932
935
|
return Math.max(0, screens.findIndex(function (it) {
|
|
@@ -934,8 +937,12 @@ var Viewer = function Viewer(_ref) {
|
|
|
934
937
|
}));
|
|
935
938
|
}, [screenId, screens]);
|
|
936
939
|
|
|
937
|
-
if (
|
|
938
|
-
|
|
940
|
+
if (currentScreenMedia !== null) {
|
|
941
|
+
currentScreenMedia.current = screensMediasRef.current[screenIndex];
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
if (screensMedias !== null) {
|
|
945
|
+
screensMedias.current = screensMediasRef.current;
|
|
939
946
|
}
|
|
940
947
|
|
|
941
948
|
var changeIndex = useCallback(function (index) {
|
|
@@ -943,6 +950,10 @@ var Viewer = function Viewer(_ref) {
|
|
|
943
950
|
return;
|
|
944
951
|
}
|
|
945
952
|
|
|
953
|
+
if (currentScreenMedia !== null) {
|
|
954
|
+
currentScreenMedia.current = screensMediasRef.current[index];
|
|
955
|
+
}
|
|
956
|
+
|
|
946
957
|
if (onScreenChange !== null) {
|
|
947
958
|
onScreenChange(screens[index], index);
|
|
948
959
|
}
|
|
@@ -1361,12 +1372,14 @@ var Viewer = function Viewer(_ref) {
|
|
|
1361
1372
|
onEnableInteraction: onEnableInteraction,
|
|
1362
1373
|
onDisableInteraction: onDisableInteraction,
|
|
1363
1374
|
getMediaRef: function getMediaRef(mediaRef) {
|
|
1364
|
-
|
|
1375
|
+
screensMediasRef.current[i] = mediaRef;
|
|
1365
1376
|
}
|
|
1366
1377
|
});
|
|
1367
1378
|
var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
|
|
1368
1379
|
var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
|
|
1369
|
-
return /*#__PURE__*/React.createElement(React.Fragment,
|
|
1380
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
1381
|
+
key: key
|
|
1382
|
+
}, current && screenIndex > 0 ? /*#__PURE__*/React.createElement("button", {
|
|
1370
1383
|
type: "button",
|
|
1371
1384
|
className: "sr-only",
|
|
1372
1385
|
onClick: onScreenPrevious,
|
|
@@ -1379,7 +1392,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
1379
1392
|
}]
|
|
1380
1393
|
}), "Go to previous screen") : null, /*#__PURE__*/React.createElement("div", {
|
|
1381
1394
|
ref: current ? currentScreenRef : null,
|
|
1382
|
-
key: key,
|
|
1383
1395
|
style: {
|
|
1384
1396
|
width: landscape ? screenWidth : null,
|
|
1385
1397
|
height: landscape ? screenHeight : null,
|
package/lib/index.js
CHANGED
|
@@ -794,7 +794,8 @@ var propTypes$2 = {
|
|
|
794
794
|
onInteraction: PropTypes__default["default"].func,
|
|
795
795
|
onEnd: PropTypes__default["default"].func,
|
|
796
796
|
onViewModeChange: PropTypes__default["default"].func,
|
|
797
|
-
|
|
797
|
+
currentScreenMedia: core.PropTypes.ref,
|
|
798
|
+
screensMedias: core.PropTypes.ref,
|
|
798
799
|
className: PropTypes__default["default"].string
|
|
799
800
|
};
|
|
800
801
|
var defaultProps$2 = {
|
|
@@ -819,7 +820,8 @@ var defaultProps$2 = {
|
|
|
819
820
|
onInteraction: null,
|
|
820
821
|
onEnd: null,
|
|
821
822
|
onViewModeChange: null,
|
|
822
|
-
|
|
823
|
+
currentScreenMedia: null,
|
|
824
|
+
screensMedias: null,
|
|
823
825
|
className: null
|
|
824
826
|
};
|
|
825
827
|
|
|
@@ -847,7 +849,8 @@ var Viewer = function Viewer(_ref) {
|
|
|
847
849
|
onInteraction = _ref.onInteraction,
|
|
848
850
|
onEnd = _ref.onEnd,
|
|
849
851
|
onViewModeChange = _ref.onViewModeChange,
|
|
850
|
-
|
|
852
|
+
currentScreenMedia = _ref.currentScreenMedia,
|
|
853
|
+
screensMedias = _ref.screensMedias,
|
|
851
854
|
className = _ref.className;
|
|
852
855
|
var intl = reactIntl.useIntl();
|
|
853
856
|
var parsedStory = hooks.useParsedStory(story, {
|
|
@@ -943,7 +946,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
943
946
|
_ref7$height = _ref7.height,
|
|
944
947
|
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
945
948
|
|
|
946
|
-
var
|
|
949
|
+
var screensMediasRef = React.useRef([]); // Screen index
|
|
947
950
|
|
|
948
951
|
var screenIndex = React.useMemo(function () {
|
|
949
952
|
return Math.max(0, screens.findIndex(function (it) {
|
|
@@ -951,8 +954,12 @@ var Viewer = function Viewer(_ref) {
|
|
|
951
954
|
}));
|
|
952
955
|
}, [screenId, screens]);
|
|
953
956
|
|
|
954
|
-
if (
|
|
955
|
-
|
|
957
|
+
if (currentScreenMedia !== null) {
|
|
958
|
+
currentScreenMedia.current = screensMediasRef.current[screenIndex];
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (screensMedias !== null) {
|
|
962
|
+
screensMedias.current = screensMediasRef.current;
|
|
956
963
|
}
|
|
957
964
|
|
|
958
965
|
var changeIndex = React.useCallback(function (index) {
|
|
@@ -960,6 +967,10 @@ var Viewer = function Viewer(_ref) {
|
|
|
960
967
|
return;
|
|
961
968
|
}
|
|
962
969
|
|
|
970
|
+
if (currentScreenMedia !== null) {
|
|
971
|
+
currentScreenMedia.current = screensMediasRef.current[index];
|
|
972
|
+
}
|
|
973
|
+
|
|
963
974
|
if (onScreenChange !== null) {
|
|
964
975
|
onScreenChange(screens[index], index);
|
|
965
976
|
}
|
|
@@ -1378,12 +1389,14 @@ var Viewer = function Viewer(_ref) {
|
|
|
1378
1389
|
onEnableInteraction: onEnableInteraction,
|
|
1379
1390
|
onDisableInteraction: onDisableInteraction,
|
|
1380
1391
|
getMediaRef: function getMediaRef(mediaRef) {
|
|
1381
|
-
|
|
1392
|
+
screensMediasRef.current[i] = mediaRef;
|
|
1382
1393
|
}
|
|
1383
1394
|
});
|
|
1384
1395
|
var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
|
|
1385
1396
|
var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
|
|
1386
|
-
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", {
|
|
1387
1400
|
type: "button",
|
|
1388
1401
|
className: "sr-only",
|
|
1389
1402
|
onClick: onScreenPrevious,
|
|
@@ -1396,7 +1409,6 @@ var Viewer = function Viewer(_ref) {
|
|
|
1396
1409
|
}]
|
|
1397
1410
|
}), "Go to previous screen") : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1398
1411
|
ref: current ? currentScreenRef : null,
|
|
1399
|
-
key: key,
|
|
1400
1412
|
style: {
|
|
1401
1413
|
width: landscape ? screenWidth : null,
|
|
1402
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.383",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@micromag/elements": "^0.2.379",
|
|
61
61
|
"@micromag/fields": "^0.2.379",
|
|
62
62
|
"@micromag/intl": "^0.2.379",
|
|
63
|
-
"@micromag/screens": "^0.2.
|
|
63
|
+
"@micromag/screens": "^0.2.383",
|
|
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": "14ecbbc6ee503b1c56d5dccde6da83e8e1394c19"
|
|
80
80
|
}
|