@gxpl/sdk 0.0.39 → 0.0.41
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/transitions/transitionMachine.d.ts +27 -0
- package/lib/sdk/transitions/transitionMachine.js +11 -16
- package/lib/sdk/transitions/utils/getDeltaAndProgress.d.ts +1 -1
- package/lib/sdk/transitions/utils/getDeltaAndProgress.js +1 -1
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.d.ts +1 -1
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +3 -3
- package/lib/sdk/transitions/utils/getScenesOnStart.d.ts +1 -1
- package/lib/sdk/transitions/utils/getScenesOnStart.js +5 -5
- package/lib/sdk/transitions/utils/types.d.ts +2 -0
- package/lib/sdk/types/article/Interaction.d.ts +6 -1
- package/lib/sdk-nextjs/components/Page.js +3 -8
- package/lib/sdk-nextjs/components/Preview/PreviewListener.js +1 -0
- package/lib/sdk-nextjs/components/Scene.js +42 -6
- package/lib/sdk-nextjs/components/items/LinkWrapper.js +1 -0
- package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +16 -9
- package/lib/sdk-nextjs/components/items/RichTextItem/RichTextItem.js +1 -1
- package/lib/sdk-nextjs/fixedLayers/FixedLayerTransitionsRegistry.d.ts +1 -1
- package/lib/sdk-nextjs/fixedLayers/FixedLayerTransitionsRegistry.js +2 -2
- package/lib/sdk-nextjs/interactions/InteractionsRegistry.d.ts +9 -1
- package/lib/sdk-nextjs/interactions/InteractionsRegistry.js +100 -3
- package/lib/sdk-nextjs/provider/InOutTransitionContext.d.ts +8 -0
- package/lib/sdk-nextjs/provider/InOutTransitionContext.js +14 -0
- package/lib/sdk-nextjs/provider/InteractionsContext.js +10 -2
- package/lib/sdk-nextjs/provider/TransitionMachineContext.d.ts +96 -0
- package/lib/sdk-nextjs/provider/TransitionMachineContextProvider.d.ts +11 -0
- package/lib/sdk-nextjs/provider/TransitionMachineContextProvider.js +18 -0
- package/package.json +2 -1
|
@@ -10,10 +10,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
10
10
|
transition: "slide";
|
|
11
11
|
to: string;
|
|
12
12
|
direction: Direction;
|
|
13
|
+
duration: number;
|
|
13
14
|
} | {
|
|
14
15
|
type: "TRANSITION_TRIGGER";
|
|
15
16
|
transition: "fade";
|
|
16
17
|
to: string;
|
|
18
|
+
duration: number;
|
|
17
19
|
} | {
|
|
18
20
|
type: "SWIPE_START";
|
|
19
21
|
direction: Direction;
|
|
@@ -84,10 +86,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
84
86
|
transition: "slide";
|
|
85
87
|
to: string;
|
|
86
88
|
direction: Direction;
|
|
89
|
+
duration: number;
|
|
87
90
|
} | {
|
|
88
91
|
type: "TRANSITION_TRIGGER";
|
|
89
92
|
transition: "fade";
|
|
90
93
|
to: string;
|
|
94
|
+
duration: number;
|
|
91
95
|
} | {
|
|
92
96
|
type: "SWIPE_START";
|
|
93
97
|
direction: Direction;
|
|
@@ -118,10 +122,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
118
122
|
transition: "slide";
|
|
119
123
|
to: string;
|
|
120
124
|
direction: Direction;
|
|
125
|
+
duration: number;
|
|
121
126
|
} | {
|
|
122
127
|
type: "TRANSITION_TRIGGER";
|
|
123
128
|
transition: "fade";
|
|
124
129
|
to: string;
|
|
130
|
+
duration: number;
|
|
125
131
|
} | {
|
|
126
132
|
type: "SWIPE_START";
|
|
127
133
|
direction: Direction;
|
|
@@ -175,10 +181,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
175
181
|
transition: "slide";
|
|
176
182
|
to: string;
|
|
177
183
|
direction: Direction;
|
|
184
|
+
duration: number;
|
|
178
185
|
} | {
|
|
179
186
|
type: "TRANSITION_TRIGGER";
|
|
180
187
|
transition: "fade";
|
|
181
188
|
to: string;
|
|
189
|
+
duration: number;
|
|
182
190
|
} | {
|
|
183
191
|
type: "SWIPE_START";
|
|
184
192
|
direction: Direction;
|
|
@@ -211,10 +219,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
211
219
|
transition: "slide";
|
|
212
220
|
to: string;
|
|
213
221
|
direction: Direction;
|
|
222
|
+
duration: number;
|
|
214
223
|
} | {
|
|
215
224
|
type: "TRANSITION_TRIGGER";
|
|
216
225
|
transition: "fade";
|
|
217
226
|
to: string;
|
|
227
|
+
duration: number;
|
|
218
228
|
}, {
|
|
219
229
|
type: "SWIPE_PREPARE";
|
|
220
230
|
touchData: {
|
|
@@ -226,10 +236,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
226
236
|
transition: "slide";
|
|
227
237
|
to: string;
|
|
228
238
|
direction: Direction;
|
|
239
|
+
duration: number;
|
|
229
240
|
} | {
|
|
230
241
|
type: "TRANSITION_TRIGGER";
|
|
231
242
|
transition: "fade";
|
|
232
243
|
to: string;
|
|
244
|
+
duration: number;
|
|
233
245
|
} | {
|
|
234
246
|
type: "SWIPE_START";
|
|
235
247
|
direction: Direction;
|
|
@@ -279,10 +291,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
279
291
|
transition: "slide";
|
|
280
292
|
to: string;
|
|
281
293
|
direction: Direction;
|
|
294
|
+
duration: number;
|
|
282
295
|
} | {
|
|
283
296
|
type: "TRANSITION_TRIGGER";
|
|
284
297
|
transition: "fade";
|
|
285
298
|
to: string;
|
|
299
|
+
duration: number;
|
|
286
300
|
} | {
|
|
287
301
|
type: "SWIPE_START";
|
|
288
302
|
direction: Direction;
|
|
@@ -323,10 +337,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
323
337
|
transition: "slide";
|
|
324
338
|
to: string;
|
|
325
339
|
direction: Direction;
|
|
340
|
+
duration: number;
|
|
326
341
|
} | {
|
|
327
342
|
type: "TRANSITION_TRIGGER";
|
|
328
343
|
transition: "fade";
|
|
329
344
|
to: string;
|
|
345
|
+
duration: number;
|
|
330
346
|
} | {
|
|
331
347
|
type: "SWIPE_START";
|
|
332
348
|
direction: Direction;
|
|
@@ -374,10 +390,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
374
390
|
transition: "slide";
|
|
375
391
|
to: string;
|
|
376
392
|
direction: Direction;
|
|
393
|
+
duration: number;
|
|
377
394
|
} | {
|
|
378
395
|
type: "TRANSITION_TRIGGER";
|
|
379
396
|
transition: "fade";
|
|
380
397
|
to: string;
|
|
398
|
+
duration: number;
|
|
381
399
|
} | {
|
|
382
400
|
type: "SWIPE_START";
|
|
383
401
|
direction: Direction;
|
|
@@ -418,10 +436,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
418
436
|
transition: "slide";
|
|
419
437
|
to: string;
|
|
420
438
|
direction: Direction;
|
|
439
|
+
duration: number;
|
|
421
440
|
} | {
|
|
422
441
|
type: "TRANSITION_TRIGGER";
|
|
423
442
|
transition: "fade";
|
|
424
443
|
to: string;
|
|
444
|
+
duration: number;
|
|
425
445
|
} | {
|
|
426
446
|
type: "SWIPE_START";
|
|
427
447
|
direction: Direction;
|
|
@@ -465,10 +485,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
465
485
|
transition: "slide";
|
|
466
486
|
to: string;
|
|
467
487
|
direction: Direction;
|
|
488
|
+
duration: number;
|
|
468
489
|
} | {
|
|
469
490
|
type: "TRANSITION_TRIGGER";
|
|
470
491
|
transition: "fade";
|
|
471
492
|
to: string;
|
|
493
|
+
duration: number;
|
|
472
494
|
} | {
|
|
473
495
|
type: "SWIPE_START";
|
|
474
496
|
direction: Direction;
|
|
@@ -513,10 +535,12 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
513
535
|
transition: "slide";
|
|
514
536
|
to: string;
|
|
515
537
|
direction: Direction;
|
|
538
|
+
duration: number;
|
|
516
539
|
} | {
|
|
517
540
|
type: "TRANSITION_TRIGGER";
|
|
518
541
|
transition: "fade";
|
|
519
542
|
to: string;
|
|
543
|
+
duration: number;
|
|
520
544
|
} | {
|
|
521
545
|
type: "SWIPE_START";
|
|
522
546
|
direction: Direction;
|
|
@@ -565,10 +589,12 @@ export type TransitionEvents = {
|
|
|
565
589
|
transition: 'slide';
|
|
566
590
|
to: string;
|
|
567
591
|
direction: Direction;
|
|
592
|
+
duration: number;
|
|
568
593
|
} | {
|
|
569
594
|
type: 'TRANSITION_TRIGGER';
|
|
570
595
|
transition: 'fade';
|
|
571
596
|
to: string;
|
|
597
|
+
duration: number;
|
|
572
598
|
} | {
|
|
573
599
|
type: 'SWIPE_START';
|
|
574
600
|
direction: Direction;
|
|
@@ -609,6 +635,7 @@ export type TransitionMachineInput = {
|
|
|
609
635
|
startScene: string;
|
|
610
636
|
scenes: Scene[];
|
|
611
637
|
relations: Relation[];
|
|
638
|
+
previewWindow: Window | null;
|
|
612
639
|
};
|
|
613
640
|
type Scene = {
|
|
614
641
|
id: string;
|
|
@@ -69,18 +69,18 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
69
69
|
throw new Error('Active scene not found');
|
|
70
70
|
}
|
|
71
71
|
const from = activeScene.id;
|
|
72
|
-
return Object.assign(Object.assign({ stage: 'active', from,
|
|
72
|
+
return Object.assign(Object.assign({ stage: 'active', duration: event.duration, from,
|
|
73
73
|
to }, (transition === 'slide' ? { direction: event.direction } : {})), { type: transition });
|
|
74
74
|
},
|
|
75
75
|
scenes: ({ context, event }) => {
|
|
76
|
-
const { scenes } = context;
|
|
76
|
+
const { scenes, input: { previewWindow } } = context;
|
|
77
77
|
const activeScene = scenes[0];
|
|
78
78
|
if (!activeScene) {
|
|
79
79
|
throw new Error('Active scene not found');
|
|
80
80
|
}
|
|
81
81
|
const { to, transition } = event;
|
|
82
82
|
const newScenes = transition === 'slide'
|
|
83
|
-
? (0, getScenesOnStart_1.getScenesOnSlideStart)({ from: activeScene.id, to }, { x: 0, y: 0 }, event.direction)
|
|
83
|
+
? (0, getScenesOnStart_1.getScenesOnSlideStart)({ from: activeScene.id, to }, { x: 0, y: 0 }, event.direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window)
|
|
84
84
|
: (0, getScenesOnStart_1.getScenesOnFadeStart)({ from: activeScene.id, to }, 0);
|
|
85
85
|
return newScenes;
|
|
86
86
|
}
|
|
@@ -120,13 +120,14 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
120
120
|
const activeScene = scenes[0];
|
|
121
121
|
if (!activeScene)
|
|
122
122
|
return context.scenes;
|
|
123
|
+
const { previewWindow } = input;
|
|
123
124
|
const relation = (0, findRelation_1.findRelation)(input.relations, activeScene.id, direction);
|
|
124
125
|
if (!transition || !('startX' in transition) || !('startY' in transition))
|
|
125
126
|
return context.scenes;
|
|
126
127
|
const start = { x: transition.startX, y: transition.startY };
|
|
127
|
-
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, direction);
|
|
128
|
+
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window);
|
|
128
129
|
const newScenes = relation.type === 'slide'
|
|
129
|
-
? (0, getScenesOnStart_1.getScenesOnSlideStart)(relation, { x: deltaX, y: deltaY }, direction)
|
|
130
|
+
? (0, getScenesOnStart_1.getScenesOnSlideStart)(relation, { x: deltaX, y: deltaY }, direction, window)
|
|
130
131
|
: (0, getScenesOnStart_1.getScenesOnFadeStart)(relation, progress);
|
|
131
132
|
return newScenes;
|
|
132
133
|
}
|
|
@@ -151,11 +152,11 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
151
152
|
return Object.assign(Object.assign({}, transition), { stage: 'active', currentX: event.touchData.x, currentY: event.touchData.y });
|
|
152
153
|
},
|
|
153
154
|
scenes: ({ context, event }) => {
|
|
154
|
-
const { transition, scenes } = context;
|
|
155
|
+
const { transition, scenes, input: { previewWindow } } = context;
|
|
155
156
|
if (!(0, isActiveSwipeTransition_1.isActiveSwipeTransition)(transition))
|
|
156
157
|
return scenes;
|
|
157
158
|
const start = { x: transition.startX, y: transition.startY };
|
|
158
|
-
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, transition.direction);
|
|
159
|
+
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, transition.direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window);
|
|
159
160
|
const newScenes = transition.type === 'slide'
|
|
160
161
|
? (0, getScenesOnProgressUpdate_1.getScenesOnSlideProgressUpdate)(scenes, { x: deltaX, y: deltaY })
|
|
161
162
|
: (0, getScenesOnProgressUpdate_1.getScenesOnFadeProgressUpdate)(scenes, transition.to, progress);
|
|
@@ -201,24 +202,18 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
201
202
|
target: 'settling',
|
|
202
203
|
actions: (0, xstate_1.assign)({
|
|
203
204
|
scenes: ({ context }) => {
|
|
204
|
-
const { transition, scenes } = context;
|
|
205
|
+
const { transition, scenes, input: { previewWindow } } = context;
|
|
205
206
|
if (!transition || transition.stage !== 'active' || !('type' in transition)) {
|
|
206
207
|
return scenes;
|
|
207
208
|
}
|
|
208
|
-
return (0, getScenesOnInstantTransition_1.getScenesOnInstantTransition)(scenes, transition);
|
|
209
|
+
return (0, getScenesOnInstantTransition_1.getScenesOnInstantTransition)(scenes, transition, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window);
|
|
209
210
|
},
|
|
210
211
|
transition: ({ context }) => {
|
|
211
212
|
const { transition } = context;
|
|
212
213
|
if (!transition || transition.stage !== 'active' || !('type' in transition)) {
|
|
213
214
|
return null;
|
|
214
215
|
}
|
|
215
|
-
return {
|
|
216
|
-
stage: 'settling',
|
|
217
|
-
success: true,
|
|
218
|
-
type: transition.type,
|
|
219
|
-
from: transition.from,
|
|
220
|
-
to: transition.to,
|
|
221
|
-
};
|
|
216
|
+
return Object.assign({ stage: 'settling', success: true, type: transition.type, from: transition.from, to: transition.to }, (transition.duration ? { duration: transition.duration } : {}));
|
|
222
217
|
}
|
|
223
218
|
})
|
|
224
219
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Direction } from './types';
|
|
2
|
-
export declare function getDeltaAndProgress(current: Delta, start: Delta, direction: Direction): {
|
|
2
|
+
export declare function getDeltaAndProgress(current: Delta, start: Delta, direction: Direction, window: Window): {
|
|
3
3
|
deltaX: number;
|
|
4
4
|
deltaY: number;
|
|
5
5
|
progress: number;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDeltaAndProgress = getDeltaAndProgress;
|
|
4
4
|
const getAxis_1 = require("./getAxis");
|
|
5
|
-
function getDeltaAndProgress(current, start, direction) {
|
|
5
|
+
function getDeltaAndProgress(current, start, direction, window) {
|
|
6
6
|
const axis = (0, getAxis_1.getAxis)(direction);
|
|
7
7
|
const deltaX = axis === 'horizontal' ? current.x - start.x : 0;
|
|
8
8
|
const deltaY = axis === 'vertical' ? current.y - start.y : 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InstantTransition, TransitionScene } from './types';
|
|
2
|
-
export declare function getScenesOnInstantTransition(scenes: TransitionScene[], transition: InstantTransition): TransitionScene[];
|
|
2
|
+
export declare function getScenesOnInstantTransition(scenes: TransitionScene[], transition: InstantTransition, window: Window): TransitionScene[];
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getScenesOnInstantTransition = getScenesOnInstantTransition;
|
|
4
|
-
function getScenesOnInstantTransition(scenes, transition) {
|
|
4
|
+
function getScenesOnInstantTransition(scenes, transition, window) {
|
|
5
5
|
const { type, to, direction } = transition;
|
|
6
6
|
if (type === 'slide' && direction) {
|
|
7
|
-
return getScenesOnInstantSlideTransition(scenes, to, direction);
|
|
7
|
+
return getScenesOnInstantSlideTransition(scenes, to, direction, window);
|
|
8
8
|
}
|
|
9
9
|
else if (type === 'fade') {
|
|
10
10
|
return getScenesOnInstantFadeTransition(scenes);
|
|
11
11
|
}
|
|
12
12
|
return scenes;
|
|
13
13
|
}
|
|
14
|
-
function getScenesOnInstantSlideTransition(scenes, to, direction) {
|
|
14
|
+
function getScenesOnInstantSlideTransition(scenes, to, direction, window) {
|
|
15
15
|
let fromFinalX = 0;
|
|
16
16
|
let fromFinalY = 0;
|
|
17
17
|
if (direction === 'east') {
|
|
@@ -9,7 +9,7 @@ export declare function getScenesOnFadeStart({ from, to }: FromTo, progress: num
|
|
|
9
9
|
y: number;
|
|
10
10
|
};
|
|
11
11
|
}[];
|
|
12
|
-
export declare function getScenesOnSlideStart({ from, to }: FromTo, delta: Delta, direction: Direction): TransitionScene[];
|
|
12
|
+
export declare function getScenesOnSlideStart({ from, to }: FromTo, delta: Delta, direction: Direction, window: Window): TransitionScene[];
|
|
13
13
|
type Delta = {
|
|
14
14
|
x: number;
|
|
15
15
|
y: number;
|
|
@@ -21,7 +21,7 @@ function getScenesOnFadeStart({ from, to }, progress) {
|
|
|
21
21
|
};
|
|
22
22
|
return [sceneFrom, sceneTo];
|
|
23
23
|
}
|
|
24
|
-
function getScenesOnSlideStart({ from, to }, delta, direction) {
|
|
24
|
+
function getScenesOnSlideStart({ from, to }, delta, direction, window) {
|
|
25
25
|
const common = {
|
|
26
26
|
opacity: 1,
|
|
27
27
|
};
|
|
@@ -29,8 +29,8 @@ function getScenesOnSlideStart({ from, to }, delta, direction) {
|
|
|
29
29
|
id: from,
|
|
30
30
|
styles: Object.assign(Object.assign({}, common), { startX: 0, startY: 0, x: delta.x, y: delta.y })
|
|
31
31
|
};
|
|
32
|
-
const startX = getNextSceneSlideStartX(direction);
|
|
33
|
-
const startY = getNextSceneSlideStartY(direction);
|
|
32
|
+
const startX = getNextSceneSlideStartX(direction, window);
|
|
33
|
+
const startY = getNextSceneSlideStartY(direction, window);
|
|
34
34
|
const sceneTo = {
|
|
35
35
|
id: to,
|
|
36
36
|
styles: Object.assign(Object.assign({}, common), { startX,
|
|
@@ -38,13 +38,13 @@ function getScenesOnSlideStart({ from, to }, delta, direction) {
|
|
|
38
38
|
};
|
|
39
39
|
return [sceneFrom, sceneTo];
|
|
40
40
|
}
|
|
41
|
-
function getNextSceneSlideStartX(direction) {
|
|
41
|
+
function getNextSceneSlideStartX(direction, window) {
|
|
42
42
|
const axis = (0, getAxis_1.getAxis)(direction);
|
|
43
43
|
if (axis !== 'horizontal')
|
|
44
44
|
return 0;
|
|
45
45
|
return direction === 'east' ? window.innerWidth : -window.innerWidth;
|
|
46
46
|
}
|
|
47
|
-
function getNextSceneSlideStartY(direction) {
|
|
47
|
+
function getNextSceneSlideStartY(direction, window) {
|
|
48
48
|
const axis = (0, getAxis_1.getAxis)(direction);
|
|
49
49
|
if (axis !== 'vertical')
|
|
50
50
|
return 0;
|
|
@@ -14,6 +14,7 @@ export type PreparingTransition = {
|
|
|
14
14
|
export type ActiveTransition = {
|
|
15
15
|
stage: 'active';
|
|
16
16
|
direction: Direction;
|
|
17
|
+
duration?: number;
|
|
17
18
|
type: 'slide' | 'fade';
|
|
18
19
|
from: string;
|
|
19
20
|
to: string;
|
|
@@ -35,6 +36,7 @@ export type InstantTransition = {
|
|
|
35
36
|
from: string;
|
|
36
37
|
to: string;
|
|
37
38
|
direction?: Direction;
|
|
39
|
+
duration?: number;
|
|
38
40
|
};
|
|
39
41
|
export type TransitionScene = {
|
|
40
42
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Interaction {
|
|
2
2
|
id: string;
|
|
3
|
-
triggers: (InteractionItemTrigger | InteractionScrollTrigger)[];
|
|
3
|
+
triggers: (InteractionItemTrigger | InteractionScrollTrigger | SceneTransitionTrigger)[];
|
|
4
4
|
states: InteractionState[];
|
|
5
5
|
startStateId: string;
|
|
6
6
|
}
|
|
@@ -10,6 +10,11 @@ export interface InteractionItemTrigger {
|
|
|
10
10
|
from: StateId;
|
|
11
11
|
to: StateId;
|
|
12
12
|
}
|
|
13
|
+
export interface SceneTransitionTrigger {
|
|
14
|
+
type: 'scene-transition';
|
|
15
|
+
from: StateId;
|
|
16
|
+
to: StateId;
|
|
17
|
+
}
|
|
13
18
|
export interface InteractionScrollTrigger {
|
|
14
19
|
position: number;
|
|
15
20
|
from: StateId;
|
|
@@ -7,12 +7,13 @@ exports.Page = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const html_react_parser_1 = __importDefault(require("html-react-parser"));
|
|
9
9
|
const Head_1 = require("./Head");
|
|
10
|
-
const TransitionMachineContext_1 = require("../provider/TransitionMachineContext");
|
|
11
10
|
const Scenes_1 = require("./Scenes/Scenes");
|
|
12
11
|
const FixedLayer_1 = require("./fixedLayers/FixedLayer");
|
|
13
12
|
const PreviewWrapper_1 = require("./Preview/PreviewWrapper");
|
|
14
13
|
const PreviewListener_1 = require("./Preview/PreviewListener");
|
|
15
14
|
const AssetsCacheProvider_1 = require("../assets/AssetsCacheProvider");
|
|
15
|
+
const InOutTransitionContext_1 = require("../provider/InOutTransitionContext");
|
|
16
|
+
const TransitionMachineContextProvider_1 = require("../provider/TransitionMachineContextProvider");
|
|
16
17
|
const Page = ({ project, articlesData }) => {
|
|
17
18
|
var _a, _b;
|
|
18
19
|
const afterBodyOpen = (0, html_react_parser_1.default)(project.html.afterBodyOpen);
|
|
@@ -20,12 +21,6 @@ const Page = ({ project, articlesData }) => {
|
|
|
20
21
|
const startScene = (_b = (_a = project.pages.find(page => page.isStartScene)) === null || _a === void 0 ? void 0 : _a.articleId) !== null && _b !== void 0 ? _b : Object.keys(articlesData)[0];
|
|
21
22
|
const scenes = Object.values(articlesData).map(({ article }) => ({ id: article.id }));
|
|
22
23
|
const { relations, scenesAssets } = project;
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project }), afterBodyOpen, (0, jsx_runtime_1.jsx)(PreviewWrapper_1.PreviewWrapper, { relations: relations, startScene: startScene, children: (0, jsx_runtime_1.jsxs)(
|
|
24
|
-
input: {
|
|
25
|
-
startScene,
|
|
26
|
-
relations,
|
|
27
|
-
scenes,
|
|
28
|
-
}
|
|
29
|
-
}, children: [(0, jsx_runtime_1.jsx)(PreviewListener_1.PreviewListener, {}), (0, jsx_runtime_1.jsxs)(AssetsCacheProvider_1.AssetsCacheProvider, { assets: scenesAssets, children: [project.foreground && !project.foreground.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.foreground, type: "foreground" }), (0, jsx_runtime_1.jsx)(Scenes_1.Scenes, { articlesData: articlesData }), project.background && !project.background.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.background, type: "background" })] })] }) }), beforeBodyClose] }));
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project }), afterBodyOpen, (0, jsx_runtime_1.jsx)(PreviewWrapper_1.PreviewWrapper, { relations: relations, startScene: startScene, children: (0, jsx_runtime_1.jsx)(TransitionMachineContextProvider_1.TransitionMachineContextProvider, { startScene: startScene, relations: relations, scenes: scenes, children: (0, jsx_runtime_1.jsxs)(InOutTransitionContext_1.InOutTransitionProvider, { children: [(0, jsx_runtime_1.jsx)(PreviewListener_1.PreviewListener, {}), (0, jsx_runtime_1.jsxs)(AssetsCacheProvider_1.AssetsCacheProvider, { assets: scenesAssets, children: [project.foreground && !project.foreground.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.foreground, type: "foreground" }), (0, jsx_runtime_1.jsx)(Scenes_1.Scenes, { articlesData: articlesData }), project.background && !project.background.hidden && (0, jsx_runtime_1.jsx)(FixedLayer_1.FixedLayer, { layer: project.background, type: "background" })] })] }) }) }), beforeBodyClose] }));
|
|
30
25
|
};
|
|
31
26
|
exports.Page = Page;
|
|
@@ -5,22 +5,32 @@ 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 InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
8
9
|
const Scene = ({ children, id, styles: sceneStyles, elRef }) => {
|
|
9
10
|
var _a;
|
|
10
11
|
const { layoutDeviation } = (0, useLayoutDeviation_1.useLayoutDeviation)();
|
|
12
|
+
const interactionsRegistry = (0, InteractionsContext_1.useInteractionsRegistry)();
|
|
11
13
|
const layoutDeviationStyle = { '--layout-deviation': layoutDeviation };
|
|
12
14
|
const actorRef = TransitionMachineContext_1.TransitionMachineContext.useActorRef();
|
|
13
|
-
const { isControlledTransitioning, isSettling, isInstantTransitioning } = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const { isControlledTransitioning, isSettling, isInstantTransitioning } = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => {
|
|
16
|
+
return {
|
|
17
|
+
isControlledTransitioning: state.matches('transitioning'),
|
|
18
|
+
isSettling: state.matches('settling'),
|
|
19
|
+
isInstantTransitioning: state.matches('instant_transitioning')
|
|
20
|
+
};
|
|
21
|
+
});
|
|
18
22
|
const type = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => {
|
|
19
23
|
const { transition } = state.context;
|
|
20
24
|
if (!transition || !('type' in transition))
|
|
21
25
|
return undefined;
|
|
22
26
|
return transition.type;
|
|
23
27
|
});
|
|
28
|
+
const duration = TransitionMachineContext_1.TransitionMachineContext.useSelector((state) => {
|
|
29
|
+
const { transition } = state.context;
|
|
30
|
+
if (!transition || !('duration' in transition))
|
|
31
|
+
return undefined;
|
|
32
|
+
return transition.duration;
|
|
33
|
+
});
|
|
24
34
|
const isTransitioningRef = (0, react_1.useRef)(false);
|
|
25
35
|
const isTransitioning = isControlledTransitioning || isInstantTransitioning;
|
|
26
36
|
const handleTouchStart = (0, react_1.useCallback)((e) => {
|
|
@@ -101,6 +111,8 @@ const Scene = ({ children, id, styles: sceneStyles, elRef }) => {
|
|
|
101
111
|
if (!isSettling || !el)
|
|
102
112
|
return;
|
|
103
113
|
const handleTransitionEnd = (e) => {
|
|
114
|
+
if (e.target !== el)
|
|
115
|
+
return;
|
|
104
116
|
const { context } = actorRef.getSnapshot();
|
|
105
117
|
const { transition } = context;
|
|
106
118
|
if (!transition || transition.stage !== 'settling') {
|
|
@@ -133,9 +145,33 @@ const Scene = ({ children, id, styles: sceneStyles, elRef }) => {
|
|
|
133
145
|
scene.scrollTo({ top: scene.scrollHeight });
|
|
134
146
|
}
|
|
135
147
|
}, [isTransitioning, actorRef, id]);
|
|
148
|
+
(0, react_1.useEffect)(() => {
|
|
149
|
+
if (!interactionsRegistry || !actorRef)
|
|
150
|
+
return;
|
|
151
|
+
const { context } = actorRef.getSnapshot();
|
|
152
|
+
const { transition } = context;
|
|
153
|
+
if (!transition || transition.stage !== 'active')
|
|
154
|
+
return;
|
|
155
|
+
const { from, to } = transition;
|
|
156
|
+
if (from === id) {
|
|
157
|
+
interactionsRegistry.notifySceneOutTransition();
|
|
158
|
+
}
|
|
159
|
+
if (to === id) {
|
|
160
|
+
interactionsRegistry.notifySceneInTransition();
|
|
161
|
+
}
|
|
162
|
+
}, [interactionsRegistry, id, isTransitioning, actorRef]);
|
|
163
|
+
(0, react_1.useEffect)(() => {
|
|
164
|
+
if (isSettling && actorRef && interactionsRegistry) {
|
|
165
|
+
const { context } = actorRef.getSnapshot();
|
|
166
|
+
const { transition } = context;
|
|
167
|
+
if (!transition || transition.stage !== 'settling' || transition.success)
|
|
168
|
+
return;
|
|
169
|
+
interactionsRegistry.notifySceneOutTransitionCancel();
|
|
170
|
+
}
|
|
171
|
+
}, [isSettling, actorRef, interactionsRegistry]);
|
|
136
172
|
const isFixed = isControlledTransitioning || isSettling || isInstantTransitioning;
|
|
137
173
|
const transitionStyle = type === 'slide' ? 'transform' : 'opacity';
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { ref: elRef, className: "article-wrapper", style: Object.assign(Object.assign({}, layoutDeviationStyle), { width: '100vw', height: '100%', zIndex: 1, position: isFixed ? 'fixed' : 'absolute', transform: sceneStyles && (sceneStyles.x !== 0 || sceneStyles.y !== 0) ? `translate(${sceneStyles.x}px, ${sceneStyles.y}px)` : 'none', transition: isSettling || isInstantTransitioning ? `${transitionStyle} 0
|
|
174
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { ref: elRef, className: "article-wrapper", style: Object.assign(Object.assign({}, layoutDeviationStyle), { width: '100vw', height: '100%', zIndex: 1, position: isFixed ? 'fixed' : 'absolute', transform: sceneStyles && (sceneStyles.x !== 0 || sceneStyles.y !== 0) ? `translate(${sceneStyles.x}px, ${sceneStyles.y}px)` : 'none', transition: isSettling || isInstantTransitioning ? `${transitionStyle} ${duration !== null && duration !== void 0 ? duration : 250}ms ease-out` : 'none', overflowY: isFixed ? 'hidden' : 'scroll', overflowX: 'clip', opacity: (_a = sceneStyles === null || sceneStyles === void 0 ? void 0 : sceneStyles.opacity) !== null && _a !== void 0 ? _a : 1, 'WebkitOverflowScrolling': 'touch' // prevent glitch on Safari (fast scroll to top/bottom sides)
|
|
139
175
|
}), children: children }) }));
|
|
140
176
|
};
|
|
141
177
|
exports.Scene = Scene;
|
|
@@ -40,11 +40,7 @@ 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, { 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(
|
|
44
|
-
backgroundPosition: 'center',
|
|
45
|
-
backgroundSize: strokeFill.behavior === 'repeat' ? `${strokeFill.backgroundSize}%` : strokeFill.behavior,
|
|
46
|
-
backgroundRepeat: strokeFill.behavior === 'repeat' ? 'repeat' : 'no-repeat'
|
|
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
|
|
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({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
48
44
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
49
45
|
: {})), { transition: (_j = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _j !== void 0 ? _j : 'none' }), children: itemFill && itemFill.map((fill, i) => {
|
|
50
46
|
var _a, _b;
|
|
@@ -55,7 +51,7 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
55
51
|
const background = value
|
|
56
52
|
? (_b = (0, getFill_1.getFill)(value)) !== null && _b !== void 0 ? _b : 'transparent'
|
|
57
53
|
: 'transparent';
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(Fill, { fill: value, itemId: item.id, background: background, solidTransition: solidTransition, radius: radius, strokeWidth: strokeWidth, fillId: fill.id }, `fill-${i}-${fill.id}`));
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(Fill, { fill: value, itemId: item.id, background: background, transition: (stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) || '', solidTransition: solidTransition, radius: radius, strokeWidth: strokeWidth, fillId: fill.id, isHighest: i === itemFill.length - 1, borderColor: stroke }, `fill-${i}-${fill.id}`));
|
|
59
55
|
}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
60
56
|
.rectangle-${item.id} {
|
|
61
57
|
position: absolute;
|
|
@@ -82,16 +78,27 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
82
78
|
` })] }) }));
|
|
83
79
|
};
|
|
84
80
|
exports.RectangleItem = RectangleItem;
|
|
85
|
-
function Fill({ fillId, fill, itemId, background, solidTransition, radius, strokeWidth, }) {
|
|
81
|
+
function Fill({ fillId, fill, itemId, background, transition, solidTransition, radius, strokeWidth, isHighest, borderColor, }) {
|
|
86
82
|
const isRotatedImage = fill.type === 'image' && fill.rotation && fill.rotation !== 0;
|
|
87
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: fill.type === 'image' ? `image-fill-${itemId}` : `fill-${itemId}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (fill.type === 'solid' ? {
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: fill.type === 'image' ? `image-fill-${itemId}` : `fill-${itemId}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (fill.type === 'solid' ? {
|
|
84
|
+
background,
|
|
85
|
+
transition: transition && transition !== 'none' && transition.trim()
|
|
86
|
+
? `${solidTransition}, ${transition}`
|
|
87
|
+
: solidTransition
|
|
88
|
+
} : {})), (fill.type === 'image'
|
|
88
89
|
? {
|
|
89
90
|
transform: `rotate(${fill.rotation}deg)`,
|
|
90
91
|
backgroundImage: `url(${fill.src})`,
|
|
91
92
|
backgroundSize: fill.behavior === 'repeat' ? `${fill.backgroundSize}%` : fill.behavior,
|
|
92
93
|
backgroundRepeat: fill.behavior === 'repeat' ? 'repeat' : 'no-repeat',
|
|
94
|
+
backgroundOrigin: 'border-box',
|
|
93
95
|
opacity: fill.opacity
|
|
94
96
|
}
|
|
95
|
-
: { background })), { position: 'absolute', mixBlendMode: fill.blendMode, top: 0, left: 0, borderRadius:
|
|
97
|
+
: { background })), { position: 'absolute', mixBlendMode: fill.blendMode, top: 0, left: 0, borderRadius: `${radius * 100}vw`, width: '100%', height: '100%', pointerEvents: 'none' }), (isHighest ? {
|
|
98
|
+
borderColor,
|
|
99
|
+
borderWidth: `${strokeWidth * 100}vw`,
|
|
100
|
+
borderStyle: 'solid',
|
|
101
|
+
boxSizing: 'border-box'
|
|
102
|
+
} : {})), (isRotatedImage ? { overflow: 'hidden' } : {})), (fill.type !== 'solid' ? { transition } : {})) }, fillId));
|
|
96
103
|
}
|
|
97
104
|
;
|
|
@@ -48,6 +48,6 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
|
|
|
48
48
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
49
49
|
}, [isInteractive, onVisibilityChange]);
|
|
50
50
|
const color = color_1.CntrlColor.parse(item.params.color);
|
|
51
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `rich-text-wrapper-${item.id}`, style: Object.assign(Object.assign({ filter: `blur(${blur * 100}vw)` }, (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), { transform: `rotate(${angle}deg)`, letterSpacing: `${letterSpacing * exemplary}px`, wordSpacing: `${wordSpacing * exemplary}px`, fontSize: `${Math.round(fontSize * exemplary)}px`, lineHeight: `${lineHeight * exemplary}px`, willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', fontFamily: (0, getFontFamilyValue_1.getFontFamilyValue)(item.params.typeFace), fontWeight: item.params.fontWeight, fontStyle: item.params.fontStyle ? item.params.fontStyle : 'normal', verticalAlign: item.params.verticalAlign, fontVariant: item.params.fontVariant,
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `rich-text-wrapper-${item.id}`, style: Object.assign(Object.assign({ filter: `blur(${blur * 100}vw)` }, (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), { transform: `rotate(${angle}deg)`, letterSpacing: `${letterSpacing * exemplary}px`, wordSpacing: `${wordSpacing * exemplary}px`, fontSize: `${Math.round(fontSize * exemplary)}px`, lineHeight: `${lineHeight * exemplary}px`, willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', fontFamily: (0, getFontFamilyValue_1.getFontFamilyValue)(item.params.typeFace), fontWeight: item.params.fontWeight, fontStyle: item.params.fontStyle ? item.params.fontStyle : 'normal', verticalAlign: item.params.verticalAlign, fontVariant: item.params.fontVariant, textTransform: item.params.textTransform, transition }), children: content }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: styles })] }));
|
|
52
52
|
};
|
|
53
53
|
exports.RichTextItem = RichTextItem;
|
|
@@ -19,7 +19,7 @@ export declare class FixedLayerTransitionsRegistry implements InteractionsRegist
|
|
|
19
19
|
private getDefaultItemStages;
|
|
20
20
|
notifyOnActiveSceneChange(sceneId: SceneId): void;
|
|
21
21
|
setActiveTransition(to: SceneId): void;
|
|
22
|
-
notifyTransitionStartForItems(
|
|
22
|
+
notifyTransitionStartForItems(sceneId: string): void;
|
|
23
23
|
notifyTransitionEnd(itemId: string): void;
|
|
24
24
|
private notifyItemCtrlsChange;
|
|
25
25
|
}
|
|
@@ -127,13 +127,13 @@ class FixedLayerTransitionsRegistry {
|
|
|
127
127
|
setActiveTransition(to) {
|
|
128
128
|
this.activeTransition = this.transitions.find((transition) => transition.to === to && transition.from === this.activeSceneId);
|
|
129
129
|
}
|
|
130
|
-
notifyTransitionStartForItems(
|
|
130
|
+
notifyTransitionStartForItems(sceneId) {
|
|
131
131
|
var _a, _b;
|
|
132
132
|
const itemsIds = this.itemsStages.map((stage) => stage.itemId);
|
|
133
133
|
for (const itemId of itemsIds) {
|
|
134
134
|
const ctrl = this.ctrls.get(itemId);
|
|
135
135
|
const item = this.items.find((item) => item.id === itemId);
|
|
136
|
-
const keys = Object.keys((_a = item.state[
|
|
136
|
+
const keys = Object.keys((_a = item.state[sceneId]) !== null && _a !== void 0 ? _a : {});
|
|
137
137
|
(_b = ctrl === null || ctrl === void 0 ? void 0 : ctrl.handleTransitionStart) === null || _b === void 0 ? void 0 : _b.call(ctrl, keys);
|
|
138
138
|
}
|
|
139
139
|
}
|