@inappstory/slide-api 0.1.13 → 0.1.15
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/dist/index.cjs +131 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +131 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1211,7 +1211,9 @@ class DataInput {
|
|
|
1211
1211
|
onStop() {
|
|
1212
1212
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1213
1213
|
}
|
|
1214
|
-
onBeforeUnmount() {
|
|
1214
|
+
onBeforeUnmount() {
|
|
1215
|
+
return Promise.resolve();
|
|
1216
|
+
}
|
|
1215
1217
|
handleClick() {
|
|
1216
1218
|
return false;
|
|
1217
1219
|
}
|
|
@@ -1259,7 +1261,9 @@ class Barcode {
|
|
|
1259
1261
|
onStop() {
|
|
1260
1262
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1261
1263
|
}
|
|
1262
|
-
onBeforeUnmount() {
|
|
1264
|
+
onBeforeUnmount() {
|
|
1265
|
+
return Promise.resolve();
|
|
1266
|
+
}
|
|
1263
1267
|
handleClick() {
|
|
1264
1268
|
return false;
|
|
1265
1269
|
}
|
|
@@ -1297,7 +1301,9 @@ class Button extends ClickableBase {
|
|
|
1297
1301
|
onResume() { }
|
|
1298
1302
|
onStart() { }
|
|
1299
1303
|
onStop() { }
|
|
1300
|
-
onBeforeUnmount() {
|
|
1304
|
+
onBeforeUnmount() {
|
|
1305
|
+
return Promise.resolve();
|
|
1306
|
+
}
|
|
1301
1307
|
handleClick() {
|
|
1302
1308
|
return false;
|
|
1303
1309
|
}
|
|
@@ -1342,7 +1348,9 @@ class Copy {
|
|
|
1342
1348
|
onStop() {
|
|
1343
1349
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1344
1350
|
}
|
|
1345
|
-
onBeforeUnmount() {
|
|
1351
|
+
onBeforeUnmount() {
|
|
1352
|
+
return Promise.resolve();
|
|
1353
|
+
}
|
|
1346
1354
|
handleClick() {
|
|
1347
1355
|
return false;
|
|
1348
1356
|
}
|
|
@@ -1393,7 +1401,9 @@ class DateCountdown {
|
|
|
1393
1401
|
onStop() {
|
|
1394
1402
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1395
1403
|
}
|
|
1396
|
-
onBeforeUnmount() {
|
|
1404
|
+
onBeforeUnmount() {
|
|
1405
|
+
return Promise.resolve();
|
|
1406
|
+
}
|
|
1397
1407
|
handleClick() {
|
|
1398
1408
|
return false;
|
|
1399
1409
|
}
|
|
@@ -1441,7 +1451,9 @@ class Poll {
|
|
|
1441
1451
|
onStop() {
|
|
1442
1452
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1443
1453
|
}
|
|
1444
|
-
onBeforeUnmount() {
|
|
1454
|
+
onBeforeUnmount() {
|
|
1455
|
+
return Promise.resolve();
|
|
1456
|
+
}
|
|
1445
1457
|
handleClick() {
|
|
1446
1458
|
return false;
|
|
1447
1459
|
}
|
|
@@ -1494,7 +1506,9 @@ class PollLayers {
|
|
|
1494
1506
|
onStop() {
|
|
1495
1507
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1496
1508
|
}
|
|
1497
|
-
onBeforeUnmount() {
|
|
1509
|
+
onBeforeUnmount() {
|
|
1510
|
+
return Promise.resolve();
|
|
1511
|
+
}
|
|
1498
1512
|
handleClick() {
|
|
1499
1513
|
return false;
|
|
1500
1514
|
}
|
|
@@ -1542,7 +1556,9 @@ class Products {
|
|
|
1542
1556
|
onStop() {
|
|
1543
1557
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1544
1558
|
}
|
|
1545
|
-
onBeforeUnmount() {
|
|
1559
|
+
onBeforeUnmount() {
|
|
1560
|
+
return Promise.resolve();
|
|
1561
|
+
}
|
|
1546
1562
|
handleClick() {
|
|
1547
1563
|
return false;
|
|
1548
1564
|
}
|
|
@@ -1593,7 +1609,9 @@ class Quest {
|
|
|
1593
1609
|
onStop() {
|
|
1594
1610
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1595
1611
|
}
|
|
1596
|
-
onBeforeUnmount() {
|
|
1612
|
+
onBeforeUnmount() {
|
|
1613
|
+
return Promise.resolve();
|
|
1614
|
+
}
|
|
1597
1615
|
handleClick() {
|
|
1598
1616
|
return false;
|
|
1599
1617
|
}
|
|
@@ -1645,7 +1663,9 @@ class Quiz {
|
|
|
1645
1663
|
onStop() {
|
|
1646
1664
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1647
1665
|
}
|
|
1648
|
-
onBeforeUnmount() {
|
|
1666
|
+
onBeforeUnmount() {
|
|
1667
|
+
return Promise.resolve();
|
|
1668
|
+
}
|
|
1649
1669
|
handleClick() {
|
|
1650
1670
|
return false;
|
|
1651
1671
|
}
|
|
@@ -1696,7 +1716,9 @@ class QuizGrouped {
|
|
|
1696
1716
|
onStop() {
|
|
1697
1717
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1698
1718
|
}
|
|
1699
|
-
onBeforeUnmount() {
|
|
1719
|
+
onBeforeUnmount() {
|
|
1720
|
+
return Promise.resolve();
|
|
1721
|
+
}
|
|
1700
1722
|
handleClick() {
|
|
1701
1723
|
return false;
|
|
1702
1724
|
}
|
|
@@ -1747,7 +1769,9 @@ class RangeSlider {
|
|
|
1747
1769
|
onStop() {
|
|
1748
1770
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1749
1771
|
}
|
|
1750
|
-
onBeforeUnmount() {
|
|
1772
|
+
onBeforeUnmount() {
|
|
1773
|
+
return Promise.resolve();
|
|
1774
|
+
}
|
|
1751
1775
|
get isClickCapturedBySlider() {
|
|
1752
1776
|
return this._widgetApi.isClickCapturedBySlider(this._elementNodeRef);
|
|
1753
1777
|
}
|
|
@@ -1798,7 +1822,9 @@ class Rate {
|
|
|
1798
1822
|
onStop() {
|
|
1799
1823
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1800
1824
|
}
|
|
1801
|
-
onBeforeUnmount() {
|
|
1825
|
+
onBeforeUnmount() {
|
|
1826
|
+
return Promise.resolve();
|
|
1827
|
+
}
|
|
1802
1828
|
handleClick() {
|
|
1803
1829
|
return false;
|
|
1804
1830
|
}
|
|
@@ -1852,7 +1878,9 @@ class Share {
|
|
|
1852
1878
|
onStop() {
|
|
1853
1879
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1854
1880
|
}
|
|
1855
|
-
onBeforeUnmount() {
|
|
1881
|
+
onBeforeUnmount() {
|
|
1882
|
+
return Promise.resolve();
|
|
1883
|
+
}
|
|
1856
1884
|
handleClick() {
|
|
1857
1885
|
return false;
|
|
1858
1886
|
}
|
|
@@ -1887,7 +1915,9 @@ class SwipeUpItems {
|
|
|
1887
1915
|
onResume() { }
|
|
1888
1916
|
onStart() { }
|
|
1889
1917
|
onStop() { }
|
|
1890
|
-
onBeforeUnmount() {
|
|
1918
|
+
onBeforeUnmount() {
|
|
1919
|
+
return Promise.resolve();
|
|
1920
|
+
}
|
|
1891
1921
|
handleClick() {
|
|
1892
1922
|
return false;
|
|
1893
1923
|
}
|
|
@@ -1938,7 +1968,9 @@ class Test {
|
|
|
1938
1968
|
onStop() {
|
|
1939
1969
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1940
1970
|
}
|
|
1941
|
-
onBeforeUnmount() {
|
|
1971
|
+
onBeforeUnmount() {
|
|
1972
|
+
return Promise.resolve();
|
|
1973
|
+
}
|
|
1942
1974
|
handleClick() {
|
|
1943
1975
|
return false;
|
|
1944
1976
|
}
|
|
@@ -1989,7 +2021,9 @@ class Vote {
|
|
|
1989
2021
|
onStop() {
|
|
1990
2022
|
this._widgetApi.onStop(this._elementNodeRef);
|
|
1991
2023
|
}
|
|
1992
|
-
onBeforeUnmount() {
|
|
2024
|
+
onBeforeUnmount() {
|
|
2025
|
+
return Promise.resolve();
|
|
2026
|
+
}
|
|
1993
2027
|
handleClick() {
|
|
1994
2028
|
return false;
|
|
1995
2029
|
}
|
|
@@ -2018,7 +2052,9 @@ class Text {
|
|
|
2018
2052
|
onResume() { }
|
|
2019
2053
|
onStart() { }
|
|
2020
2054
|
onStop() { }
|
|
2021
|
-
onBeforeUnmount() {
|
|
2055
|
+
onBeforeUnmount() {
|
|
2056
|
+
return Promise.resolve();
|
|
2057
|
+
}
|
|
2022
2058
|
handleClick() {
|
|
2023
2059
|
return false;
|
|
2024
2060
|
}
|
|
@@ -2139,7 +2175,9 @@ class Image extends ClickableBase {
|
|
|
2139
2175
|
onResume() { }
|
|
2140
2176
|
onStart() { }
|
|
2141
2177
|
onStop() { }
|
|
2142
|
-
onBeforeUnmount() {
|
|
2178
|
+
onBeforeUnmount() {
|
|
2179
|
+
return Promise.resolve();
|
|
2180
|
+
}
|
|
2143
2181
|
handleClick() {
|
|
2144
2182
|
return false;
|
|
2145
2183
|
}
|
|
@@ -2171,7 +2209,9 @@ class SwipeUp {
|
|
|
2171
2209
|
onResume() { }
|
|
2172
2210
|
onStart() { }
|
|
2173
2211
|
onStop() { }
|
|
2174
|
-
onBeforeUnmount() {
|
|
2212
|
+
onBeforeUnmount() {
|
|
2213
|
+
return Promise.resolve();
|
|
2214
|
+
}
|
|
2175
2215
|
handleClick() {
|
|
2176
2216
|
return false;
|
|
2177
2217
|
}
|
|
@@ -2270,12 +2310,12 @@ class Video {
|
|
|
2270
2310
|
}
|
|
2271
2311
|
onStart() { }
|
|
2272
2312
|
onStop() { }
|
|
2273
|
-
onBeforeUnmount() {
|
|
2313
|
+
async onBeforeUnmount() {
|
|
2274
2314
|
// clean up memory and cpu processes
|
|
2275
2315
|
// @ts-ignore
|
|
2276
2316
|
// _log("onBeforeUnmount", true)
|
|
2277
2317
|
// console.log("onBeforeUnmount")
|
|
2278
|
-
this._destroyVODPlayer();
|
|
2318
|
+
return await this._destroyVODPlayer();
|
|
2279
2319
|
}
|
|
2280
2320
|
_initVOD(vodData) {
|
|
2281
2321
|
const onWaiting = () => {
|
|
@@ -3398,10 +3438,8 @@ class Layer {
|
|
|
3398
3438
|
disableAudio() {
|
|
3399
3439
|
this.videoElement?.disableAudio();
|
|
3400
3440
|
}
|
|
3401
|
-
onBeforeUnmount() {
|
|
3402
|
-
|
|
3403
|
-
element.onBeforeUnmount();
|
|
3404
|
-
}
|
|
3441
|
+
async onBeforeUnmount() {
|
|
3442
|
+
return Promise.all(this._elements.map(element => element.onBeforeUnmount())).then();
|
|
3405
3443
|
}
|
|
3406
3444
|
get isLayerForcePaused() {
|
|
3407
3445
|
return this.elements.some(element => element.isLayerForcePaused);
|
|
@@ -3683,10 +3721,8 @@ class Slide {
|
|
|
3683
3721
|
}
|
|
3684
3722
|
});
|
|
3685
3723
|
}
|
|
3686
|
-
onBeforeUnmount() {
|
|
3687
|
-
|
|
3688
|
-
layer.onBeforeUnmount();
|
|
3689
|
-
}
|
|
3724
|
+
async onBeforeUnmount() {
|
|
3725
|
+
return Promise.all(this._layers.map(layer => layer.onBeforeUnmount())).then();
|
|
3690
3726
|
}
|
|
3691
3727
|
get layoutService() {
|
|
3692
3728
|
return container.get({ identifier: "LayoutService" });
|
|
@@ -3749,9 +3785,9 @@ let SlideApi$1 = class SlideApi {
|
|
|
3749
3785
|
});
|
|
3750
3786
|
}
|
|
3751
3787
|
}
|
|
3752
|
-
destroy() {
|
|
3788
|
+
async destroy() {
|
|
3753
3789
|
if (this.slide != null) {
|
|
3754
|
-
this.slide.onBeforeUnmount();
|
|
3790
|
+
await this.slide.onBeforeUnmount();
|
|
3755
3791
|
}
|
|
3756
3792
|
this.destroyListeners();
|
|
3757
3793
|
this._state = 13 /* STATE.DESTROYED */;
|
|
@@ -3783,22 +3819,30 @@ let SlideApi$1 = class SlideApi {
|
|
|
3783
3819
|
let xOffset = "0px";
|
|
3784
3820
|
// for elements with bottom anchor (absolute position)
|
|
3785
3821
|
let yOffset = "0px";
|
|
3786
|
-
// alert(viewportHeight);
|
|
3787
|
-
if (viewportRatio > _ratio) {
|
|
3788
|
-
// disable _isFullscreen if viewport small
|
|
3789
|
-
_isFullscreen = false;
|
|
3790
|
-
}
|
|
3791
3822
|
if (_isFullscreen) {
|
|
3792
|
-
//
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3823
|
+
// более квадратное чем надо (desktop)
|
|
3824
|
+
if (viewportRatio > _ratio) {
|
|
3825
|
+
// fit by height
|
|
3826
|
+
slideHeight = viewportHeight;
|
|
3827
|
+
slideWidth = Math.ceil(slideHeight * _ratio);
|
|
3828
|
+
offset = Math.ceil(slideWidth - viewportWidth) / 2;
|
|
3829
|
+
if (slideOffset != null) {
|
|
3830
|
+
slideOffset.style.margin = "0 " + -offset + "px"; // -8.5
|
|
3831
|
+
}
|
|
3832
|
+
xOffset = offset + "px";
|
|
3833
|
+
}
|
|
3834
|
+
else {
|
|
3835
|
+
// fit by width, top and bottom - to offscreen or fill with bg image
|
|
3836
|
+
slideWidth = viewportWidth;
|
|
3837
|
+
slideHeight = Math.ceil(viewportWidth / _ratio);
|
|
3838
|
+
offset = Math.ceil(slideHeight - viewportHeight) / 2;
|
|
3839
|
+
if (slideOffset != null) {
|
|
3840
|
+
slideOffset.style.margin = -1 * offset + "px" + " 0 ";
|
|
3841
|
+
}
|
|
3842
|
+
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
3843
|
+
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
3844
|
+
// detect safe area offset
|
|
3798
3845
|
}
|
|
3799
|
-
// offset from viewport bottom to StoryBottom plus safe area offset bottom
|
|
3800
|
-
yOffset = `calc(${offset + this._overlappingActionBarHeight}px + env(safe-area-inset-bottom))`;
|
|
3801
|
-
// detect safe area offset
|
|
3802
3846
|
}
|
|
3803
3847
|
else {
|
|
3804
3848
|
// более квадратное чем надо
|
|
@@ -3846,7 +3890,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
3846
3890
|
if (slideBox && slideBoxPrerender) {
|
|
3847
3891
|
if (this._slideInRender) {
|
|
3848
3892
|
this._slideInRender = false;
|
|
3849
|
-
this._slideBoxRenderComplete(null);
|
|
3893
|
+
await this._slideBoxRenderComplete(null);
|
|
3850
3894
|
}
|
|
3851
3895
|
this._slideInInit = null;
|
|
3852
3896
|
this._slideInRender = true;
|
|
@@ -4009,7 +4053,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4009
4053
|
this._state = 1 /* STATE.INITED */;
|
|
4010
4054
|
await mediaResourcesWithTimeoutPromise;
|
|
4011
4055
|
result.result = true;
|
|
4012
|
-
slideBoxCb();
|
|
4056
|
+
await slideBoxCb();
|
|
4013
4057
|
}
|
|
4014
4058
|
else {
|
|
4015
4059
|
this._state = 12 /* STATE.STOPPED */;
|
|
@@ -4021,7 +4065,7 @@ let SlideApi$1 = class SlideApi {
|
|
|
4021
4065
|
}
|
|
4022
4066
|
catch (reason) {
|
|
4023
4067
|
console.log("SlideInit, onAllMediaLoaded reject", reason);
|
|
4024
|
-
slideBoxCb();
|
|
4068
|
+
await slideBoxCb();
|
|
4025
4069
|
this.layoutService.env.setTimeout(() => {
|
|
4026
4070
|
slideReadyResolve();
|
|
4027
4071
|
});
|
|
@@ -4031,31 +4075,48 @@ let SlideApi$1 = class SlideApi {
|
|
|
4031
4075
|
return result;
|
|
4032
4076
|
}
|
|
4033
4077
|
_slideInRender = false;
|
|
4034
|
-
_slideBoxRenderComplete(prevSlide) {
|
|
4078
|
+
async _slideBoxRenderComplete(prevSlide) {
|
|
4035
4079
|
if (!this._slideInRender) {
|
|
4036
4080
|
this._slideInRender = true;
|
|
4037
4081
|
return;
|
|
4038
4082
|
}
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
slideBoxPrerender
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4083
|
+
return new Promise(resolve => {
|
|
4084
|
+
const slideBox = this._slideWrapper.querySelector(`.${SlideApi.renderedBoxClassName}`);
|
|
4085
|
+
const slideBoxPrerender = this._slideWrapper.querySelector(`.${SlideApi.prerenderBoxClassName}`);
|
|
4086
|
+
if (slideBox && slideBoxPrerender) {
|
|
4087
|
+
slideBoxPrerender.classList.remove(SlideApi.prerenderBoxClassName);
|
|
4088
|
+
slideBox.classList.remove(SlideApi.renderedBoxClassName);
|
|
4089
|
+
slideBox.classList.add(SlideApi.prerenderBoxClassName);
|
|
4090
|
+
// pause Video - prevent triggering onDataWaiting from VODPlayer
|
|
4091
|
+
prevSlide?.activeLayer.pause(false, true, false);
|
|
4092
|
+
// 2 RAF - wait for browser render complete (CSS changes, etc.)
|
|
4093
|
+
if (prevSlide) {
|
|
4094
|
+
this.layoutService.env.requestAnimationFrame(() => {
|
|
4095
|
+
this.layoutService.env.requestAnimationFrame(() => {
|
|
4096
|
+
if (prevSlide) {
|
|
4097
|
+
prevSlide.onBeforeUnmount().then(_ => {
|
|
4098
|
+
// @ts-ignore
|
|
4099
|
+
// _log("clear innerHTML", true);
|
|
4100
|
+
slideBox.innerHTML = "";
|
|
4101
|
+
resolve();
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
else {
|
|
4105
|
+
resolve();
|
|
4106
|
+
}
|
|
4107
|
+
});
|
|
4108
|
+
});
|
|
4109
|
+
}
|
|
4110
|
+
else {
|
|
4111
|
+
resolve();
|
|
4112
|
+
}
|
|
4113
|
+
slideBoxPrerender.classList.add(SlideApi.renderedBoxClassName);
|
|
4114
|
+
}
|
|
4115
|
+
else {
|
|
4116
|
+
resolve();
|
|
4117
|
+
}
|
|
4118
|
+
this._slideInRender = false;
|
|
4119
|
+
});
|
|
4059
4120
|
}
|
|
4060
4121
|
_slideConfig = {};
|
|
4061
4122
|
async slideStart(config) {
|