@gxpl/sdk 0.0.54 → 0.0.56
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/schemas/article/ItemBase.schema.d.ts +180 -10
- package/lib/sdk/schemas/article/ItemBase.schema.js +26 -8
- package/lib/sdk/schemas/article/RichTextItem.schema.d.ts +76 -6
- package/lib/sdk/schemas/project/Project.schema.d.ts +46 -11
- package/lib/sdk/schemas/project/Project.schema.js +14 -3
- package/lib/sdk/transitions/transitionMachine.d.ts +104 -0
- package/lib/sdk/transitions/transitionMachine.js +19 -17
- package/lib/sdk/transitions/utils/getInstantTransitionParams.d.ts +36 -0
- package/lib/sdk/transitions/utils/getInstantTransitionParams.js +29 -0
- package/lib/sdk/transitions/utils/getScenesOnEnd.d.ts +13 -0
- package/lib/sdk/transitions/utils/getScenesOnEnd.js +22 -0
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +3 -3
- package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.d.ts +13 -0
- package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.js +8 -0
- package/lib/sdk/transitions/utils/getScenesOnStart.d.ts +1 -0
- package/lib/sdk/transitions/utils/getScenesOnStart.js +22 -4
- package/lib/sdk/transitions/utils/getTransitionFromLink.d.ts +23 -0
- package/lib/sdk/transitions/utils/getTransitionFromLink.js +31 -0
- package/lib/sdk/transitions/utils/getTransitionFromRelation.d.ts +17 -0
- package/lib/sdk/transitions/utils/getTransitionFromRelation.js +26 -0
- package/lib/sdk/transitions/utils/getTransitionParams.d.ts +20 -0
- package/lib/sdk/transitions/utils/getTransitionParams.js +29 -0
- package/lib/sdk/transitions/utils/types.d.ts +56 -14
- package/lib/sdk/types/article/Item.d.ts +16 -3
- package/lib/sdk/types/project/Relation.d.ts +19 -4
- package/lib/sdk-nextjs/components/Preview/Preview.js +4 -7
- package/lib/sdk-nextjs/components/Preview/PreviewListener.js +2 -8
- package/lib/sdk-nextjs/components/Scene.d.ts +1 -0
- package/lib/sdk-nextjs/components/Scene.js +8 -5
- package/lib/sdk-nextjs/components/items/LinkWrapper.js +3 -7
- package/lib/sdk-nextjs/provider/TransitionMachineContext.d.ts +384 -0
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +3 -3
- package/package.json +1 -1
|
@@ -11,6 +11,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
11
11
|
to: string;
|
|
12
12
|
direction: Direction;
|
|
13
13
|
duration: number;
|
|
14
|
+
} | {
|
|
15
|
+
type: "TRANSITION_TRIGGER";
|
|
16
|
+
transition: "reveal";
|
|
17
|
+
to: string;
|
|
18
|
+
direction: Direction;
|
|
19
|
+
duration: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
mode: "normal" | "reverse";
|
|
14
22
|
} | {
|
|
15
23
|
type: "TRANSITION_TRIGGER";
|
|
16
24
|
transition: "fade";
|
|
@@ -87,6 +95,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
87
95
|
to: string;
|
|
88
96
|
direction: Direction;
|
|
89
97
|
duration: number;
|
|
98
|
+
} | {
|
|
99
|
+
type: "TRANSITION_TRIGGER";
|
|
100
|
+
transition: "reveal";
|
|
101
|
+
to: string;
|
|
102
|
+
direction: Direction;
|
|
103
|
+
duration: number;
|
|
104
|
+
offset: number;
|
|
105
|
+
mode: "normal" | "reverse";
|
|
90
106
|
} | {
|
|
91
107
|
type: "TRANSITION_TRIGGER";
|
|
92
108
|
transition: "fade";
|
|
@@ -123,6 +139,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
123
139
|
to: string;
|
|
124
140
|
direction: Direction;
|
|
125
141
|
duration: number;
|
|
142
|
+
} | {
|
|
143
|
+
type: "TRANSITION_TRIGGER";
|
|
144
|
+
transition: "reveal";
|
|
145
|
+
to: string;
|
|
146
|
+
direction: Direction;
|
|
147
|
+
duration: number;
|
|
148
|
+
offset: number;
|
|
149
|
+
mode: "normal" | "reverse";
|
|
126
150
|
} | {
|
|
127
151
|
type: "TRANSITION_TRIGGER";
|
|
128
152
|
transition: "fade";
|
|
@@ -182,6 +206,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
182
206
|
to: string;
|
|
183
207
|
direction: Direction;
|
|
184
208
|
duration: number;
|
|
209
|
+
} | {
|
|
210
|
+
type: "TRANSITION_TRIGGER";
|
|
211
|
+
transition: "reveal";
|
|
212
|
+
to: string;
|
|
213
|
+
direction: Direction;
|
|
214
|
+
duration: number;
|
|
215
|
+
offset: number;
|
|
216
|
+
mode: "normal" | "reverse";
|
|
185
217
|
} | {
|
|
186
218
|
type: "TRANSITION_TRIGGER";
|
|
187
219
|
transition: "fade";
|
|
@@ -220,6 +252,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
220
252
|
to: string;
|
|
221
253
|
direction: Direction;
|
|
222
254
|
duration: number;
|
|
255
|
+
} | {
|
|
256
|
+
type: "TRANSITION_TRIGGER";
|
|
257
|
+
transition: "reveal";
|
|
258
|
+
to: string;
|
|
259
|
+
direction: Direction;
|
|
260
|
+
duration: number;
|
|
261
|
+
offset: number;
|
|
262
|
+
mode: "normal" | "reverse";
|
|
223
263
|
} | {
|
|
224
264
|
type: "TRANSITION_TRIGGER";
|
|
225
265
|
transition: "fade";
|
|
@@ -237,6 +277,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
237
277
|
to: string;
|
|
238
278
|
direction: Direction;
|
|
239
279
|
duration: number;
|
|
280
|
+
} | {
|
|
281
|
+
type: "TRANSITION_TRIGGER";
|
|
282
|
+
transition: "reveal";
|
|
283
|
+
to: string;
|
|
284
|
+
direction: Direction;
|
|
285
|
+
duration: number;
|
|
286
|
+
offset: number;
|
|
287
|
+
mode: "normal" | "reverse";
|
|
240
288
|
} | {
|
|
241
289
|
type: "TRANSITION_TRIGGER";
|
|
242
290
|
transition: "fade";
|
|
@@ -292,6 +340,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
292
340
|
to: string;
|
|
293
341
|
direction: Direction;
|
|
294
342
|
duration: number;
|
|
343
|
+
} | {
|
|
344
|
+
type: "TRANSITION_TRIGGER";
|
|
345
|
+
transition: "reveal";
|
|
346
|
+
to: string;
|
|
347
|
+
direction: Direction;
|
|
348
|
+
duration: number;
|
|
349
|
+
offset: number;
|
|
350
|
+
mode: "normal" | "reverse";
|
|
295
351
|
} | {
|
|
296
352
|
type: "TRANSITION_TRIGGER";
|
|
297
353
|
transition: "fade";
|
|
@@ -338,6 +394,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
338
394
|
to: string;
|
|
339
395
|
direction: Direction;
|
|
340
396
|
duration: number;
|
|
397
|
+
} | {
|
|
398
|
+
type: "TRANSITION_TRIGGER";
|
|
399
|
+
transition: "reveal";
|
|
400
|
+
to: string;
|
|
401
|
+
direction: Direction;
|
|
402
|
+
duration: number;
|
|
403
|
+
offset: number;
|
|
404
|
+
mode: "normal" | "reverse";
|
|
341
405
|
} | {
|
|
342
406
|
type: "TRANSITION_TRIGGER";
|
|
343
407
|
transition: "fade";
|
|
@@ -391,6 +455,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
391
455
|
to: string;
|
|
392
456
|
direction: Direction;
|
|
393
457
|
duration: number;
|
|
458
|
+
} | {
|
|
459
|
+
type: "TRANSITION_TRIGGER";
|
|
460
|
+
transition: "reveal";
|
|
461
|
+
to: string;
|
|
462
|
+
direction: Direction;
|
|
463
|
+
duration: number;
|
|
464
|
+
offset: number;
|
|
465
|
+
mode: "normal" | "reverse";
|
|
394
466
|
} | {
|
|
395
467
|
type: "TRANSITION_TRIGGER";
|
|
396
468
|
transition: "fade";
|
|
@@ -437,6 +509,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
437
509
|
to: string;
|
|
438
510
|
direction: Direction;
|
|
439
511
|
duration: number;
|
|
512
|
+
} | {
|
|
513
|
+
type: "TRANSITION_TRIGGER";
|
|
514
|
+
transition: "reveal";
|
|
515
|
+
to: string;
|
|
516
|
+
direction: Direction;
|
|
517
|
+
duration: number;
|
|
518
|
+
offset: number;
|
|
519
|
+
mode: "normal" | "reverse";
|
|
440
520
|
} | {
|
|
441
521
|
type: "TRANSITION_TRIGGER";
|
|
442
522
|
transition: "fade";
|
|
@@ -486,6 +566,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
486
566
|
to: string;
|
|
487
567
|
direction: Direction;
|
|
488
568
|
duration: number;
|
|
569
|
+
} | {
|
|
570
|
+
type: "TRANSITION_TRIGGER";
|
|
571
|
+
transition: "reveal";
|
|
572
|
+
to: string;
|
|
573
|
+
direction: Direction;
|
|
574
|
+
duration: number;
|
|
575
|
+
offset: number;
|
|
576
|
+
mode: "normal" | "reverse";
|
|
489
577
|
} | {
|
|
490
578
|
type: "TRANSITION_TRIGGER";
|
|
491
579
|
transition: "fade";
|
|
@@ -536,6 +624,14 @@ export declare const transitionMachine: import("xstate").StateMachine<Transition
|
|
|
536
624
|
to: string;
|
|
537
625
|
direction: Direction;
|
|
538
626
|
duration: number;
|
|
627
|
+
} | {
|
|
628
|
+
type: "TRANSITION_TRIGGER";
|
|
629
|
+
transition: "reveal";
|
|
630
|
+
to: string;
|
|
631
|
+
direction: Direction;
|
|
632
|
+
duration: number;
|
|
633
|
+
offset: number;
|
|
634
|
+
mode: "normal" | "reverse";
|
|
539
635
|
} | {
|
|
540
636
|
type: "TRANSITION_TRIGGER";
|
|
541
637
|
transition: "fade";
|
|
@@ -590,6 +686,14 @@ export type TransitionEvents = {
|
|
|
590
686
|
to: string;
|
|
591
687
|
direction: Direction;
|
|
592
688
|
duration: number;
|
|
689
|
+
} | {
|
|
690
|
+
type: 'TRANSITION_TRIGGER';
|
|
691
|
+
transition: 'reveal';
|
|
692
|
+
to: string;
|
|
693
|
+
direction: Direction;
|
|
694
|
+
duration: number;
|
|
695
|
+
offset: number;
|
|
696
|
+
mode: 'normal' | 'reverse';
|
|
593
697
|
} | {
|
|
594
698
|
type: 'TRANSITION_TRIGGER';
|
|
595
699
|
transition: 'fade';
|
|
@@ -12,6 +12,8 @@ const getScenesOnEnd_1 = require("./utils/getScenesOnEnd");
|
|
|
12
12
|
const getScenesOnInstantTransition_1 = require("./utils/getScenesOnInstantTransition");
|
|
13
13
|
const isActiveSwipeTransition_1 = require("./utils/isActiveSwipeTransition");
|
|
14
14
|
const getDeltaAndProgress_1 = require("./utils/getDeltaAndProgress");
|
|
15
|
+
const getInstantTransitionParams_1 = require("./utils/getInstantTransitionParams");
|
|
16
|
+
const getTransitionParams_1 = require("./utils/getTransitionParams");
|
|
15
17
|
const SWIPE_SLIDE_SUCCESS_THRESHOLD = 130;
|
|
16
18
|
const SWIPE_FADE_SUCCESS_THRESHOLD = 20;
|
|
17
19
|
exports.transitionMachine = (0, xstate_1.setup)({
|
|
@@ -70,8 +72,9 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
70
72
|
throw new Error('Active scene not found');
|
|
71
73
|
}
|
|
72
74
|
const from = activeScene.id;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
const params = (0, getInstantTransitionParams_1.getInstantTransitionParams)(transition, event);
|
|
76
|
+
return Object.assign({ stage: 'active', duration: event.duration, from,
|
|
77
|
+
to }, params);
|
|
75
78
|
},
|
|
76
79
|
scenes: ({ context, event }) => {
|
|
77
80
|
const { scenes, input: { previewWindow } } = context;
|
|
@@ -82,7 +85,9 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
82
85
|
const { to, transition } = event;
|
|
83
86
|
const newScenes = transition === 'slide'
|
|
84
87
|
? (0, getScenesOnStart_1.getScenesOnSlideStart)({ from: activeScene.id, to }, { x: 0, y: 0 }, event.direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window)
|
|
85
|
-
:
|
|
88
|
+
: transition === 'reveal'
|
|
89
|
+
? (0, getScenesOnStart_1.getScenesOnRevealStart)({ from: activeScene.id, to }, { x: 0, y: 0 }, event.direction, event.offset, event.mode, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window)
|
|
90
|
+
: (0, getScenesOnStart_1.getScenesOnFadeStart)({ from: activeScene.id, to }, 0);
|
|
86
91
|
return newScenes;
|
|
87
92
|
}
|
|
88
93
|
})
|
|
@@ -103,17 +108,8 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
103
108
|
const relation = (0, findRelation_1.findRelation)(input.relations, activeScene.id, direction);
|
|
104
109
|
if (!transition || !('startX' in transition) || !('startY' in transition))
|
|
105
110
|
return null;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
type: relation.type,
|
|
109
|
-
from: relation.from,
|
|
110
|
-
to: relation.to,
|
|
111
|
-
direction,
|
|
112
|
-
startX: transition === null || transition === void 0 ? void 0 : transition.startX,
|
|
113
|
-
startY: transition === null || transition === void 0 ? void 0 : transition.startY,
|
|
114
|
-
currentX: event.touchData.x,
|
|
115
|
-
currentY: event.touchData.y,
|
|
116
|
-
};
|
|
111
|
+
const params = (0, getTransitionParams_1.getTransitionParamsFromRelation)(relation);
|
|
112
|
+
return Object.assign({ stage: 'active', direction, startX: transition === null || transition === void 0 ? void 0 : transition.startX, startY: transition === null || transition === void 0 ? void 0 : transition.startY, currentX: event.touchData.x, currentY: event.touchData.y }, params);
|
|
117
113
|
},
|
|
118
114
|
scenes: ({ context, event }) => {
|
|
119
115
|
const { direction } = event;
|
|
@@ -129,7 +125,9 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
129
125
|
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window);
|
|
130
126
|
const newScenes = relation.type === 'slide'
|
|
131
127
|
? (0, getScenesOnStart_1.getScenesOnSlideStart)(relation, { x: deltaX, y: deltaY }, direction, window)
|
|
132
|
-
:
|
|
128
|
+
: relation.type === 'reveal'
|
|
129
|
+
? (0, getScenesOnStart_1.getScenesOnRevealStart)(relation, { x: deltaX, y: deltaY }, direction, relation.offset, relation.mode, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window)
|
|
130
|
+
: (0, getScenesOnStart_1.getScenesOnFadeStart)(relation, progress);
|
|
133
131
|
return newScenes;
|
|
134
132
|
}
|
|
135
133
|
})
|
|
@@ -160,7 +158,9 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
160
158
|
const { deltaX, deltaY, progress } = (0, getDeltaAndProgress_1.getDeltaAndProgress)(event.touchData, start, transition.direction, previewWindow !== null && previewWindow !== void 0 ? previewWindow : window);
|
|
161
159
|
const newScenes = transition.type === 'slide'
|
|
162
160
|
? (0, getScenesOnProgressUpdate_1.getScenesOnSlideProgressUpdate)(scenes, { x: deltaX, y: deltaY })
|
|
163
|
-
:
|
|
161
|
+
: transition.type === 'reveal'
|
|
162
|
+
? (0, getScenesOnProgressUpdate_1.getScenesOnRevealProgressUpdate)(scenes, { x: deltaX, y: deltaY }, transition.to, transition.offset, transition.mode)
|
|
163
|
+
: (0, getScenesOnProgressUpdate_1.getScenesOnFadeProgressUpdate)(scenes, transition.to, progress);
|
|
164
164
|
return newScenes;
|
|
165
165
|
}
|
|
166
166
|
})
|
|
@@ -191,7 +191,9 @@ exports.transitionMachine = (0, xstate_1.setup)({
|
|
|
191
191
|
const transitionSuccess = (0, isTransitionSuccess_1.isTransitionSuccess)(transition, threshold);
|
|
192
192
|
const newScenes = type === 'slide'
|
|
193
193
|
? (0, getScenesOnEnd_1.getScenesOnSlideEnd)(scenes, transition, transitionSuccess)
|
|
194
|
-
:
|
|
194
|
+
: type === 'reveal'
|
|
195
|
+
? (0, getScenesOnEnd_1.getScenesOnRevealEnd)(scenes, transition, transitionSuccess, transition.offset, transition.mode)
|
|
196
|
+
: (0, getScenesOnEnd_1.getScenesOnFadeEnd)(scenes);
|
|
195
197
|
return newScenes;
|
|
196
198
|
},
|
|
197
199
|
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Direction } from './types';
|
|
2
|
+
type Event = {
|
|
3
|
+
transition: 'slide';
|
|
4
|
+
to: string;
|
|
5
|
+
direction: Direction;
|
|
6
|
+
duration: number;
|
|
7
|
+
} | {
|
|
8
|
+
transition: 'reveal';
|
|
9
|
+
to: string;
|
|
10
|
+
direction: Direction;
|
|
11
|
+
duration: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
mode: 'normal' | 'reverse';
|
|
14
|
+
} | {
|
|
15
|
+
transition: 'fade';
|
|
16
|
+
to: string;
|
|
17
|
+
duration: number;
|
|
18
|
+
};
|
|
19
|
+
type Transition = 'slide' | 'reveal' | 'fade';
|
|
20
|
+
export declare function getInstantTransitionParams(transition: Transition, event: Event): {
|
|
21
|
+
direction: Direction;
|
|
22
|
+
type: "slide";
|
|
23
|
+
offset?: undefined;
|
|
24
|
+
mode?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
offset: number;
|
|
27
|
+
mode: "normal" | "reverse";
|
|
28
|
+
direction: Direction;
|
|
29
|
+
type: "reveal";
|
|
30
|
+
} | {
|
|
31
|
+
type: "fade";
|
|
32
|
+
direction?: undefined;
|
|
33
|
+
offset?: undefined;
|
|
34
|
+
mode?: undefined;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstantTransitionParams = getInstantTransitionParams;
|
|
4
|
+
function isTransitionEvent(event, transition) {
|
|
5
|
+
return event.transition === transition;
|
|
6
|
+
}
|
|
7
|
+
function getInstantTransitionParams(transition, event) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (transition === 'slide' && isTransitionEvent(event, transition)) {
|
|
10
|
+
return {
|
|
11
|
+
direction: (_a = event.direction) !== null && _a !== void 0 ? _a : 'north',
|
|
12
|
+
type: transition
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (transition === 'reveal' && isTransitionEvent(event, transition)) {
|
|
16
|
+
return {
|
|
17
|
+
offset: event.offset,
|
|
18
|
+
mode: event.mode,
|
|
19
|
+
direction: event.direction,
|
|
20
|
+
type: transition
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (transition === 'fade' && isTransitionEvent(event, transition)) {
|
|
24
|
+
return {
|
|
25
|
+
type: transition
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Unknown transition type`);
|
|
29
|
+
}
|
|
@@ -6,6 +6,18 @@ export declare function getScenesOnSlideEnd(scenes: TransitionScene[], transitio
|
|
|
6
6
|
startX: number;
|
|
7
7
|
startY: number;
|
|
8
8
|
opacity: number;
|
|
9
|
+
zIndex?: number;
|
|
10
|
+
};
|
|
11
|
+
id: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function getScenesOnRevealEnd(scenes: TransitionScene[], transition: ActiveTransition, success: boolean, offset: number, mode: 'normal' | 'reverse'): {
|
|
14
|
+
styles: {
|
|
15
|
+
zIndex: number;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
startX: number;
|
|
19
|
+
startY: number;
|
|
20
|
+
opacity: number;
|
|
9
21
|
};
|
|
10
22
|
id: string;
|
|
11
23
|
}[];
|
|
@@ -16,6 +28,7 @@ export declare function getScenesOnFadeEnd(scenes: TransitionScene[]): {
|
|
|
16
28
|
startY: number;
|
|
17
29
|
x: number;
|
|
18
30
|
y: number;
|
|
31
|
+
zIndex?: number;
|
|
19
32
|
};
|
|
20
33
|
id: string;
|
|
21
34
|
}[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getScenesOnSlideEnd = getScenesOnSlideEnd;
|
|
4
|
+
exports.getScenesOnRevealEnd = getScenesOnRevealEnd;
|
|
4
5
|
exports.getScenesOnFadeEnd = getScenesOnFadeEnd;
|
|
5
6
|
function getScenesOnSlideEnd(scenes, transition, success) {
|
|
6
7
|
const { from, to, direction } = transition;
|
|
@@ -23,6 +24,27 @@ function getScenesOnSlideEnd(scenes, transition, success) {
|
|
|
23
24
|
return Object.assign(Object.assign({}, s), { styles: Object.assign(Object.assign({}, s.styles), { x: isNextActiveScene ? 0 : prevElX, y: isNextActiveScene ? 0 : prevElY }) });
|
|
24
25
|
});
|
|
25
26
|
}
|
|
27
|
+
function getScenesOnRevealEnd(scenes, transition, success, offset, mode) {
|
|
28
|
+
const { from, to, direction } = transition;
|
|
29
|
+
return scenes.map((s) => {
|
|
30
|
+
const isNextActiveScene = success ? s.id === to : s.id === from;
|
|
31
|
+
let prevElX = 0;
|
|
32
|
+
if (direction === 'east') {
|
|
33
|
+
prevElX = success ? -window.innerWidth : window.innerWidth * offset;
|
|
34
|
+
}
|
|
35
|
+
else if (direction === 'west') {
|
|
36
|
+
prevElX = success ? window.innerWidth : -window.innerWidth * offset;
|
|
37
|
+
}
|
|
38
|
+
let prevElY = 0;
|
|
39
|
+
if (direction === 'north') {
|
|
40
|
+
prevElY = success ? window.innerHeight : -window.innerHeight * offset;
|
|
41
|
+
}
|
|
42
|
+
else if (direction === 'south') {
|
|
43
|
+
prevElY = success ? -window.innerHeight : window.innerHeight * offset;
|
|
44
|
+
}
|
|
45
|
+
return Object.assign(Object.assign({}, s), { styles: Object.assign(Object.assign({}, s.styles), { zIndex: isNextActiveScene ? 1 : 2, x: isNextActiveScene ? 0 : prevElX, y: isNextActiveScene ? 0 : prevElY }) });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
26
48
|
function getScenesOnFadeEnd(scenes) {
|
|
27
49
|
return scenes.map((s) => {
|
|
28
50
|
return Object.assign(Object.assign({}, s), { styles: Object.assign(Object.assign({}, s.styles), { opacity: 1 }) });
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getScenesOnInstantTransition = getScenesOnInstantTransition;
|
|
4
4
|
function getScenesOnInstantTransition(scenes, transition, window) {
|
|
5
|
-
const { type, to
|
|
6
|
-
if (type === 'slide' && direction) {
|
|
7
|
-
return getScenesOnInstantSlideTransition(scenes, to, direction, window);
|
|
5
|
+
const { type, to } = transition;
|
|
6
|
+
if ((type === 'slide' || type === 'reveal') && transition.direction) {
|
|
7
|
+
return getScenesOnInstantSlideTransition(scenes, to, transition.direction, window);
|
|
8
8
|
}
|
|
9
9
|
else if (type === 'fade') {
|
|
10
10
|
return getScenesOnInstantFadeTransition(scenes);
|
|
@@ -6,6 +6,18 @@ export declare function getScenesOnSlideProgressUpdate(scenes: TransitionScene[]
|
|
|
6
6
|
startX: number;
|
|
7
7
|
startY: number;
|
|
8
8
|
opacity: number;
|
|
9
|
+
zIndex?: number;
|
|
10
|
+
};
|
|
11
|
+
id: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function getScenesOnRevealProgressUpdate(scenes: TransitionScene[], delta: Delta, to: string, offset: number, mode: 'normal' | 'reverse'): {
|
|
14
|
+
styles: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
startX: number;
|
|
18
|
+
startY: number;
|
|
19
|
+
opacity: number;
|
|
20
|
+
zIndex?: number;
|
|
9
21
|
};
|
|
10
22
|
id: string;
|
|
11
23
|
}[];
|
|
@@ -16,6 +28,7 @@ export declare function getScenesOnFadeProgressUpdate(scenes: TransitionScene[],
|
|
|
16
28
|
startY: number;
|
|
17
29
|
x: number;
|
|
18
30
|
y: number;
|
|
31
|
+
zIndex?: number;
|
|
19
32
|
};
|
|
20
33
|
id: string;
|
|
21
34
|
}[];
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getScenesOnSlideProgressUpdate = getScenesOnSlideProgressUpdate;
|
|
4
|
+
exports.getScenesOnRevealProgressUpdate = getScenesOnRevealProgressUpdate;
|
|
4
5
|
exports.getScenesOnFadeProgressUpdate = getScenesOnFadeProgressUpdate;
|
|
5
6
|
const normalizeOpacity_1 = require("./normalizeOpacity");
|
|
6
7
|
function getScenesOnSlideProgressUpdate(scenes, delta) {
|
|
7
8
|
return scenes.map((scene) => (Object.assign(Object.assign({}, scene), { styles: Object.assign(Object.assign({}, scene.styles), { x: scene.styles.startX + delta.x, y: scene.styles.startY + delta.y }) })));
|
|
8
9
|
}
|
|
10
|
+
function getScenesOnRevealProgressUpdate(scenes, delta, to, offset, mode) {
|
|
11
|
+
return scenes.map((scene) => {
|
|
12
|
+
const isNextScene = scene.id === to;
|
|
13
|
+
const sceneOffset = isNextScene ? offset : 1;
|
|
14
|
+
return Object.assign(Object.assign({}, scene), { styles: Object.assign(Object.assign({}, scene.styles), { x: scene.styles.startX + delta.x * sceneOffset, y: scene.styles.startY + delta.y * sceneOffset }) });
|
|
15
|
+
});
|
|
16
|
+
}
|
|
9
17
|
function getScenesOnFadeProgressUpdate(scenes, to, progress) {
|
|
10
18
|
return scenes.map((scene) => {
|
|
11
19
|
const isNextScene = scene.id === to;
|
|
@@ -10,6 +10,7 @@ export declare function getScenesOnFadeStart({ from, to }: FromTo, progress: num
|
|
|
10
10
|
};
|
|
11
11
|
}[];
|
|
12
12
|
export declare function getScenesOnSlideStart({ from, to }: FromTo, delta: Delta, direction: Direction, window: Window): TransitionScene[];
|
|
13
|
+
export declare function getScenesOnRevealStart({ from, to }: FromTo, delta: Delta, direction: Direction, offset: number, mode: 'normal' | 'reverse', window: Window): TransitionScene[];
|
|
13
14
|
type Delta = {
|
|
14
15
|
x: number;
|
|
15
16
|
y: number;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getScenesOnFadeStart = getScenesOnFadeStart;
|
|
4
4
|
exports.getScenesOnSlideStart = getScenesOnSlideStart;
|
|
5
|
+
exports.getScenesOnRevealStart = getScenesOnRevealStart;
|
|
5
6
|
const getAxis_1 = require("./getAxis");
|
|
6
7
|
const normalizeOpacity_1 = require("./normalizeOpacity");
|
|
7
8
|
function getScenesOnFadeStart({ from, to }, progress) {
|
|
@@ -38,15 +39,32 @@ function getScenesOnSlideStart({ from, to }, delta, direction, window) {
|
|
|
38
39
|
};
|
|
39
40
|
return [sceneFrom, sceneTo];
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
+
function getScenesOnRevealStart({ from, to }, delta, direction, offset, mode, window) {
|
|
43
|
+
const common = {
|
|
44
|
+
opacity: 1,
|
|
45
|
+
};
|
|
46
|
+
const sceneFrom = {
|
|
47
|
+
id: from,
|
|
48
|
+
styles: Object.assign(Object.assign({}, common), { startX: 0, zIndex: 2, startY: 0, x: delta.x, y: delta.y })
|
|
49
|
+
};
|
|
50
|
+
const startX = getNextSceneSlideStartX(direction, window, offset);
|
|
51
|
+
const startY = getNextSceneSlideStartY(direction, window, offset);
|
|
52
|
+
const sceneTo = {
|
|
53
|
+
id: to,
|
|
54
|
+
styles: Object.assign(Object.assign({}, common), { zIndex: 1, startX,
|
|
55
|
+
startY, x: startX + delta.x * offset, y: startY + delta.y * offset })
|
|
56
|
+
};
|
|
57
|
+
return [sceneFrom, sceneTo];
|
|
58
|
+
}
|
|
59
|
+
function getNextSceneSlideStartX(direction, window, offset = 1) {
|
|
42
60
|
const axis = (0, getAxis_1.getAxis)(direction);
|
|
43
61
|
if (axis !== 'horizontal')
|
|
44
62
|
return 0;
|
|
45
|
-
return direction === 'east' ? window.innerWidth : -window.innerWidth;
|
|
63
|
+
return direction === 'east' ? window.innerWidth * offset : -window.innerWidth * offset;
|
|
46
64
|
}
|
|
47
|
-
function getNextSceneSlideStartY(direction, window) {
|
|
65
|
+
function getNextSceneSlideStartY(direction, window, offset = 1) {
|
|
48
66
|
const axis = (0, getAxis_1.getAxis)(direction);
|
|
49
67
|
if (axis !== 'vertical')
|
|
50
68
|
return 0;
|
|
51
|
-
return direction === 'north' ? -window.innerHeight : window.innerHeight;
|
|
69
|
+
return direction === 'north' ? -window.innerHeight * offset : window.innerHeight * offset;
|
|
52
70
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClickLink } from '../../types/article/Item';
|
|
2
|
+
export declare function getTransitionFromLink(link: ClickLink): {
|
|
3
|
+
transition: "fade";
|
|
4
|
+
to: string;
|
|
5
|
+
duration: number;
|
|
6
|
+
offset?: undefined;
|
|
7
|
+
mode?: undefined;
|
|
8
|
+
direction?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
transition: "reveal";
|
|
11
|
+
to: string;
|
|
12
|
+
offset: number;
|
|
13
|
+
mode: "normal" | "reverse";
|
|
14
|
+
direction: "north" | "east" | "south" | "west";
|
|
15
|
+
duration: number;
|
|
16
|
+
} | {
|
|
17
|
+
transition: "slide";
|
|
18
|
+
to: string;
|
|
19
|
+
direction: "north" | "east" | "south" | "west";
|
|
20
|
+
duration: number;
|
|
21
|
+
offset?: undefined;
|
|
22
|
+
mode?: undefined;
|
|
23
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransitionFromLink = getTransitionFromLink;
|
|
4
|
+
function getTransitionFromLink(link) {
|
|
5
|
+
if (link.animation === 'fade') {
|
|
6
|
+
return {
|
|
7
|
+
transition: link.animation,
|
|
8
|
+
to: link.value,
|
|
9
|
+
duration: link.duration
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (link.animation === 'reveal') {
|
|
13
|
+
return {
|
|
14
|
+
transition: link.animation,
|
|
15
|
+
to: link.value,
|
|
16
|
+
offset: link.offset,
|
|
17
|
+
mode: link.mode,
|
|
18
|
+
direction: link.direction,
|
|
19
|
+
duration: link.duration
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (link.animation === 'slide') {
|
|
23
|
+
return {
|
|
24
|
+
transition: link.animation,
|
|
25
|
+
to: link.value,
|
|
26
|
+
direction: link.direction,
|
|
27
|
+
duration: link.duration
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Unknown transition type`);
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Relation } from './types';
|
|
2
|
+
export declare function getTransitionFromRelation(transition: Relation): {
|
|
3
|
+
transition: "fade";
|
|
4
|
+
to: string;
|
|
5
|
+
offset?: undefined;
|
|
6
|
+
mode?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
transition: "reveal";
|
|
9
|
+
to: string;
|
|
10
|
+
offset: number;
|
|
11
|
+
mode: "normal" | "reverse";
|
|
12
|
+
} | {
|
|
13
|
+
transition: "slide";
|
|
14
|
+
to: string;
|
|
15
|
+
offset?: undefined;
|
|
16
|
+
mode?: undefined;
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransitionFromRelation = getTransitionFromRelation;
|
|
4
|
+
function getTransitionFromRelation(transition) {
|
|
5
|
+
if (transition.type === 'fade') {
|
|
6
|
+
return {
|
|
7
|
+
transition: transition.type,
|
|
8
|
+
to: transition.to
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (transition.type === 'reveal') {
|
|
12
|
+
return {
|
|
13
|
+
transition: transition.type,
|
|
14
|
+
to: transition.to,
|
|
15
|
+
offset: transition.offset,
|
|
16
|
+
mode: transition.mode
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (transition.type === 'slide') {
|
|
20
|
+
return {
|
|
21
|
+
transition: transition.type,
|
|
22
|
+
to: transition.to,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Unknown transition type`);
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Relation } from './types';
|
|
2
|
+
export declare function getTransitionParamsFromRelation(relation: Relation): {
|
|
3
|
+
type: "slide";
|
|
4
|
+
from: string;
|
|
5
|
+
to: string;
|
|
6
|
+
offset?: undefined;
|
|
7
|
+
mode?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
offset: number;
|
|
10
|
+
mode: "normal" | "reverse";
|
|
11
|
+
type: "reveal";
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "fade";
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
offset?: undefined;
|
|
19
|
+
mode?: undefined;
|
|
20
|
+
};
|