@twab/visualization 1.5.2 → 1.5.3
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/visualization.js +50 -19
- package/package.json +1 -1
package/dist/visualization.js
CHANGED
|
@@ -1205,6 +1205,7 @@ FramesManager.prototype.getSmallBlock = async function (
|
|
|
1205
1205
|
|
|
1206
1206
|
response = response.data;
|
|
1207
1207
|
const images = response.frames;
|
|
1208
|
+
images[0].blockStart = true;
|
|
1208
1209
|
this.requests[`block_${ENUM.Direction.Next}_${response.end}`] = true;
|
|
1209
1210
|
|
|
1210
1211
|
this.getBlock(time, this.channel, 1, ENUM.Direction.Self, true, true);
|
|
@@ -1286,6 +1287,7 @@ FramesManager.prototype.getBlock = async function (
|
|
|
1286
1287
|
// response.data.frames = this.fillEmptyBlock(time, direction)
|
|
1287
1288
|
}
|
|
1288
1289
|
|
|
1290
|
+
response.data.frames[0].blockStart = true;
|
|
1289
1291
|
this.orderFramesBlock(response.data.frames);
|
|
1290
1292
|
this.currentPosition = this.findFrameIndexByTime(this.currentTime);
|
|
1291
1293
|
|
|
@@ -1354,12 +1356,11 @@ FramesManager.prototype.orderFramesBlock = function (images) {
|
|
|
1354
1356
|
image.time += this.shiftFrames;
|
|
1355
1357
|
}
|
|
1356
1358
|
if (this.buffer.length > 0) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
this.buffer = [...beforeImages, ...this.buffer, ...afterImages];
|
|
1359
|
+
this.buffer = [...this.buffer, ...images]
|
|
1360
|
+
.filter(
|
|
1361
|
+
(f, i, array) => array.findIndex((ff) => ff.time === f.time) === i
|
|
1362
|
+
)
|
|
1363
|
+
.sort((fa, fb) => fa.time - fb.time);
|
|
1363
1364
|
} else {
|
|
1364
1365
|
this.buffer = images;
|
|
1365
1366
|
}
|
|
@@ -1430,11 +1431,29 @@ FramesManager.prototype.getBufferSlice = function (start, end) {
|
|
|
1430
1431
|
|
|
1431
1432
|
FramesManager.prototype.next = function () {
|
|
1432
1433
|
const newPosition = this.currentPosition + this.currentStep * this.size;
|
|
1433
|
-
this.currentPosition =
|
|
1434
|
-
newPosition < this.buffer.length ? newPosition : this.currentPosition;
|
|
1435
|
-
this.currentTime = this.buffer[this.currentPosition]?.time || this.currentTime;
|
|
1436
1434
|
|
|
1437
|
-
this.
|
|
1435
|
+
const blockStartTime = this.buffer
|
|
1436
|
+
.slice(0, this.currentPosition)
|
|
1437
|
+
.reverse()
|
|
1438
|
+
.find((f) => f.blockStart)?.time;
|
|
1439
|
+
|
|
1440
|
+
if (
|
|
1441
|
+
(this.buffer[this.currentPosition]?.time + this.currentStep * this.size ===
|
|
1442
|
+
this.buffer[newPosition]?.time &&
|
|
1443
|
+
this.buffer[newPosition + this.size]?.time -
|
|
1444
|
+
this.buffer[newPosition]?.time ===
|
|
1445
|
+
this.currentStep * this.size) ||
|
|
1446
|
+
!this.requests[`block__${blockStartTime}`]
|
|
1447
|
+
) {
|
|
1448
|
+
this.currentPosition =
|
|
1449
|
+
newPosition < this.buffer.length ? newPosition : this.currentPosition;
|
|
1450
|
+
this.currentTime =
|
|
1451
|
+
this.buffer[this.currentPosition]?.time || this.currentTime;
|
|
1452
|
+
|
|
1453
|
+
this.checkMinBlockSize(true);
|
|
1454
|
+
return true
|
|
1455
|
+
}
|
|
1456
|
+
return false
|
|
1438
1457
|
};
|
|
1439
1458
|
|
|
1440
1459
|
FramesManager.prototype.previous = function () {
|
|
@@ -1513,6 +1532,7 @@ function FramesInterface(
|
|
|
1513
1532
|
this.startAudienceTime = startAudienceTime;
|
|
1514
1533
|
this.useCache = useCache;
|
|
1515
1534
|
this.shiftFrames = shiftFrames;
|
|
1535
|
+
this.forceCurrent = false;
|
|
1516
1536
|
}
|
|
1517
1537
|
|
|
1518
1538
|
FramesInterface.prototype.init = async function () {
|
|
@@ -1557,16 +1577,27 @@ FramesInterface.prototype.loadFrames = async function () {
|
|
|
1557
1577
|
|
|
1558
1578
|
FramesInterface.prototype.loadNextFrames = async function () {
|
|
1559
1579
|
return new Promise((resolve) => {
|
|
1560
|
-
this.framesManager.next()
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1580
|
+
if (this.framesManager.next()) {
|
|
1581
|
+
Promise.all([
|
|
1582
|
+
this.constructImagesComponent(this.framesManager.getNextImages() || []),
|
|
1583
|
+
...(this.forceCurrent
|
|
1584
|
+
? [
|
|
1585
|
+
this.constructImagesComponent(
|
|
1586
|
+
this.framesManager.getCurrentImages() || []
|
|
1587
|
+
),
|
|
1588
|
+
]
|
|
1589
|
+
: []),
|
|
1590
|
+
]).then((frames) => {
|
|
1591
|
+
this.frames.prev = this.frames.current;
|
|
1592
|
+
this.frames.current = frames[1] || this.frames.next;
|
|
1593
|
+
this.frames.next = frames[0];
|
|
1594
|
+
this.forceCurrent = false;
|
|
1595
|
+
resolve();
|
|
1596
|
+
});
|
|
1597
|
+
} else {
|
|
1598
|
+
this.forceCurrent = true;
|
|
1568
1599
|
resolve();
|
|
1569
|
-
}
|
|
1600
|
+
}
|
|
1570
1601
|
})
|
|
1571
1602
|
};
|
|
1572
1603
|
|