@micromag/viewer 0.3.34 → 0.3.37

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 +24 -10
  2. package/lib/index.js +24 -10
  3. package/package.json +8 -8
package/es/index.js CHANGED
@@ -71,7 +71,7 @@ function useKeyboardShortcuts() {
71
71
  window.removeEventListener('keydown', onKey);
72
72
  }
73
73
  };
74
- }, [disabled]);
74
+ }, [disabled, shortcuts]);
75
75
  }
76
76
 
77
77
  function checkClickable(el) {
@@ -181,6 +181,7 @@ function useScreenInteraction() {
181
181
  contentX = _e$currentTarget$getB2 === void 0 ? 0 : _e$currentTarget$getB2;
182
182
 
183
183
  var tapX = e.clientX;
184
+ console.log(e.clientX, contentX, screenWidth);
184
185
  var hasTappedLeft = tappedCurrent ? tapX - contentX < screenWidth * (1 - nextScreenWidthPercent) : screenIndex > index;
185
186
 
186
187
  if (hasTappedLeft) {
@@ -743,7 +744,7 @@ var defaultProps$5 = {
743
744
  onClickItem: null,
744
745
  onClose: null,
745
746
  onShare: null,
746
- thumbsPerLine: 4,
747
+ thumbsPerLine: 3,
747
748
  toggleFullscreen: null,
748
749
  fullscreenActive: false,
749
750
  fullscreenEnabled: false,
@@ -1492,7 +1493,8 @@ var Viewer = function Viewer(_ref) {
1492
1493
  screens: deviceScreens
1493
1494
  }, screenSizeOptions)),
1494
1495
  containerRef = _useScreenSizeFromEle.ref,
1495
- screenSize = _useScreenSizeFromEle.screenSize;
1496
+ screenSize = _useScreenSizeFromEle.screenSize,
1497
+ screenScale = _useScreenSizeFromEle.scale;
1496
1498
 
1497
1499
  var _ref5 = screenSize || {},
1498
1500
  _ref5$width = _ref5.width,
@@ -1504,6 +1506,8 @@ var Viewer = function Viewer(_ref) {
1504
1506
  _ref5$menuOverScreen = _ref5.menuOverScreen,
1505
1507
  menuOverScreen = _ref5$menuOverScreen === void 0 ? false : _ref5$menuOverScreen;
1506
1508
 
1509
+ var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
1510
+ var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
1507
1511
  var hasSize = screenWidth > 0 && screenHeight > 0;
1508
1512
  var ready = hasSize; // && fontsLoaded;
1509
1513
 
@@ -1571,7 +1575,7 @@ var Viewer = function Viewer(_ref) {
1571
1575
  var _useScreenInteraction = useScreenInteraction({
1572
1576
  screens: screens,
1573
1577
  screenIndex: screenIndex,
1574
- screenWidth: screenWidth,
1578
+ screenWidth: screenContainerWidth,
1575
1579
  isView: isView,
1576
1580
  clickOnSiblings: landscape && withLandscapeSiblingsScreens,
1577
1581
  nextScreenWidthPercent: tapNextScreenWidthPercent,
@@ -1719,14 +1723,14 @@ var Viewer = function Viewer(_ref) {
1719
1723
  closeable: closeable,
1720
1724
  shareBasePath: basePath,
1721
1725
  screenSize: screenSize,
1722
- menuWidth: screenWidth,
1726
+ menuWidth: screenContainerWidth,
1723
1727
  trackingEnabled: trackingEnabled,
1724
1728
  onClickItem: onClickMenuItem,
1725
1729
  onClickMenu: onClickMenu,
1726
1730
  onClickCloseViewer: onCloseViewer,
1727
1731
  onRequestOpen: onMenuRequestOpen,
1728
1732
  onRequestClose: onMenuRequestClose,
1729
- withDotItemClick: screenWidth > 400,
1733
+ withDotItemClick: screenContainerWidth > 400,
1730
1734
  withoutScreensMenu: withoutScreensMenu,
1731
1735
  refDots: menuDotsContainerRef
1732
1736
  }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", {
@@ -1756,7 +1760,7 @@ var Viewer = function Viewer(_ref) {
1756
1760
  var screenTransform = null;
1757
1761
 
1758
1762
  if (landscape) {
1759
- screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
1763
+ screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenContainerWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
1760
1764
  } else {
1761
1765
  screenTransform = "translateX(".concat(current ? 0 : '100%', ")");
1762
1766
  }
@@ -1777,8 +1781,10 @@ var Viewer = function Viewer(_ref) {
1777
1781
  })) : null, /*#__PURE__*/React.createElement("div", {
1778
1782
  ref: current ? currentScreenRef : null,
1779
1783
  style: {
1780
- width: landscape ? screenWidth : null,
1781
- height: landscape ? screenHeight : null,
1784
+ // width: landscape ? screenWidth : null,
1785
+ // height: landscape ? screenHeight : null,
1786
+ width: screenContainerWidth,
1787
+ height: screenContainerHeight,
1782
1788
  transform: !withoutScreensTransforms ? screenTransform : null
1783
1789
  },
1784
1790
  className: classNames([styles$7.screen, (_ref13 = {}, _defineProperty(_ref13, styles$7.current, current), _defineProperty(_ref13, styles$7.visible, current || withLandscapeSiblingsScreens), _ref13)]),
@@ -1806,7 +1812,15 @@ var Viewer = function Viewer(_ref) {
1806
1812
  onClick: function onClick(e) {
1807
1813
  return onScreenClick(e, i);
1808
1814
  }
1809
- }, viewerScreen), current && screenIndex < screens.length ? /*#__PURE__*/React.createElement("button", {
1815
+ }, /*#__PURE__*/React.createElement("div", {
1816
+ className: styles$7.scaler,
1817
+ style: {
1818
+ width: screenWidth,
1819
+ height: screenHeight,
1820
+ transform: screenScale !== null ? "scale(".concat(screenScale, ")") : null,
1821
+ transformOrigin: screenScale !== null ? '0 0' : null
1822
+ }
1823
+ }, viewerScreen)), current && screenIndex < screens.length ? /*#__PURE__*/React.createElement("button", {
1810
1824
  type: "button",
1811
1825
  className: "sr-only",
1812
1826
  onClick: gotoNextScreen,
package/lib/index.js CHANGED
@@ -89,7 +89,7 @@ function useKeyboardShortcuts() {
89
89
  window.removeEventListener('keydown', onKey);
90
90
  }
91
91
  };
92
- }, [disabled]);
92
+ }, [disabled, shortcuts]);
93
93
  }
94
94
 
95
95
  function checkClickable(el) {
@@ -199,6 +199,7 @@ function useScreenInteraction() {
199
199
  contentX = _e$currentTarget$getB2 === void 0 ? 0 : _e$currentTarget$getB2;
200
200
 
201
201
  var tapX = e.clientX;
202
+ console.log(e.clientX, contentX, screenWidth);
202
203
  var hasTappedLeft = tappedCurrent ? tapX - contentX < screenWidth * (1 - nextScreenWidthPercent) : screenIndex > index;
203
204
 
204
205
  if (hasTappedLeft) {
@@ -761,7 +762,7 @@ var defaultProps$5 = {
761
762
  onClickItem: null,
762
763
  onClose: null,
763
764
  onShare: null,
764
- thumbsPerLine: 4,
765
+ thumbsPerLine: 3,
765
766
  toggleFullscreen: null,
766
767
  fullscreenActive: false,
767
768
  fullscreenEnabled: false,
@@ -1510,7 +1511,8 @@ var Viewer = function Viewer(_ref) {
1510
1511
  screens: deviceScreens
1511
1512
  }, screenSizeOptions)),
1512
1513
  containerRef = _useScreenSizeFromEle.ref,
1513
- screenSize = _useScreenSizeFromEle.screenSize;
1514
+ screenSize = _useScreenSizeFromEle.screenSize,
1515
+ screenScale = _useScreenSizeFromEle.scale;
1514
1516
 
1515
1517
  var _ref5 = screenSize || {},
1516
1518
  _ref5$width = _ref5.width,
@@ -1522,6 +1524,8 @@ var Viewer = function Viewer(_ref) {
1522
1524
  _ref5$menuOverScreen = _ref5.menuOverScreen,
1523
1525
  menuOverScreen = _ref5$menuOverScreen === void 0 ? false : _ref5$menuOverScreen;
1524
1526
 
1527
+ var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
1528
+ var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
1525
1529
  var hasSize = screenWidth > 0 && screenHeight > 0;
1526
1530
  var ready = hasSize; // && fontsLoaded;
1527
1531
 
@@ -1589,7 +1593,7 @@ var Viewer = function Viewer(_ref) {
1589
1593
  var _useScreenInteraction = useScreenInteraction({
1590
1594
  screens: screens,
1591
1595
  screenIndex: screenIndex,
1592
- screenWidth: screenWidth,
1596
+ screenWidth: screenContainerWidth,
1593
1597
  isView: isView,
1594
1598
  clickOnSiblings: landscape && withLandscapeSiblingsScreens,
1595
1599
  nextScreenWidthPercent: tapNextScreenWidthPercent,
@@ -1737,14 +1741,14 @@ var Viewer = function Viewer(_ref) {
1737
1741
  closeable: closeable,
1738
1742
  shareBasePath: basePath,
1739
1743
  screenSize: screenSize,
1740
- menuWidth: screenWidth,
1744
+ menuWidth: screenContainerWidth,
1741
1745
  trackingEnabled: trackingEnabled,
1742
1746
  onClickItem: onClickMenuItem,
1743
1747
  onClickMenu: onClickMenu,
1744
1748
  onClickCloseViewer: onCloseViewer,
1745
1749
  onRequestOpen: onMenuRequestOpen,
1746
1750
  onRequestClose: onMenuRequestClose,
1747
- withDotItemClick: screenWidth > 400,
1751
+ withDotItemClick: screenContainerWidth > 400,
1748
1752
  withoutScreensMenu: withoutScreensMenu,
1749
1753
  refDots: menuDotsContainerRef
1750
1754
  }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React__default["default"].createElement("div", {
@@ -1774,7 +1778,7 @@ var Viewer = function Viewer(_ref) {
1774
1778
  var screenTransform = null;
1775
1779
 
1776
1780
  if (landscape) {
1777
- screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
1781
+ screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenContainerWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
1778
1782
  } else {
1779
1783
  screenTransform = "translateX(".concat(current ? 0 : '100%', ")");
1780
1784
  }
@@ -1795,8 +1799,10 @@ var Viewer = function Viewer(_ref) {
1795
1799
  })) : null, /*#__PURE__*/React__default["default"].createElement("div", {
1796
1800
  ref: current ? currentScreenRef : null,
1797
1801
  style: {
1798
- width: landscape ? screenWidth : null,
1799
- height: landscape ? screenHeight : null,
1802
+ // width: landscape ? screenWidth : null,
1803
+ // height: landscape ? screenHeight : null,
1804
+ width: screenContainerWidth,
1805
+ height: screenContainerHeight,
1800
1806
  transform: !withoutScreensTransforms ? screenTransform : null
1801
1807
  },
1802
1808
  className: classNames__default["default"]([styles$7.screen, (_ref13 = {}, _defineProperty__default["default"](_ref13, styles$7.current, current), _defineProperty__default["default"](_ref13, styles$7.visible, current || withLandscapeSiblingsScreens), _ref13)]),
@@ -1824,7 +1830,15 @@ var Viewer = function Viewer(_ref) {
1824
1830
  onClick: function onClick(e) {
1825
1831
  return onScreenClick(e, i);
1826
1832
  }
1827
- }, viewerScreen), current && screenIndex < screens.length ? /*#__PURE__*/React__default["default"].createElement("button", {
1833
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1834
+ className: styles$7.scaler,
1835
+ style: {
1836
+ width: screenWidth,
1837
+ height: screenHeight,
1838
+ transform: screenScale !== null ? "scale(".concat(screenScale, ")") : null,
1839
+ transformOrigin: screenScale !== null ? '0 0' : null
1840
+ }
1841
+ }, viewerScreen)), current && screenIndex < screens.length ? /*#__PURE__*/React__default["default"].createElement("button", {
1828
1842
  type: "button",
1829
1843
  className: "sr-only",
1830
1844
  onClick: gotoNextScreen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/viewer",
3
- "version": "0.3.34",
3
+ "version": "0.3.37",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -59,12 +59,12 @@
59
59
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
60
60
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
61
61
  "@fortawesome/react-fontawesome": "^0.1.13",
62
- "@micromag/core": "^0.3.34",
63
- "@micromag/element-scroll": "^0.3.34",
64
- "@micromag/elements": "^0.3.34",
65
- "@micromag/fields": "^0.3.34",
66
- "@micromag/intl": "^0.3.34",
67
- "@micromag/screens": "^0.3.34",
62
+ "@micromag/core": "^0.3.36",
63
+ "@micromag/element-scroll": "^0.3.36",
64
+ "@micromag/elements": "^0.3.37",
65
+ "@micromag/fields": "^0.3.36",
66
+ "@micromag/intl": "^0.3.36",
67
+ "@micromag/screens": "^0.3.37",
68
68
  "@react-spring/core": "^9.1.1",
69
69
  "@react-spring/web": "^9.1.1",
70
70
  "@use-gesture/react": "^10.2.4",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "f8332cb20e6c8cf2cbdba28fc965877684174b2f"
84
+ "gitHead": "81633b181d0ca4b962255ddeaed955346d29b2e9"
85
85
  }