@micromag/viewer 0.2.380 → 0.2.384

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.
Files changed (3) hide show
  1. package/es/index.js +19 -11
  2. package/lib/index.js +19 -11
  3. package/package.json +8 -8
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
- currentMedia: PropTypes$1.ref,
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
- currentMedia: null,
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
- currentMedia = _ref.currentMedia,
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 screensMediaRef = useRef([]); // Screen index
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 (currentMedia !== null) {
938
- currentMedia.current = screensMediaRef.current[screenIndex];
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,8 +950,8 @@ var Viewer = function Viewer(_ref) {
943
950
  return;
944
951
  }
945
952
 
946
- if (currentMedia !== null) {
947
- currentMedia.current = screensMediaRef.current[index];
953
+ if (currentScreenMedia !== null) {
954
+ currentScreenMedia.current = screensMediasRef.current[index];
948
955
  }
949
956
 
950
957
  if (onScreenChange !== null) {
@@ -1365,12 +1372,14 @@ var Viewer = function Viewer(_ref) {
1365
1372
  onEnableInteraction: onEnableInteraction,
1366
1373
  onDisableInteraction: onDisableInteraction,
1367
1374
  getMediaRef: function getMediaRef(mediaRef) {
1368
- screensMediaRef.current[i] = mediaRef;
1375
+ screensMediasRef.current[i] = mediaRef;
1369
1376
  }
1370
1377
  });
1371
1378
  var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
1372
1379
  var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
1373
- return /*#__PURE__*/React.createElement(React.Fragment, null, current && screenIndex > 0 ? /*#__PURE__*/React.createElement("button", {
1380
+ return /*#__PURE__*/React.createElement(React.Fragment, {
1381
+ key: key
1382
+ }, current && screenIndex > 0 ? /*#__PURE__*/React.createElement("button", {
1374
1383
  type: "button",
1375
1384
  className: "sr-only",
1376
1385
  onClick: onScreenPrevious,
@@ -1383,7 +1392,6 @@ var Viewer = function Viewer(_ref) {
1383
1392
  }]
1384
1393
  }), "Go to previous screen") : null, /*#__PURE__*/React.createElement("div", {
1385
1394
  ref: current ? currentScreenRef : null,
1386
- key: key,
1387
1395
  style: {
1388
1396
  width: landscape ? screenWidth : null,
1389
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
- currentMedia: core.PropTypes.ref,
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
- currentMedia: null,
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
- currentMedia = _ref.currentMedia,
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 screensMediaRef = React.useRef([]); // Screen index
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 (currentMedia !== null) {
955
- currentMedia.current = screensMediaRef.current[screenIndex];
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,8 +967,8 @@ var Viewer = function Viewer(_ref) {
960
967
  return;
961
968
  }
962
969
 
963
- if (currentMedia !== null) {
964
- currentMedia.current = screensMediaRef.current[index];
970
+ if (currentScreenMedia !== null) {
971
+ currentScreenMedia.current = screensMediasRef.current[index];
965
972
  }
966
973
 
967
974
  if (onScreenChange !== null) {
@@ -1382,12 +1389,14 @@ var Viewer = function Viewer(_ref) {
1382
1389
  onEnableInteraction: onEnableInteraction,
1383
1390
  onDisableInteraction: onDisableInteraction,
1384
1391
  getMediaRef: function getMediaRef(mediaRef) {
1385
- screensMediaRef.current[i] = mediaRef;
1392
+ screensMediasRef.current[i] = mediaRef;
1386
1393
  }
1387
1394
  });
1388
1395
  var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
1389
1396
  var screenTransform = landscape ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : "translateX(".concat(current ? 0 : '100%', ")");
1390
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, current && screenIndex > 0 ? /*#__PURE__*/React__default["default"].createElement("button", {
1397
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
1398
+ key: key
1399
+ }, current && screenIndex > 0 ? /*#__PURE__*/React__default["default"].createElement("button", {
1391
1400
  type: "button",
1392
1401
  className: "sr-only",
1393
1402
  onClick: onScreenPrevious,
@@ -1400,7 +1409,6 @@ var Viewer = function Viewer(_ref) {
1400
1409
  }]
1401
1410
  }), "Go to previous screen") : null, /*#__PURE__*/React__default["default"].createElement("div", {
1402
1411
  ref: current ? currentScreenRef : null,
1403
- key: key,
1404
1412
  style: {
1405
1413
  width: landscape ? screenWidth : null,
1406
1414
  height: landscape ? screenHeight : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/viewer",
3
- "version": "0.2.380",
3
+ "version": "0.2.384",
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.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.379",
58
+ "@micromag/core": "^0.2.384",
59
+ "@micromag/element-scroll": "^0.2.384",
60
+ "@micromag/elements": "^0.2.384",
61
+ "@micromag/fields": "^0.2.384",
62
+ "@micromag/intl": "^0.2.384",
63
+ "@micromag/screens": "^0.2.384",
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": "857ac6e0c89d8edc0f1f9781c093e51d65757f34"
79
+ "gitHead": "cfe309fba4ad374b6cd483e588d90ab3b76d2f5b"
80
80
  }