@gxpl/sdk 0.0.15 → 0.0.18
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/lib/sdk/types/article/Item.d.ts +12 -1
- package/lib/sdk-nextjs/common/useKeyframeValue.js +6 -4
- package/lib/sdk-nextjs/components/Article.js +2 -2
- package/lib/sdk-nextjs/components/{ArticleWrapper.d.ts → Scene.d.ts} +1 -1
- package/lib/sdk-nextjs/components/{ArticleWrapper.js → Scene.js} +7 -6
- package/lib/sdk-nextjs/components/Section/Section.js +18 -18
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/CodeEmbedItem.js +2 -2
- package/lib/sdk-nextjs/components/items/CompoundItem/CompoundItem.js +3 -3
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/VimeoEmbed.js +4 -4
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/YoutubeEmbed.js +4 -4
- package/lib/sdk-nextjs/components/items/FileItem/ImageItem.js +2 -2
- package/lib/sdk-nextjs/components/items/FileItem/VideoItem.js +5 -5
- package/lib/sdk-nextjs/components/items/GroupItem/GroupItem.js +2 -2
- package/lib/sdk-nextjs/components/items/LinkWrapper.d.ts +2 -2
- package/lib/sdk-nextjs/components/items/LinkWrapper.js +22 -4
- package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +3 -3
- package/lib/sdk-nextjs/utils/ArticleRectManager/ArticleRectObserver.d.ts +3 -0
- package/lib/sdk-nextjs/utils/ArticleRectManager/ArticleRectObserver.js +34 -5
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +6 -6
- package/package.json +1 -1
|
@@ -193,10 +193,21 @@ export interface StickyParams {
|
|
|
193
193
|
from: number;
|
|
194
194
|
to?: number;
|
|
195
195
|
}
|
|
196
|
-
export
|
|
196
|
+
export type Link = UrlLink | ClickLink;
|
|
197
|
+
interface UrlLink {
|
|
197
198
|
url: string;
|
|
198
199
|
target: string;
|
|
199
200
|
}
|
|
201
|
+
interface UrlLink {
|
|
202
|
+
url: string;
|
|
203
|
+
target: string;
|
|
204
|
+
}
|
|
205
|
+
interface ClickLink {
|
|
206
|
+
value: string;
|
|
207
|
+
animation: 'fade' | 'slide' | 'reveal';
|
|
208
|
+
duration: number;
|
|
209
|
+
direction: 'north' | 'west' | 'south' | 'east';
|
|
210
|
+
}
|
|
200
211
|
export type VideoItem = Item<ArticleItemType.Video>;
|
|
201
212
|
export type RectangleItem = Item<ArticleItemType.Rectangle>;
|
|
202
213
|
export type ImageItem = Item<ArticleItemType.Image>;
|
|
@@ -49,8 +49,10 @@ function useKeyframeValue(item, type, itemParamsGetter, animatorGetter, sectionI
|
|
|
49
49
|
(0, react_1.useEffect)(() => {
|
|
50
50
|
if (!articleRectObserver || !animator)
|
|
51
51
|
return;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
return articleRectObserver.on('init', () => {
|
|
53
|
+
const scroll = articleRectObserver.getSectionScroll(sectionId);
|
|
54
|
+
handleKeyframeValue(scroll);
|
|
55
|
+
});
|
|
54
56
|
}, [articleRectObserver, handleKeyframeValue, animator]);
|
|
55
57
|
(0, react_1.useEffect)(() => {
|
|
56
58
|
if (!articleRectObserver || !animator)
|
|
@@ -59,7 +61,7 @@ function useKeyframeValue(item, type, itemParamsGetter, animatorGetter, sectionI
|
|
|
59
61
|
const scroll = articleRectObserver.getSectionScroll(sectionId);
|
|
60
62
|
handleKeyframeValue(scroll);
|
|
61
63
|
});
|
|
62
|
-
}, [
|
|
64
|
+
}, [articleRectObserver, handleKeyframeValue, animator]);
|
|
63
65
|
(0, react_1.useEffect)(() => {
|
|
64
66
|
if (!articleRectObserver || !animator)
|
|
65
67
|
return;
|
|
@@ -67,6 +69,6 @@ function useKeyframeValue(item, type, itemParamsGetter, animatorGetter, sectionI
|
|
|
67
69
|
const scroll = articleRectObserver.getSectionScroll(sectionId);
|
|
68
70
|
handleKeyframeValue(scroll);
|
|
69
71
|
});
|
|
70
|
-
}, [
|
|
72
|
+
}, [articleRectObserver, handleKeyframeValue, animator]);
|
|
71
73
|
return keyframes.length ? adjustedValue : paramValue;
|
|
72
74
|
}
|
|
@@ -11,7 +11,7 @@ const Section_1 = require("./Section/Section");
|
|
|
11
11
|
const Item_1 = require("./items/Item");
|
|
12
12
|
const useArticleRectObserver_1 = require("../utils/ArticleRectManager/useArticleRectObserver");
|
|
13
13
|
const ArticleRectContext_1 = require("../provider/ArticleRectContext");
|
|
14
|
-
const
|
|
14
|
+
const Scene_1 = require("./Scene");
|
|
15
15
|
const InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
16
16
|
const WebGLContextManagerContext_1 = require("../provider/WebGLContextManagerContext");
|
|
17
17
|
const effects_1 = require("@cntrl-site/effects");
|
|
@@ -31,7 +31,7 @@ const Article = ({ article, styles, keyframes }) => {
|
|
|
31
31
|
});
|
|
32
32
|
}, [articleRectObserver]);
|
|
33
33
|
const webglContextManager = (0, react_1.useMemo)(() => new effects_1.WebGLContextManager(), []);
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsxs)(InteractionsContext_1.InteractionsProvider, { article: article, children: [(0, jsx_runtime_1.jsx)(KeyframesContext_1.KeyframesContext.Provider, { value: keyframesRepo, children: (0, jsx_runtime_1.jsx)(
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsxs)(InteractionsContext_1.InteractionsProvider, { article: article, children: [(0, jsx_runtime_1.jsx)(KeyframesContext_1.KeyframesContext.Provider, { value: keyframesRepo, children: (0, jsx_runtime_1.jsx)(Scene_1.Scene, { id: article.id, styles: styles, children: (0, jsx_runtime_1.jsx)("div", { className: "article", ref: articleRef, children: (0, jsx_runtime_1.jsx)(WebGLContextManagerContext_1.WebglContextManagerContext.Provider, { value: webglContextManager, children: article.sections.map((section, i) => {
|
|
35
35
|
const data = {};
|
|
36
36
|
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { section: section, data: data, children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: section.id, articleHeight: articleHeight }, item.id))) }, section.id));
|
|
37
37
|
}) }) }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Scene = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const useLayoutDeviation_1 = require("../common/useLayoutDeviation");
|
|
7
7
|
const TransitionMachineContext_1 = require("../provider/TransitionMachineContext");
|
|
8
|
-
const
|
|
8
|
+
const Scene = ({ children, id, styles: sceneStyles }) => {
|
|
9
9
|
var _a;
|
|
10
10
|
const { layoutDeviation } = (0, useLayoutDeviation_1.useLayoutDeviation)();
|
|
11
11
|
const layoutDeviationStyle = { '--layout-deviation': layoutDeviation };
|
|
12
12
|
const sceneRef = (0, react_1.useRef)(null);
|
|
13
13
|
const actorRef = TransitionMachineContext_1.TransitionMachineContext.useActorRef();
|
|
14
|
-
const { isControlledTransitioning, isSettling, isInstantTransitioning } = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => ({
|
|
14
|
+
const { isControlledTransitioning, isSettling, isInstantTransitioning, stateValue } = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => ({
|
|
15
15
|
isControlledTransitioning: state.matches('transitioning'),
|
|
16
16
|
isSettling: state.matches('settling'),
|
|
17
17
|
isInstantTransitioning: state.matches('instant_transitioning'),
|
|
18
|
+
stateValue: state.value
|
|
18
19
|
}));
|
|
19
20
|
const type = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => {
|
|
20
21
|
const { transition } = state.context;
|
|
@@ -136,9 +137,9 @@ const ArticleWrapper = ({ children, id, styles: sceneStyles }) => {
|
|
|
136
137
|
}, [isTransitioning, actorRef, id]);
|
|
137
138
|
const isFixed = isControlledTransitioning || isSettling || isInstantTransitioning;
|
|
138
139
|
const transitionStyle = type === 'slide' ? 'transform' : 'opacity';
|
|
139
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: sceneRef, className: "article-wrapper", style: Object.assign(Object.assign({}, layoutDeviationStyle), { width: '100vw', height: '100%', position: isFixed ? 'fixed' : 'absolute', transform: `translate3d(${sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.x}px, ${sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.y}px, 0)`, transition: isSettling || isInstantTransitioning ? `${transitionStyle} 0.25s ease-out` : 'none', overflowY: isFixed ? 'hidden' : '
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { ref: sceneRef, className: "article-wrapper", style: Object.assign(Object.assign({}, layoutDeviationStyle), { width: '100vw', height: '100%', position: isFixed ? 'fixed' : 'absolute', transform: `translate3d(${sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.x}px, ${sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.y}px, 0)`, transition: isSettling || isInstantTransitioning ? `${transitionStyle} 0.25s ease-out` : 'none', overflowY: isFixed ? 'hidden' : 'scroll', opacity: (_a = sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.opacity) !== null && _a !== void 0 ? _a : 1 }), children: children }) }));
|
|
140
141
|
};
|
|
141
|
-
exports.
|
|
142
|
+
exports.Scene = Scene;
|
|
142
143
|
function isTransitionDisabled(transitionReady) {
|
|
143
144
|
return !transitionReady.north && !transitionReady.east && !transitionReady.south && !transitionReady.west;
|
|
144
145
|
}
|
|
@@ -153,7 +154,7 @@ function canTransition(direction, el) {
|
|
|
153
154
|
case 'north':
|
|
154
155
|
return el.scrollTop === 0;
|
|
155
156
|
case 'south': {
|
|
156
|
-
const isAllowed = el.scrollTop + el.clientHeight >= el.scrollHeight;
|
|
157
|
+
const isAllowed = el.scrollTop + el.clientHeight + 1 >= el.scrollHeight;
|
|
157
158
|
return isAllowed;
|
|
158
159
|
}
|
|
159
160
|
case 'west':
|
|
@@ -35,24 +35,24 @@ const Section = ({ section, data, children }) => {
|
|
|
35
35
|
transform: media.position === 'fixed' ? 'translateY(-100vh)' : 'unset',
|
|
36
36
|
height: media.position === 'fixed' ? `calc(${getSectionHeight(height)} + 200vh)` : getSectionHeight(height)
|
|
37
37
|
}, children: [media.type === 'video' && ((0, jsx_runtime_1.jsx)(SectionVideo_1.SectionVideo, { container: sectionRef.current, sectionId: section.id, media: media })), media.type === 'image' && ((0, jsx_runtime_1.jsx)(SectionImage_1.SectionImage, { media: media, sectionId: section.id }))] }, `section-background-wrapper-${section.id}`) })), children] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
.section-${section.id} {
|
|
39
|
+
height: ${getSectionHeight(height)};
|
|
40
|
+
position: relative;
|
|
41
|
+
display: ${hidden ? 'none' : 'block'};
|
|
42
|
+
background-color: ${color_1.CntrlColor.parse(color !== null && color !== void 0 ? color : DEFAULT_COLOR).fmt('rgba')};
|
|
43
|
+
}
|
|
44
|
+
.section-background-overlay-${section.id} {
|
|
45
|
+
height: ${getSectionHeight(height)};
|
|
46
|
+
width: 100%;
|
|
47
|
+
position: relative;
|
|
48
|
+
overflow: clip;
|
|
49
|
+
}
|
|
50
|
+
.section-background-wrapper-${section.id} {
|
|
51
|
+
transform: ${(media === null || media === void 0 ? void 0 : media.position) === 'fixed' ? 'translateY(-100vh)' : 'unset'};
|
|
52
|
+
position: relative;
|
|
53
|
+
height: ${(media === null || media === void 0 ? void 0 : media.position) === 'fixed' ? `calc(${getSectionHeight(height)} + 200vh)` : getSectionHeight(height)};
|
|
54
|
+
width: 100%;
|
|
55
|
+
}
|
|
56
56
|
` })] }));
|
|
57
57
|
};
|
|
58
58
|
exports.Section = Section;
|
|
@@ -16,7 +16,7 @@ const useCodeEmbedItem_1 = require("./useCodeEmbedItem");
|
|
|
16
16
|
const FontFaceGenerator_1 = require("../../../../sdk/FontFaceGenerator/FontFaceGenerator");
|
|
17
17
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
18
18
|
const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
20
|
const id = (0, react_1.useId)();
|
|
21
21
|
const { fonts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
22
22
|
const fontGoogleTags = fonts === null || fonts === void 0 ? void 0 : fonts.google;
|
|
@@ -71,7 +71,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
71
71
|
(0, react_1.useEffect)(() => {
|
|
72
72
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
73
73
|
}, [isInteractive, onVisibilityChange]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, {
|
|
74
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { link: item.link, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign({ transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_h = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _h !== void 0 ? _h : 'none' }), ref: setRef, children: item.params.iframe ? ((0, jsx_runtime_1.jsx)("iframe", { "data-embed": item.id, className: `embed-${item.id}`, style: {
|
|
75
75
|
border: 'unset'
|
|
76
76
|
} })) : ((0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, dangerouslySetInnerHTML: { __html: html } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
77
77
|
.embed-wrapper-${item.id} {
|
|
@@ -14,7 +14,7 @@ const style_1 = __importDefault(require("styled-jsx/style"));
|
|
|
14
14
|
const CompoundChild_1 = require("./CompoundChild");
|
|
15
15
|
const useCompoundItem_1 = require("./useCompoundItem");
|
|
16
16
|
const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
17
|
-
var _a, _b, _c
|
|
17
|
+
var _a, _b, _c;
|
|
18
18
|
const id = (0, react_1.useId)();
|
|
19
19
|
const { items } = item;
|
|
20
20
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -28,10 +28,10 @@ const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
|
|
|
28
28
|
(0, react_1.useEffect)(() => {
|
|
29
29
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
30
30
|
}, [isInteractive, onVisibilityChange]);
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, {
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: item.link, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style: {
|
|
32
32
|
opacity,
|
|
33
33
|
transform: `rotate(${angle}deg)`,
|
|
34
|
-
transition: (
|
|
34
|
+
transition: (_c = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _c !== void 0 ? _c : 'none'
|
|
35
35
|
}, children: items && items.map(item => ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
36
36
|
.compound-${item.id} {
|
|
37
37
|
overflow: ${item.params.overflow};
|
|
@@ -23,7 +23,7 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
23
23
|
const useEmbedVideoItem_1 = require("./useEmbedVideoItem");
|
|
24
24
|
const LinkWrapper_1 = require("../LinkWrapper");
|
|
25
25
|
const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
27
27
|
const id = (0, react_1.useId)();
|
|
28
28
|
const { radius: itemRadius, blur: itemBlur, opacity: itemOpacity } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
|
|
29
29
|
const [iframeRef, setIframeRef] = (0, react_1.useState)(null);
|
|
@@ -110,7 +110,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
}, [interactionCtrl, vimeoPlayer]);
|
|
113
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, {
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { link: item.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign({ opacity, transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_e = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), onMouseEnter: () => {
|
|
114
114
|
if (!vimeoPlayer || params.play !== 'on-hover')
|
|
115
115
|
return;
|
|
116
116
|
vimeoPlayer.play();
|
|
@@ -118,7 +118,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
118
118
|
if (!vimeoPlayer || params.play !== 'on-hover')
|
|
119
119
|
return;
|
|
120
120
|
vimeoPlayer.pause();
|
|
121
|
-
}, children: [params.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick(), src: (
|
|
121
|
+
}, children: [params.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick(), src: (_f = params.coverUrl) !== null && _f !== void 0 ? _f : '', style: {
|
|
122
122
|
display: isCoverVisible ? 'block' : 'none',
|
|
123
123
|
cursor: 'pointer',
|
|
124
124
|
position: 'absolute',
|
|
@@ -135,7 +135,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
135
135
|
left: '0'
|
|
136
136
|
} })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: {
|
|
137
137
|
borderRadius: `${radius * 100}vw`,
|
|
138
|
-
transition: (
|
|
138
|
+
transition: (_g = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _g !== void 0 ? _g : 'none'
|
|
139
139
|
} })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
140
140
|
.embed-video-wrapper-${item.id} {
|
|
141
141
|
position: absolute;
|
|
@@ -15,7 +15,7 @@ const useYouTubeIframeApi_1 = require("../../../utils/Youtube/useYouTubeIframeAp
|
|
|
15
15
|
const useRegisterResize_1 = require("../../../common/useRegisterResize");
|
|
16
16
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
17
17
|
const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
19
|
const id = (0, react_1.useId)();
|
|
20
20
|
const { url } = item.params;
|
|
21
21
|
const params = item.params;
|
|
@@ -108,7 +108,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}, [interactionCtrl, player]);
|
|
111
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, {
|
|
111
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { link: item.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
112
112
|
if (!player || params.play !== 'on-hover')
|
|
113
113
|
return;
|
|
114
114
|
player.playVideo();
|
|
@@ -116,7 +116,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
116
116
|
if (!player || params.play !== 'on-hover')
|
|
117
117
|
return;
|
|
118
118
|
player.pauseVideo();
|
|
119
|
-
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
119
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_e = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _e !== void 0 ? _e : 'none' }), children: [params.coverUrl && ((0, jsx_runtime_1.jsx)("img", { ref: setImgRef, onClick: () => onCoverClick(), src: (_f = params.coverUrl) !== null && _f !== void 0 ? _f : '', style: {
|
|
120
120
|
display: isCoverVisible ? 'block' : 'none',
|
|
121
121
|
cursor: 'pointer',
|
|
122
122
|
position: 'absolute',
|
|
@@ -126,7 +126,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
126
126
|
top: '0',
|
|
127
127
|
left: '0',
|
|
128
128
|
zIndex: 1
|
|
129
|
-
}, alt: "Cover img" })), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (
|
|
129
|
+
}, alt: "Cover img" })), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_g = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _g !== void 0 ? _g : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
130
130
|
.embed-youtube-video-wrapper-${item.id},
|
|
131
131
|
.embed-${item.id} {
|
|
132
132
|
position: absolute;
|
|
@@ -18,7 +18,7 @@ const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
|
18
18
|
const getFill_1 = require("../../../utils/getFill");
|
|
19
19
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
20
20
|
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
22
22
|
const id = (0, react_1.useId)();
|
|
23
23
|
const { radius: itemRadius, strokeWidth: itemStrokeWidth, opacity: itemOpacity, strokeFill: itemStrokeFill, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
24
24
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -65,7 +65,7 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
65
65
|
(0, react_1.useEffect)(() => {
|
|
66
66
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
67
67
|
}, [isInteractive, onVisibilityChange]);
|
|
68
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, {
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: item.link, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign({ opacity, transform: `rotate(${angle}deg)` }, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none' }), children: hasGLEffect && isFXAllowed
|
|
69
69
|
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight }))
|
|
70
70
|
: ((0, jsx_runtime_1.jsx)("img", { alt: "", className: `image image-${item.id}`, style: inlineStyles, src: item.params.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
71
71
|
.image-wrapper-${item.id} {
|
|
@@ -19,7 +19,7 @@ const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
|
19
19
|
const getFill_1 = require("../../../utils/getFill");
|
|
20
20
|
const useExemplary_1 = require("../../../common/useExemplary");
|
|
21
21
|
const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
23
23
|
const id = (0, react_1.useId)();
|
|
24
24
|
const { radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, opacity: itemOpacity, blur: itemBlur } = (0, useFileItem_1.useFileItem)(item, sectionId);
|
|
25
25
|
const [isVideoPlaying, setIsVideoPlaying] = (0, react_1.useState)(false);
|
|
@@ -91,13 +91,13 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
91
91
|
observer.observe(ref);
|
|
92
92
|
return () => observer.disconnect();
|
|
93
93
|
}, [videoRef, ref, userPaused, isVideoInteracted]);
|
|
94
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, {
|
|
94
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { link: item.link, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: {
|
|
95
95
|
opacity,
|
|
96
96
|
transform: `rotate(${angle}deg)`,
|
|
97
97
|
filter: `blur(${blur * 100}vw)`,
|
|
98
98
|
willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
|
|
99
|
-
transition: (
|
|
100
|
-
}, children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.params.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (
|
|
99
|
+
transition: (_o = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _o !== void 0 ? _o : 'none'
|
|
100
|
+
}, children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.params.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}` })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (_p = item.params.coverUrl) !== null && _p !== void 0 ? _p : '', ref: setVideoRef, autoPlay: params.play === 'auto', preload: "auto", onClick: () => {
|
|
101
101
|
setIsVideoInteracted(true);
|
|
102
102
|
}, muted: params.muted, onPlay: () => {
|
|
103
103
|
setIsVideoPlaying(true);
|
|
@@ -120,7 +120,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
120
120
|
return;
|
|
121
121
|
setIsVideoInteracted(true);
|
|
122
122
|
videoRef.play();
|
|
123
|
-
}, src: (
|
|
123
|
+
}, src: (_q = item.params.coverUrl) !== null && _q !== void 0 ? _q : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
124
124
|
if (!videoRef)
|
|
125
125
|
return;
|
|
126
126
|
setIsVideoInteracted(true);
|
|
@@ -15,7 +15,7 @@ const useGroupItem_1 = require("./useGroupItem");
|
|
|
15
15
|
const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromItemStateAndParams");
|
|
16
16
|
const CompoundChild_1 = require("../CompoundItem/CompoundChild");
|
|
17
17
|
const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange, isInCompound }) => {
|
|
18
|
-
var _a, _b, _c, _d
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
19
|
const id = (0, react_1.useId)();
|
|
20
20
|
const { items } = item;
|
|
21
21
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -30,7 +30,7 @@ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
30
30
|
(0, react_1.useEffect)(() => {
|
|
31
31
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
32
32
|
}, [isInteractive, onVisibilityChange]);
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, {
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: item.link, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (_d = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _d !== void 0 ? _d : 'none', willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), children: items && items.map(item => isInCompound ? ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id)) : ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, isParentVisible: isInteractive, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
34
34
|
.group-${item.id} {
|
|
35
35
|
position: absolute;
|
|
36
36
|
width: 100%;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Link } from '../../../sdk/types/article/Item';
|
|
2
3
|
interface Props {
|
|
3
|
-
url?: string;
|
|
4
4
|
children: ReactElement | ReactNode[];
|
|
5
|
-
|
|
5
|
+
link?: Link;
|
|
6
6
|
}
|
|
7
7
|
export declare const LinkWrapper: React.FC<Props>;
|
|
8
8
|
export {};
|
|
@@ -2,10 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
const TransitionMachineContext_1 = require("../../provider/TransitionMachineContext");
|
|
6
|
+
const LinkWrapper = ({ link, children }) => {
|
|
7
|
+
const actorRef = TransitionMachineContext_1.TransitionMachineContext.useActorRef();
|
|
8
|
+
const validUrl = link && 'url' in link ? buildValidUrl(link.url) : 'javascript:void(0)';
|
|
9
|
+
const targetParams = link && 'target' in link && link.target === '_blank' ? { target: link.target, rel: 'noreferrer' } : {};
|
|
10
|
+
const handleGoToScene = () => {
|
|
11
|
+
if (!actorRef || !link || !('value' in link))
|
|
12
|
+
return;
|
|
13
|
+
actorRef.send({
|
|
14
|
+
type: 'TRANSITION_TRIGGER',
|
|
15
|
+
transition: link.animation,
|
|
16
|
+
to: link.value,
|
|
17
|
+
direction: link.direction
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
if (validUrl) {
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: validUrl }, targetParams, { children: children })));
|
|
22
|
+
}
|
|
23
|
+
if (link && 'value' in link) {
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("a", { onClick: handleGoToScene, role: "button", children: children }));
|
|
25
|
+
}
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
9
27
|
};
|
|
10
28
|
exports.LinkWrapper = LinkWrapper;
|
|
11
29
|
function buildValidUrl(url) {
|
|
@@ -15,7 +15,7 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
15
15
|
const getFill_1 = require("../../../utils/getFill");
|
|
16
16
|
const areFillsVisible_1 = require("../../../utils/areFillsVisible/areFillsVisible");
|
|
17
17
|
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19
19
|
const id = (0, react_1.useId)();
|
|
20
20
|
const { fill: itemFill, radius: itemRadius, strokeWidth: itemStrokeWidth, strokeFill: itemStrokeFill, blur: itemBlur, backdropBlur: itemBackdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
|
|
21
21
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -40,13 +40,13 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
40
40
|
const stroke = strokeFill
|
|
41
41
|
? (_h = (0, getFill_1.getFill)(strokeFill)) !== null && _h !== void 0 ? _h : 'transparent'
|
|
42
42
|
: 'transparent';
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, {
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: item.link, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (strokeFill ? Object.assign({ borderColor: stroke, borderWidth: strokeWidth !== undefined ? `${strokeWidth * 100}vw` : 0, borderRadius: radius !== undefined ? `${radius * 100}vw` : 'inherit', borderStyle: 'solid' }, (strokeFill.type === 'image' ? {
|
|
44
44
|
backgroundPosition: 'center',
|
|
45
45
|
backgroundSize: strokeFill.behavior === 'repeat' ? `${strokeFill.backgroundSize}%` : strokeFill.behavior,
|
|
46
46
|
backgroundRepeat: strokeFill.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
47
47
|
} : {})) : {})), { borderRadius: `${radius * 100}vw` }), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
48
48
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
49
|
-
: {})), { transition: (
|
|
49
|
+
: {})), { transition: (_j = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _j !== void 0 ? _j : 'none' }), children: itemFill && itemFill.map((fill, i) => {
|
|
50
50
|
var _a, _b;
|
|
51
51
|
const stateFillLayer = stateFillLayers === null || stateFillLayers === void 0 ? void 0 : stateFillLayers.find((layer) => layer.id === fill.id);
|
|
52
52
|
const value = stateFillLayer
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from '../EventEmitter';
|
|
2
2
|
interface EventMap {
|
|
3
|
+
'init': undefined;
|
|
3
4
|
'scroll': undefined;
|
|
4
5
|
'resize': DOMRect;
|
|
5
6
|
}
|
|
@@ -11,6 +12,8 @@ export declare class ArticleRectObserver extends EventEmitter<EventMap> {
|
|
|
11
12
|
private animationFrame;
|
|
12
13
|
private parent;
|
|
13
14
|
private sectionsScrollMap;
|
|
15
|
+
private previousParentWidth;
|
|
16
|
+
private isInitialized;
|
|
14
17
|
constructor();
|
|
15
18
|
get scroll(): number;
|
|
16
19
|
getSectionScroll(sectionId: string): number;
|
|
@@ -9,12 +9,14 @@ const resize_observer_polyfill_1 = __importDefault(require("resize-observer-poly
|
|
|
9
9
|
class ArticleRectObserver extends EventEmitter_1.EventEmitter {
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
|
-
this.articleWidth =
|
|
12
|
+
this.articleWidth = 1;
|
|
13
13
|
this.registry = new Map();
|
|
14
14
|
this.scrollPos = window.scrollY;
|
|
15
15
|
this.animationFrame = NaN;
|
|
16
16
|
this.parent = undefined;
|
|
17
17
|
this.sectionsScrollMap = new Map();
|
|
18
|
+
this.previousParentWidth = null;
|
|
19
|
+
this.isInitialized = false;
|
|
18
20
|
this.handleScroll = (scroll) => {
|
|
19
21
|
this.setScroll(scroll / this.articleWidth);
|
|
20
22
|
};
|
|
@@ -41,8 +43,17 @@ class ArticleRectObserver extends EventEmitter_1.EventEmitter {
|
|
|
41
43
|
}
|
|
42
44
|
init(parent) {
|
|
43
45
|
this.parent = parent;
|
|
46
|
+
const scrollableParent = parent.parentElement;
|
|
47
|
+
const parentBoundary = parent.getBoundingClientRect();
|
|
48
|
+
if (!scrollableParent) {
|
|
49
|
+
throw new Error('Scrollable parent not found');
|
|
50
|
+
}
|
|
51
|
+
const articleWidth = parentBoundary.width;
|
|
52
|
+
this.articleWidth = articleWidth;
|
|
53
|
+
this.previousParentWidth = articleWidth;
|
|
54
|
+
this.setScroll(scrollableParent.scrollTop / articleWidth);
|
|
44
55
|
const onScroll = () => {
|
|
45
|
-
this.handleScroll(
|
|
56
|
+
this.handleScroll(scrollableParent.scrollTop);
|
|
46
57
|
if (!isNaN(this.animationFrame))
|
|
47
58
|
return;
|
|
48
59
|
this.animationFrame = window.requestAnimationFrame(() => {
|
|
@@ -50,10 +61,21 @@ class ArticleRectObserver extends EventEmitter_1.EventEmitter {
|
|
|
50
61
|
this.emit('scroll', undefined);
|
|
51
62
|
});
|
|
52
63
|
};
|
|
53
|
-
|
|
64
|
+
scrollableParent.addEventListener('scroll', onScroll);
|
|
65
|
+
for (const sectionId of this.registry.keys()) {
|
|
66
|
+
const el = this.registry.get(sectionId);
|
|
67
|
+
if (!el)
|
|
68
|
+
continue;
|
|
69
|
+
const rect = el.getBoundingClientRect();
|
|
70
|
+
this.sectionsScrollMap.set(sectionId, rect.top - parentBoundary.top);
|
|
71
|
+
}
|
|
72
|
+
this.isInitialized = true;
|
|
73
|
+
this.emit('init', undefined);
|
|
54
74
|
return () => {
|
|
55
75
|
this.parent = undefined;
|
|
56
|
-
|
|
76
|
+
this.isInitialized = false;
|
|
77
|
+
this.previousParentWidth = null;
|
|
78
|
+
scrollableParent.removeEventListener('scroll', onScroll);
|
|
57
79
|
if (!isNaN(this.animationFrame)) {
|
|
58
80
|
window.cancelAnimationFrame(this.animationFrame);
|
|
59
81
|
this.animationFrame = NaN;
|
|
@@ -72,7 +94,14 @@ class ArticleRectObserver extends EventEmitter_1.EventEmitter {
|
|
|
72
94
|
if (!this.parent)
|
|
73
95
|
return;
|
|
74
96
|
const parentBoundary = this.parent.getBoundingClientRect();
|
|
75
|
-
|
|
97
|
+
const newWidth = parentBoundary.width;
|
|
98
|
+
if (!this.isInitialized || this.previousParentWidth === newWidth) {
|
|
99
|
+
this.articleWidth = newWidth;
|
|
100
|
+
this.previousParentWidth = newWidth;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.articleWidth = newWidth;
|
|
104
|
+
this.previousParentWidth = newWidth;
|
|
76
105
|
this.setScroll(window.scrollY / this.articleWidth);
|
|
77
106
|
this.emit('resize', parentBoundary);
|
|
78
107
|
for (const sectionId of this.registry.keys()) {
|
|
@@ -13,7 +13,7 @@ exports.FontStyles = {
|
|
|
13
13
|
};
|
|
14
14
|
class RichTextConverter {
|
|
15
15
|
toHtml(richText, exemplary) {
|
|
16
|
-
var _a, _b, _c, _d, _e;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17
17
|
const { text, blocks = [] } = richText.params;
|
|
18
18
|
const root = [];
|
|
19
19
|
const styleRules = [];
|
|
@@ -72,7 +72,7 @@ class RichTextConverter {
|
|
|
72
72
|
offset = entity.end;
|
|
73
73
|
}
|
|
74
74
|
if (entity.link) {
|
|
75
|
-
kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: entity.link, target: entity.target, children: entityKids }, entity.start));
|
|
75
|
+
kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: { url: entity.link, target: (_e = entity.target) !== null && _e !== void 0 ? _e : '_self', animation: (_f = entity.animation) !== null && _f !== void 0 ? _f : 'fade', direction: (_g = entity.direction) !== null && _g !== void 0 ? _g : 'north' }, children: entityKids }, entity.start));
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
78
|
kids.push(...entityKids);
|
|
@@ -81,7 +81,7 @@ class RichTextConverter {
|
|
|
81
81
|
kids.push(sliceSymbols(content, offset));
|
|
82
82
|
}
|
|
83
83
|
for (const styles of group) {
|
|
84
|
-
const entitiesGroups = (
|
|
84
|
+
const entitiesGroups = (_h = this.groupEntities(entities, styles)) !== null && _h !== void 0 ? _h : [];
|
|
85
85
|
for (const entitiesGroup of entitiesGroups) {
|
|
86
86
|
if (!entitiesGroup.stylesGroup)
|
|
87
87
|
continue;
|
|
@@ -147,7 +147,7 @@ class RichTextConverter {
|
|
|
147
147
|
return styleGroups;
|
|
148
148
|
}
|
|
149
149
|
groupEntities(entities, styleGroups) {
|
|
150
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
150
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
151
151
|
const entitiesGroups = [];
|
|
152
152
|
if (!entities.length && !styleGroups)
|
|
153
153
|
return;
|
|
@@ -167,7 +167,7 @@ class RichTextConverter {
|
|
|
167
167
|
const end = dividers[i + 1];
|
|
168
168
|
const entity = entities.find(e => e.start === start);
|
|
169
169
|
entitiesGroups.push(Object.assign({ stylesGroup: [], start,
|
|
170
|
-
end }, (entity && { link: (_b = (_a = entity.data) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '', target: (_d = (_c = entity.data) === null || _c === void 0 ? void 0 : _c.target) !== null && _d !== void 0 ? _d : '_self' })));
|
|
170
|
+
end }, (entity && { link: (_b = (_a = entity.data) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '', target: (_d = (_c = entity.data) === null || _c === void 0 ? void 0 : _c.target) !== null && _d !== void 0 ? _d : '_self', animation: (_f = (_e = entity.data) === null || _e === void 0 ? void 0 : _e.animation) !== null && _f !== void 0 ? _f : 'fade', direction: (_h = (_g = entity.data) === null || _g === void 0 ? void 0 : _g.direction) !== null && _h !== void 0 ? _h : 'north' })));
|
|
171
171
|
}
|
|
172
172
|
return entitiesGroups;
|
|
173
173
|
}
|
|
@@ -194,7 +194,7 @@ class RichTextConverter {
|
|
|
194
194
|
const end = entityDividers[i + 1];
|
|
195
195
|
const entity = entities.find(e => e.start === start);
|
|
196
196
|
entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
|
|
197
|
-
end }, (entity && { link: (
|
|
197
|
+
end }, (entity && { link: (_k = (_j = entity.data) === null || _j === void 0 ? void 0 : _j.url) !== null && _k !== void 0 ? _k : '', target: (_m = (_l = entity.data) === null || _l === void 0 ? void 0 : _l.target) !== null && _m !== void 0 ? _m : '_self', animation: (_p = (_o = entity.data) === null || _o === void 0 ? void 0 : _o.animation) !== null && _p !== void 0 ? _p : 'fade', direction: (_r = (_q = entity.data) === null || _q === void 0 ? void 0 : _q.direction) !== null && _r !== void 0 ? _r : 'north' })));
|
|
198
198
|
}
|
|
199
199
|
return entitiesGroups;
|
|
200
200
|
}
|