@gxpl/sdk 0.0.56 → 0.0.57
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/utils/getScenesOnEnd.js +5 -5
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +24 -1
- package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.js +1 -2
- package/lib/sdk/transitions/utils/getScenesOnStart.js +7 -5
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.d.ts +1 -0
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +28 -5
- package/package.json +1 -1
|
@@ -30,19 +30,19 @@ function getScenesOnRevealEnd(scenes, transition, success, offset, mode) {
|
|
|
30
30
|
const isNextActiveScene = success ? s.id === to : s.id === from;
|
|
31
31
|
let prevElX = 0;
|
|
32
32
|
if (direction === 'east') {
|
|
33
|
-
prevElX = success ? -window.innerWidth : window.innerWidth * offset;
|
|
33
|
+
prevElX = success ? -window.innerWidth * (mode === 'normal' ? 1 : offset) : window.innerWidth * (mode === 'normal' ? offset : 1);
|
|
34
34
|
}
|
|
35
35
|
else if (direction === 'west') {
|
|
36
|
-
prevElX = success ? window.innerWidth : -window.innerWidth * offset;
|
|
36
|
+
prevElX = success ? window.innerWidth * (mode === 'normal' ? 1 : offset) : -window.innerWidth * (mode === 'normal' ? offset : 1);
|
|
37
37
|
}
|
|
38
38
|
let prevElY = 0;
|
|
39
39
|
if (direction === 'north') {
|
|
40
|
-
prevElY = success ? window.innerHeight : -window.innerHeight * offset;
|
|
40
|
+
prevElY = success ? window.innerHeight * (mode === 'normal' ? 1 : offset) : -window.innerHeight * (mode === 'normal' ? offset : 1);
|
|
41
41
|
}
|
|
42
42
|
else if (direction === 'south') {
|
|
43
|
-
prevElY = success ? -window.innerHeight : window.innerHeight * offset;
|
|
43
|
+
prevElY = success ? -window.innerHeight * (mode === 'normal' ? 1 : offset) : window.innerHeight * (mode === 'normal' ? offset : 1);
|
|
44
44
|
}
|
|
45
|
-
return Object.assign(Object.assign({}, s), { styles: Object.assign(Object.assign({}, s.styles), { zIndex: isNextActiveScene ? 1 :
|
|
45
|
+
return Object.assign(Object.assign({}, s), { styles: Object.assign(Object.assign({}, s.styles), { zIndex: isNextActiveScene ? 1 : 0, x: isNextActiveScene ? 0 : prevElX, y: isNextActiveScene ? 0 : prevElY }) });
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function getScenesOnFadeEnd(scenes) {
|
|
@@ -3,14 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getScenesOnInstantTransition = getScenesOnInstantTransition;
|
|
4
4
|
function getScenesOnInstantTransition(scenes, transition, window) {
|
|
5
5
|
const { type, to } = transition;
|
|
6
|
-
if (
|
|
6
|
+
if (type === 'slide' && transition.direction) {
|
|
7
7
|
return getScenesOnInstantSlideTransition(scenes, to, transition.direction, window);
|
|
8
8
|
}
|
|
9
|
+
else if (type === 'reveal' && transition.direction) {
|
|
10
|
+
return getScenesOnInstantRevealTransition(scenes, to, transition.direction, transition.offset, transition.mode, window);
|
|
11
|
+
}
|
|
9
12
|
else if (type === 'fade') {
|
|
10
13
|
return getScenesOnInstantFadeTransition(scenes);
|
|
11
14
|
}
|
|
12
15
|
return scenes;
|
|
13
16
|
}
|
|
17
|
+
function getScenesOnInstantRevealTransition(scenes, to, direction, offset, mode, window) {
|
|
18
|
+
let fromFinalX = 0;
|
|
19
|
+
let fromFinalY = 0;
|
|
20
|
+
if (direction === 'east') {
|
|
21
|
+
fromFinalX = -window.innerWidth * (mode === 'normal' ? 1 : offset);
|
|
22
|
+
}
|
|
23
|
+
else if (direction === 'west') {
|
|
24
|
+
fromFinalX = window.innerWidth * (mode === 'normal' ? 1 : offset);
|
|
25
|
+
}
|
|
26
|
+
else if (direction === 'north') {
|
|
27
|
+
fromFinalY = window.innerHeight * (mode === 'normal' ? 1 : offset);
|
|
28
|
+
}
|
|
29
|
+
else if (direction === 'south') {
|
|
30
|
+
fromFinalY = -window.innerHeight * (mode === 'normal' ? 1 : offset);
|
|
31
|
+
}
|
|
32
|
+
return scenes.map((scene) => {
|
|
33
|
+
const isToScene = scene.id === to;
|
|
34
|
+
return Object.assign(Object.assign({}, scene), { styles: Object.assign(Object.assign({}, scene.styles), { x: isToScene ? 0 : fromFinalX, y: isToScene ? 0 : fromFinalY }) });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
14
37
|
function getScenesOnInstantSlideTransition(scenes, to, direction, window) {
|
|
15
38
|
let fromFinalX = 0;
|
|
16
39
|
let fromFinalY = 0;
|
|
@@ -9,8 +9,7 @@ function getScenesOnSlideProgressUpdate(scenes, delta) {
|
|
|
9
9
|
}
|
|
10
10
|
function getScenesOnRevealProgressUpdate(scenes, delta, to, offset, mode) {
|
|
11
11
|
return scenes.map((scene) => {
|
|
12
|
-
const
|
|
13
|
-
const sceneOffset = isNextScene ? offset : 1;
|
|
12
|
+
const sceneOffset = (scene.id === to) === (mode === 'normal') ? offset : 1;
|
|
14
13
|
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
14
|
});
|
|
16
15
|
}
|
|
@@ -43,16 +43,18 @@ function getScenesOnRevealStart({ from, to }, delta, direction, offset, mode, wi
|
|
|
43
43
|
const common = {
|
|
44
44
|
opacity: 1,
|
|
45
45
|
};
|
|
46
|
+
const fromSceneOffset = mode === 'normal' ? 1 : offset;
|
|
46
47
|
const sceneFrom = {
|
|
47
48
|
id: from,
|
|
48
|
-
styles: Object.assign(Object.assign({}, common), { startX: 0, zIndex: 2, startY: 0, x: delta.x, y: delta.y })
|
|
49
|
+
styles: Object.assign(Object.assign({}, common), { startX: 0, zIndex: mode === 'normal' ? 2 : 1, startY: 0, x: delta.x * fromSceneOffset, y: delta.y * fromSceneOffset })
|
|
49
50
|
};
|
|
50
|
-
const
|
|
51
|
-
const
|
|
51
|
+
const toSceneOffset = mode === 'normal' ? offset : 1;
|
|
52
|
+
const startX = getNextSceneSlideStartX(direction, window, toSceneOffset);
|
|
53
|
+
const startY = getNextSceneSlideStartY(direction, window, toSceneOffset);
|
|
52
54
|
const sceneTo = {
|
|
53
55
|
id: to,
|
|
54
|
-
styles: Object.assign(Object.assign({}, common), { zIndex: 1, startX,
|
|
55
|
-
startY, x: startX + delta.x *
|
|
56
|
+
styles: Object.assign(Object.assign({}, common), { zIndex: mode === 'normal' ? 1 : 2, startX,
|
|
57
|
+
startY, x: startX + delta.x * toSceneOffset, y: startY + delta.y * toSceneOffset })
|
|
56
58
|
};
|
|
57
59
|
return [sceneFrom, sceneTo];
|
|
58
60
|
}
|
|
@@ -151,7 +151,6 @@ class RichTextConverter {
|
|
|
151
151
|
return styleGroups;
|
|
152
152
|
}
|
|
153
153
|
groupEntities(entities, styleGroups) {
|
|
154
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
155
154
|
const entitiesGroups = [];
|
|
156
155
|
if (!entities.length && !styleGroups)
|
|
157
156
|
return;
|
|
@@ -170,8 +169,8 @@ class RichTextConverter {
|
|
|
170
169
|
const start = dividers[i];
|
|
171
170
|
const end = dividers[i + 1];
|
|
172
171
|
const entity = entities.find(e => e.start === start);
|
|
173
|
-
entitiesGroups.push(Object.assign(
|
|
174
|
-
end },
|
|
172
|
+
entitiesGroups.push(Object.assign({ stylesGroup: [], start,
|
|
173
|
+
end }, this.getLinkFromEntity(entity)));
|
|
175
174
|
}
|
|
176
175
|
return entitiesGroups;
|
|
177
176
|
}
|
|
@@ -197,11 +196,35 @@ class RichTextConverter {
|
|
|
197
196
|
const start = entityDividers[i];
|
|
198
197
|
const end = entityDividers[i + 1];
|
|
199
198
|
const entity = entities.find(e => e.start === start);
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
const link = this.getLinkFromEntity(entity);
|
|
200
|
+
entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
|
|
201
|
+
end }, link));
|
|
202
202
|
}
|
|
203
203
|
return entitiesGroups;
|
|
204
204
|
}
|
|
205
|
+
getLinkFromEntity(entity) {
|
|
206
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
207
|
+
if (!entity)
|
|
208
|
+
return;
|
|
209
|
+
const { data } = entity;
|
|
210
|
+
if (!data)
|
|
211
|
+
return;
|
|
212
|
+
if (data.type === 'url' || data.type === 'anchor') {
|
|
213
|
+
return { url: data.url, target: (_a = data.target) !== null && _a !== void 0 ? _a : '_self' };
|
|
214
|
+
}
|
|
215
|
+
if (data.type === 'scene') {
|
|
216
|
+
if (data.animation === 'fade') {
|
|
217
|
+
return { type: 'scene', value: data.value, animation: 'fade', duration: (_b = data.duration) !== null && _b !== void 0 ? _b : 0 };
|
|
218
|
+
}
|
|
219
|
+
if (data.animation === 'slide') {
|
|
220
|
+
return { type: 'scene', value: data.value, animation: 'slide', direction: (_c = data.direction) !== null && _c !== void 0 ? _c : 'north', duration: (_d = data.duration) !== null && _d !== void 0 ? _d : 0 };
|
|
221
|
+
}
|
|
222
|
+
if (data.animation === 'reveal') {
|
|
223
|
+
return { type: 'scene', value: data.value, animation: 'reveal', direction: (_e = data.direction) !== null && _e !== void 0 ? _e : 'north', offset: (_f = data.offset) !== null && _f !== void 0 ? _f : 0, mode: (_g = data.mode) !== null && _g !== void 0 ? _g : 'normal', duration: (_h = data.duration) !== null && _h !== void 0 ? _h : 0 };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
205
228
|
static fromRangeStylesToInline(draftStyle, exemplary) {
|
|
206
229
|
const { value, name } = draftStyle;
|
|
207
230
|
const map = {
|