@micromag/viewer 0.3.207 → 0.3.213
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/assets/css/styles.css +3 -3
- package/es/index.js +134 -73
- package/lib/index.js +134 -73
- package/package.json +11 -10
package/es/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
14
14
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import { Helmet } from 'react-helmet';
|
|
17
|
+
import { animated } from '@react-spring/web';
|
|
17
18
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
18
19
|
import { Label, ScreenPreview, Screen, Button as Button$1, Meta, FontFaces } from '@micromag/core/components';
|
|
19
20
|
import { useDimensionObserver, useTrackEvent, useDragProgress, useMediaProgress, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
|
|
@@ -22,7 +23,6 @@ import { useIntl, FormattedMessage } from 'react-intl';
|
|
|
22
23
|
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
23
24
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
24
25
|
import { useSpring } from '@react-spring/core';
|
|
25
|
-
import { animated } from '@react-spring/web';
|
|
26
26
|
import Scroll from '@micromag/element-scroll';
|
|
27
27
|
import ShareOptions from '@micromag/element-share-options';
|
|
28
28
|
import { useGesture } from '@use-gesture/react';
|
|
@@ -511,14 +511,14 @@ var styles$e = {"container":"micromag-viewer-buttons-toggle-button-container","n
|
|
|
511
511
|
|
|
512
512
|
var propTypes$i = {
|
|
513
513
|
className: PropTypes.string,
|
|
514
|
-
|
|
514
|
+
progressSpring: PropTypes.number,
|
|
515
515
|
button: PropTypes.node,
|
|
516
516
|
toggledButton: PropTypes.node,
|
|
517
517
|
toggledButtonClassName: PropTypes.string
|
|
518
518
|
};
|
|
519
519
|
var defaultProps$i = {
|
|
520
520
|
className: null,
|
|
521
|
-
|
|
521
|
+
progressSpring: 0,
|
|
522
522
|
button: null,
|
|
523
523
|
toggledButton: null,
|
|
524
524
|
toggledButtonClassName: null
|
|
@@ -526,26 +526,27 @@ var defaultProps$i = {
|
|
|
526
526
|
|
|
527
527
|
var ToggleButton = function ToggleButton(_ref) {
|
|
528
528
|
var className = _ref.className,
|
|
529
|
-
|
|
529
|
+
progressSpring = _ref.progressSpring,
|
|
530
530
|
button = _ref.button,
|
|
531
531
|
toggledButton = _ref.toggledButton,
|
|
532
532
|
toggledButtonClassName = _ref.toggledButtonClassName;
|
|
533
533
|
if (button === null) return false;
|
|
534
|
-
|
|
535
|
-
var getToggleButtonStyles = function getToggleButtonStyles(t) {
|
|
536
|
-
return {
|
|
537
|
-
transform: "translateY(".concat(t * -100, "%)")
|
|
538
|
-
};
|
|
539
|
-
};
|
|
540
|
-
|
|
541
534
|
return /*#__PURE__*/React.createElement("div", {
|
|
542
535
|
className: classNames([styles$e.container, _defineProperty({}, className, className !== null)])
|
|
543
|
-
}, /*#__PURE__*/React.createElement(
|
|
536
|
+
}, /*#__PURE__*/React.createElement(animated.div, {
|
|
544
537
|
className: styles$e.normal,
|
|
545
|
-
style:
|
|
546
|
-
|
|
538
|
+
style: {
|
|
539
|
+
transform: progressSpring.to(function (p) {
|
|
540
|
+
return "translateY(".concat(p * -100, "%)");
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
}, button), /*#__PURE__*/React.createElement(animated.div, {
|
|
547
544
|
className: classNames([styles$e.toggled, _defineProperty({}, toggledButtonClassName, toggledButtonClassName !== null)]),
|
|
548
|
-
style:
|
|
545
|
+
style: {
|
|
546
|
+
transform: progressSpring.to(function (p) {
|
|
547
|
+
return "translateY(".concat((p - 1) * -100, "%)");
|
|
548
|
+
})
|
|
549
|
+
}
|
|
549
550
|
}, toggledButton));
|
|
550
551
|
};
|
|
551
552
|
|
|
@@ -556,20 +557,20 @@ var styles$d = {"backdrop":"micromag-viewer-menus-menu-container-backdrop","heig
|
|
|
556
557
|
|
|
557
558
|
var propTypes$h = {
|
|
558
559
|
className: PropTypes.string,
|
|
559
|
-
|
|
560
|
+
progressSpring: PropTypes.number,
|
|
560
561
|
theme: PropTypes$1.viewerTheme,
|
|
561
562
|
children: PropTypes.node
|
|
562
563
|
};
|
|
563
564
|
var defaultProps$h = {
|
|
564
565
|
className: null,
|
|
565
|
-
|
|
566
|
+
progressSpring: 0,
|
|
566
567
|
theme: null,
|
|
567
568
|
children: null
|
|
568
569
|
};
|
|
569
570
|
|
|
570
571
|
var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
|
|
571
572
|
var className = _ref.className,
|
|
572
|
-
|
|
573
|
+
progressSpring = _ref.progressSpring,
|
|
573
574
|
viewerTheme = _ref.theme,
|
|
574
575
|
children = _ref.children;
|
|
575
576
|
|
|
@@ -587,17 +588,25 @@ var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
|
|
|
587
588
|
style: {
|
|
588
589
|
pointerEvents: 'none'
|
|
589
590
|
}
|
|
590
|
-
}, /*#__PURE__*/React.createElement(
|
|
591
|
+
}, /*#__PURE__*/React.createElement(animated.div, {
|
|
591
592
|
className: styles$d.heightContainer,
|
|
592
593
|
style: _objectSpread({
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
594
|
+
opacity: progressSpring,
|
|
595
|
+
// transform: progressSpring.to((p) => `translateY(${(1 - p) * -100}%)`),
|
|
596
|
+
// height: progressSpring.to((p) => `${p * 100}%`),
|
|
597
|
+
pointerEvents: progressSpring.to(function (p) {
|
|
598
|
+
return p < 0.25 ? 'none' : 'auto';
|
|
599
|
+
}),
|
|
600
|
+
zIndex: progressSpring.to(function (p) {
|
|
601
|
+
return Math.round(2 + p);
|
|
602
|
+
})
|
|
596
603
|
}, backgroundColorStyle)
|
|
597
|
-
}, children), /*#__PURE__*/React.createElement(
|
|
604
|
+
}, children), /*#__PURE__*/React.createElement(animated.div, {
|
|
598
605
|
className: styles$d.backdrop,
|
|
599
606
|
style: {
|
|
600
|
-
opacity:
|
|
607
|
+
opacity: progressSpring.to(function (p) {
|
|
608
|
+
return easings.easeOutQuint(p);
|
|
609
|
+
})
|
|
601
610
|
}
|
|
602
611
|
}));
|
|
603
612
|
};
|
|
@@ -924,7 +933,10 @@ var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
|
|
|
924
933
|
}]
|
|
925
934
|
})) : '');
|
|
926
935
|
return /*#__PURE__*/React.createElement("div", {
|
|
927
|
-
className: classNames([styles$a.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$a.isCurrent, current), _ref4)])
|
|
936
|
+
className: classNames([styles$a.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$a.isCurrent, current), _ref4)]),
|
|
937
|
+
style: {
|
|
938
|
+
paddingBottom: "".concat(screenHeight / screenWidth * 100, "%")
|
|
939
|
+
}
|
|
928
940
|
}, /*#__PURE__*/React.createElement("button", {
|
|
929
941
|
type: "button",
|
|
930
942
|
className: styles$a.button,
|
|
@@ -957,7 +969,7 @@ var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
|
|
|
957
969
|
ViewerMenuScreen.propTypes = propTypes$d;
|
|
958
970
|
ViewerMenuScreen.defaultProps = defaultProps$d;
|
|
959
971
|
|
|
960
|
-
var styles$9 = {"scroll":"micromag-viewer-menus-menu-preview-scroll","container":"micromag-viewer-menus-menu-preview-container","disabled":"micromag-viewer-menus-menu-preview-disabled","screenButton":"micromag-viewer-menus-menu-preview-screenButton","buttons":"micromag-viewer-menus-menu-preview-buttons","content":"micromag-viewer-menus-menu-preview-content","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","title":"micromag-viewer-menus-menu-preview-title","nav":"micromag-viewer-menus-menu-preview-nav","item":"micromag-viewer-menus-menu-preview-item","items":"micromag-viewer-menus-menu-preview-items","
|
|
972
|
+
var styles$9 = {"scroll":"micromag-viewer-menus-menu-preview-scroll","container":"micromag-viewer-menus-menu-preview-container","disabled":"micromag-viewer-menus-menu-preview-disabled","screenButton":"micromag-viewer-menus-menu-preview-screenButton","buttons":"micromag-viewer-menus-menu-preview-buttons","content":"micromag-viewer-menus-menu-preview-content","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","title":"micromag-viewer-menus-menu-preview-title","nav":"micromag-viewer-menus-menu-preview-nav","item":"micromag-viewer-menus-menu-preview-item","items":"micromag-viewer-menus-menu-preview-items","inner":"micromag-viewer-menus-menu-preview-inner","frame":"micromag-viewer-menus-menu-preview-frame","fillPulse":"micromag-viewer-menus-menu-preview-fillPulse","isLoading":"micromag-viewer-menus-menu-preview-isLoading","screen":"micromag-viewer-menus-menu-preview-screen","intro":"micromag-viewer-menus-menu-preview-intro"};
|
|
961
973
|
|
|
962
974
|
var propTypes$c = {
|
|
963
975
|
viewerTheme: PropTypes$1.viewerTheme,
|
|
@@ -968,6 +980,7 @@ var propTypes$c = {
|
|
|
968
980
|
onClickScreen: PropTypes.func,
|
|
969
981
|
maxThumbsWidth: PropTypes.number,
|
|
970
982
|
paddingTop: PropTypes.number,
|
|
983
|
+
scrollDisabled: PropTypes.bool,
|
|
971
984
|
// @todo to reimplement:
|
|
972
985
|
// shouldLoad: PropTypes.bool,
|
|
973
986
|
// toggleFullscreen: PropTypes.func,
|
|
@@ -985,6 +998,7 @@ var defaultProps$c = {
|
|
|
985
998
|
onClickScreen: null,
|
|
986
999
|
maxThumbsWidth: 140,
|
|
987
1000
|
paddingTop: null,
|
|
1001
|
+
scrollDisabled: false,
|
|
988
1002
|
// toggleFullscreen: null,
|
|
989
1003
|
// fullscreenActive: false,
|
|
990
1004
|
// fullscreenEnabled: false,
|
|
@@ -1000,6 +1014,7 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1000
1014
|
onClickScreen = _ref.onClickScreen,
|
|
1001
1015
|
maxThumbsWidth = _ref.maxThumbsWidth,
|
|
1002
1016
|
paddingTop = _ref.paddingTop,
|
|
1017
|
+
scrollDisabled = _ref.scrollDisabled,
|
|
1003
1018
|
className = _ref.className;
|
|
1004
1019
|
|
|
1005
1020
|
var _useDimensionObserver = useDimensionObserver(),
|
|
@@ -1026,12 +1041,29 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1026
1041
|
var brandImageStyle = brandImageUrl !== null ? {
|
|
1027
1042
|
backgroundImage: "url(".concat(brandImageUrl, ")")
|
|
1028
1043
|
} : null; // const { url: brandLogoUrl = null } = brandLogo || {};
|
|
1029
|
-
|
|
1044
|
+
|
|
1045
|
+
var _useState = useState([]),
|
|
1046
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1047
|
+
screensMounted = _useState2[0],
|
|
1048
|
+
setScreensMounted = _useState2[1]; // @todo optimize all of this the proper way
|
|
1030
1049
|
// const finalItems = useMemo(
|
|
1031
1050
|
// () => (!focusable ? items.map((s, i) => (i > 6 ? { screenId: s.screenId } : s)) : items),
|
|
1032
1051
|
// [items, focusable],
|
|
1033
1052
|
// );
|
|
1034
1053
|
|
|
1054
|
+
|
|
1055
|
+
useEffect(function () {
|
|
1056
|
+
if (items.length === screensMounted.length) {
|
|
1057
|
+
return null;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
var timeout = setTimeout(function () {
|
|
1061
|
+
setScreensMounted([].concat(_toConsumableArray(screensMounted), [true]));
|
|
1062
|
+
}, 40);
|
|
1063
|
+
return function () {
|
|
1064
|
+
clearTimeout(timeout);
|
|
1065
|
+
};
|
|
1066
|
+
}, [items, screensMounted, setScreensMounted]);
|
|
1035
1067
|
return /*#__PURE__*/React.createElement("div", {
|
|
1036
1068
|
className: classNames([styles$9.container, _defineProperty({}, className, className !== null)]),
|
|
1037
1069
|
style: _objectSpread(_objectSpread({}, brandImageStyle), {}, {
|
|
@@ -1042,7 +1074,8 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1042
1074
|
className: styles$9.content,
|
|
1043
1075
|
ref: containerRef
|
|
1044
1076
|
}, /*#__PURE__*/React.createElement(Scroll, {
|
|
1045
|
-
className: styles$9.scroll
|
|
1077
|
+
className: styles$9.scroll,
|
|
1078
|
+
disabled: scrollDisabled
|
|
1046
1079
|
}, /*#__PURE__*/React.createElement("nav", {
|
|
1047
1080
|
className: styles$9.nav,
|
|
1048
1081
|
style: {
|
|
@@ -1052,38 +1085,36 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
1052
1085
|
className: styles$9.items
|
|
1053
1086
|
}, items.map(function (item, index) {
|
|
1054
1087
|
var _ref6 = item || {},
|
|
1055
|
-
screenId = _ref6.screenId
|
|
1056
|
-
_ref6$screen = _ref6.screen,
|
|
1057
|
-
screen = _ref6$screen === void 0 ? null : _ref6$screen;
|
|
1088
|
+
screenId = _ref6.screenId;
|
|
1058
1089
|
|
|
1059
1090
|
var itemStyles = {
|
|
1060
1091
|
width: "".concat(100 / thumbsPerLine, "%")
|
|
1061
1092
|
};
|
|
1093
|
+
|
|
1094
|
+
var _ref7 = screenSize || {},
|
|
1095
|
+
screenWidth = _ref7.width,
|
|
1096
|
+
screenHeight = _ref7.height;
|
|
1097
|
+
|
|
1098
|
+
var screenMounted = screensMounted[index] || false;
|
|
1062
1099
|
return /*#__PURE__*/React.createElement("li", {
|
|
1063
1100
|
key: "item-".concat(screenId),
|
|
1064
1101
|
className: styles$9.item,
|
|
1065
1102
|
style: itemStyles
|
|
1066
1103
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1067
|
-
className: styles$9.
|
|
1068
|
-
},
|
|
1069
|
-
className: styles$9.
|
|
1070
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1071
|
-
width: "10",
|
|
1072
|
-
height: "16",
|
|
1073
|
-
viewBox: "0 0 10 16",
|
|
1104
|
+
className: styles$9.inner
|
|
1105
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1106
|
+
className: classNames([styles$9.frame, _defineProperty({}, styles$9.isLoading, !screenMounted)]),
|
|
1074
1107
|
style: {
|
|
1075
|
-
|
|
1108
|
+
paddingBottom: "".concat(screenHeight / screenWidth * 100, "%")
|
|
1076
1109
|
}
|
|
1077
|
-
}, /*#__PURE__*/React.createElement(
|
|
1078
|
-
|
|
1079
|
-
height: "16"
|
|
1080
|
-
})) : /*#__PURE__*/React.createElement(ViewerMenuScreen, {
|
|
1110
|
+
}, screenMounted ? /*#__PURE__*/React.createElement(ViewerMenuScreen, {
|
|
1111
|
+
className: styles$9.screen,
|
|
1081
1112
|
item: item,
|
|
1082
1113
|
index: index,
|
|
1083
1114
|
screenSize: screenSize,
|
|
1084
1115
|
onClick: onClickScreen,
|
|
1085
1116
|
focusable: focusable
|
|
1086
|
-
})));
|
|
1117
|
+
}) : null)));
|
|
1087
1118
|
}))))));
|
|
1088
1119
|
};
|
|
1089
1120
|
|
|
@@ -1393,6 +1424,11 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1393
1424
|
shareOpened = _useState4[0],
|
|
1394
1425
|
setShareOpened = _useState4[1];
|
|
1395
1426
|
|
|
1427
|
+
var _useState5 = useState(false),
|
|
1428
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1429
|
+
menuMounted = _useState6[0],
|
|
1430
|
+
setMenuMounted = _useState6[1];
|
|
1431
|
+
|
|
1396
1432
|
var _useDimensionObserver = useDimensionObserver(),
|
|
1397
1433
|
navContainerRef = _useDimensionObserver.ref,
|
|
1398
1434
|
_useDimensionObserver2 = _useDimensionObserver.height,
|
|
@@ -1533,6 +1569,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1533
1569
|
springParams: springParams
|
|
1534
1570
|
}),
|
|
1535
1571
|
bindShareDrag = _useDragProgress.bind,
|
|
1572
|
+
draggingShare = _useDragProgress.dragging,
|
|
1536
1573
|
shareOpenedProgress = _useDragProgress.progress;
|
|
1537
1574
|
|
|
1538
1575
|
var computeMenuProgress = useCallback(function (_ref9) {
|
|
@@ -1580,6 +1617,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1580
1617
|
springParams: springParams
|
|
1581
1618
|
}),
|
|
1582
1619
|
bindMenuDrag = _useDragProgress2.bind,
|
|
1620
|
+
draggingMenu = _useDragProgress2.dragging,
|
|
1583
1621
|
menuOpenedProgress = _useDragProgress2.progress;
|
|
1584
1622
|
|
|
1585
1623
|
var keyboardShortcuts = useMemo(function () {
|
|
@@ -1595,6 +1633,13 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1595
1633
|
useKeyboardShortcuts(keyboardShortcuts); // should be zero if either screens menu or share menu is opened
|
|
1596
1634
|
|
|
1597
1635
|
var dotsOpacity = Math.min(1, Math.max(0, 1 - (menuOpenedProgress + shareOpenedProgress)));
|
|
1636
|
+
useEffect(function () {
|
|
1637
|
+
if ((menuOpened || draggingMenu) && !menuMounted) {
|
|
1638
|
+
setMenuMounted(true);
|
|
1639
|
+
} else if (!menuOpened && !draggingMenu && menuMounted) {
|
|
1640
|
+
setMenuMounted(false);
|
|
1641
|
+
}
|
|
1642
|
+
}, [menuOpened, draggingMenu, menuMounted, setMenuMounted]);
|
|
1598
1643
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1599
1644
|
className: classNames([styles$6.menuNavContainer, (_ref11 = {}, _defineProperty(_ref11, styles$6.withShadow, withShadow), _defineProperty(_ref11, styles$6.isOpened, menuOpened || shareOpened), _ref11)]),
|
|
1600
1645
|
ref: refDots,
|
|
@@ -1620,7 +1665,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1620
1665
|
theme: menuTheme,
|
|
1621
1666
|
iconPosition: "left"
|
|
1622
1667
|
}),
|
|
1623
|
-
|
|
1668
|
+
progressSpring: shareOpenedProgress
|
|
1624
1669
|
})) : null, !withoutScreensMenu ? /*#__PURE__*/React.createElement("div", Object.assign({
|
|
1625
1670
|
className: classNames([styles$6.menuItem, styles$6.menuItemScreens])
|
|
1626
1671
|
}, bindMenuDrag()), /*#__PURE__*/React.createElement(ToggleButton, {
|
|
@@ -1636,7 +1681,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1636
1681
|
theme: menuTheme,
|
|
1637
1682
|
iconPosition: "right"
|
|
1638
1683
|
}),
|
|
1639
|
-
|
|
1684
|
+
progressSpring: menuOpenedProgress,
|
|
1640
1685
|
toggledButtonClassName: styles$6.screensMenuButtonToggled
|
|
1641
1686
|
})) : null), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
|
|
1642
1687
|
direction: "horizontal",
|
|
@@ -1656,9 +1701,9 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1656
1701
|
}
|
|
1657
1702
|
}))), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
|
|
1658
1703
|
className: styles$6.menuContainer,
|
|
1659
|
-
|
|
1704
|
+
progressSpring: shareOpenedProgress,
|
|
1660
1705
|
theme: viewerTheme
|
|
1661
|
-
},
|
|
1706
|
+
}, draggingShare || shareOpened ? /*#__PURE__*/React.createElement(ViewerMenuShare, {
|
|
1662
1707
|
viewerTheme: viewerTheme,
|
|
1663
1708
|
className: styles$6.menuShare,
|
|
1664
1709
|
title: title,
|
|
@@ -1673,9 +1718,9 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1673
1718
|
onClose: onCloseShare
|
|
1674
1719
|
}) : null), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
|
|
1675
1720
|
className: styles$6.menuContainer,
|
|
1676
|
-
|
|
1721
|
+
progressSpring: menuOpenedProgress,
|
|
1677
1722
|
theme: viewerTheme
|
|
1678
|
-
},
|
|
1723
|
+
}, menuMounted ? /*#__PURE__*/React.createElement(ViewerMenuPreview, {
|
|
1679
1724
|
viewerTheme: viewerTheme,
|
|
1680
1725
|
className: styles$6.menuPreview,
|
|
1681
1726
|
screenSize: screenSize,
|
|
@@ -1687,6 +1732,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1687
1732
|
onShare: onShare,
|
|
1688
1733
|
onClickScreen: onClickScreen,
|
|
1689
1734
|
onClose: onCloseMenu,
|
|
1735
|
+
scrollDisabled: draggingMenu,
|
|
1690
1736
|
toggleFullscreen: toggleFullscreen,
|
|
1691
1737
|
fullscreenActive: fullscreenActive,
|
|
1692
1738
|
fullscreenEnabled: fullscreenEnabled
|
|
@@ -1695,6 +1741,7 @@ var ViewerMenu = function ViewerMenu(_ref) {
|
|
|
1695
1741
|
|
|
1696
1742
|
ViewerMenu.propTypes = propTypes$9;
|
|
1697
1743
|
ViewerMenu.defaultProps = defaultProps$9;
|
|
1744
|
+
var ViewerMenu$1 = /*#__PURE__*/React.memo(ViewerMenu);
|
|
1698
1745
|
|
|
1699
1746
|
var styles$5 = {"container":"micromag-viewer-screen-container","navigationHint":"micromag-viewer-screen-navigationHint"};
|
|
1700
1747
|
|
|
@@ -2769,34 +2816,48 @@ var Viewer = function Viewer(_ref) {
|
|
|
2769
2816
|
springParams: springParams
|
|
2770
2817
|
}),
|
|
2771
2818
|
isDragging = _useDragProgress.dragging,
|
|
2772
|
-
|
|
2819
|
+
progressSpring = _useDragProgress.progress,
|
|
2773
2820
|
dragContentBind = _useDragProgress.bind;
|
|
2774
2821
|
|
|
2775
|
-
var getScreenStylesByIndex = function getScreenStylesByIndex(index,
|
|
2822
|
+
var getScreenStylesByIndex = function getScreenStylesByIndex(index, spring) {
|
|
2776
2823
|
if (transitionType === 'stack') {
|
|
2777
|
-
var _t = index - progress;
|
|
2778
|
-
|
|
2779
|
-
var _clamped = Math.min(1, Math.max(0, _t));
|
|
2780
|
-
|
|
2781
|
-
var invert = Math.min(1, Math.max(0, -_t));
|
|
2782
|
-
var opacity = Math.max(0, 1 - 0.75 * invert + (_t + 1)); // just hide other screens
|
|
2783
|
-
|
|
2784
|
-
if (Math.abs(_t) > neighborScreensActive) return {
|
|
2785
|
-
opacity: 0
|
|
2786
|
-
};
|
|
2787
2824
|
return {
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2825
|
+
zIndex: index,
|
|
2826
|
+
opacity: spring.to(function (progress) {
|
|
2827
|
+
var t = index - progress;
|
|
2828
|
+
var invert = Math.min(1, Math.max(0, -t));
|
|
2829
|
+
if (Math.abs(t) > neighborScreensActive) return 0;
|
|
2830
|
+
return Math.max(0, 1 - 0.75 * invert + (t + 1));
|
|
2831
|
+
}),
|
|
2832
|
+
transform: spring.to(function (progress) {
|
|
2833
|
+
var t = index - progress;
|
|
2834
|
+
var clamped = Math.min(1, Math.max(0, t));
|
|
2835
|
+
var invert = Math.min(1, Math.max(0, -t));
|
|
2836
|
+
if (Math.abs(t) > neighborScreensActive) return 'translateX(100%)';
|
|
2837
|
+
return "translateX(".concat(clamped * 100, "%) scale(").concat(1 - 0.2 * invert, ")");
|
|
2838
|
+
}),
|
|
2839
|
+
boxShadow: spring.to(function (progress) {
|
|
2840
|
+
var t = index - progress;
|
|
2841
|
+
if (Math.abs(t) > neighborScreensActive) return null;
|
|
2842
|
+
var clamped = Math.min(1, Math.max(0, t));
|
|
2843
|
+
return "0 0 ".concat(4 * (1 - clamped), "rem ").concat(-0.5 * (1 - clamped), "rem black");
|
|
2844
|
+
})
|
|
2792
2845
|
};
|
|
2793
2846
|
}
|
|
2794
2847
|
|
|
2795
|
-
var t = index - progress;
|
|
2796
|
-
var clamped = Math.min(1, Math.max(0, Math.abs(t)));
|
|
2797
2848
|
return {
|
|
2798
|
-
opacity:
|
|
2799
|
-
|
|
2849
|
+
opacity: spring.to(function (progress) {
|
|
2850
|
+
var t = index - progress;
|
|
2851
|
+
if (Math.abs(t) > neighborScreensActive) return 0;
|
|
2852
|
+
var clamped = Math.min(1, Math.max(0, Math.abs(t)));
|
|
2853
|
+
return 1 - 0.75 * clamped;
|
|
2854
|
+
}),
|
|
2855
|
+
transform: spring.to(function (progress) {
|
|
2856
|
+
var t = index - progress;
|
|
2857
|
+
if (Math.abs(t) > neighborScreensActive) return "translate(100%)";
|
|
2858
|
+
var clamped = Math.min(1, Math.max(0, Math.abs(t)));
|
|
2859
|
+
return "translateX(".concat(t * neighborScreenOffset, "%) scale(").concat(1 - (1 - neighborScreenScale) * clamped, ")");
|
|
2860
|
+
}),
|
|
2800
2861
|
zIndex: screensCount - index
|
|
2801
2862
|
};
|
|
2802
2863
|
};
|
|
@@ -2882,7 +2943,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
2882
2943
|
}), (_ref15 = {}, _defineProperty(_ref15, styles$6.landscape, landscape), _defineProperty(_ref15, styles$6.withoutGestures, withoutGestures), _defineProperty(_ref15, styles$6.hideMenu, !menuVisible), _defineProperty(_ref15, styles$6.fadeMenu, playing && playbackControls && !playbackcontrolsVisible), _defineProperty(_ref15, styles$6.ready, ready || withoutScreensTransforms), _defineProperty(_ref15, styles$6.hasInteracted, hasInteracted), _defineProperty(_ref15, styles$6.isDragging, isDragging), _defineProperty(_ref15, className, className), _ref15)]),
|
|
2883
2944
|
ref: containerRef,
|
|
2884
2945
|
onContextMenu: onContextMenu
|
|
2885
|
-
}, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu, {
|
|
2946
|
+
}, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu$1, {
|
|
2886
2947
|
story: parsedStory,
|
|
2887
2948
|
currentScreenIndex: screenIndex,
|
|
2888
2949
|
withShadow: menuOverScreen && !withoutMenuShadow,
|
|
@@ -2917,8 +2978,8 @@ var Viewer = function Viewer(_ref) {
|
|
|
2917
2978
|
}, screens.map(function (screen, i) {
|
|
2918
2979
|
var current = screenIndex === i;
|
|
2919
2980
|
var active = i >= screenIndex - neighborScreensActive && i <= screenIndex + neighborScreensActive;
|
|
2920
|
-
var screenStyles = getScreenStylesByIndex(i,
|
|
2921
|
-
return /*#__PURE__*/React.createElement(
|
|
2981
|
+
var screenStyles = getScreenStylesByIndex(i, progressSpring);
|
|
2982
|
+
return /*#__PURE__*/React.createElement(animated.div, {
|
|
2922
2983
|
key: "screen-viewer-".concat(screen.id || '', "-").concat(i + 1),
|
|
2923
2984
|
style: screenStyles,
|
|
2924
2985
|
className: classNames([styles$6.screenContainer, _defineProperty({}, styles$6.current, current)])
|