scandoc-ai-components 0.0.63 → 0.0.65
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.js +33 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11191,6 +11191,7 @@ class ExtractorVideo {
|
|
|
11191
11191
|
this.scanStartTime = null;
|
|
11192
11192
|
this.unsupportedDocCount = 0;
|
|
11193
11193
|
this.video = null;
|
|
11194
|
+
this.updateOverlayTimeout = null;
|
|
11194
11195
|
}
|
|
11195
11196
|
reset() {
|
|
11196
11197
|
this.stopVideo();
|
|
@@ -11245,6 +11246,25 @@ class ExtractorVideo {
|
|
|
11245
11246
|
bottomPct: bottom / canvas.height
|
|
11246
11247
|
};
|
|
11247
11248
|
}
|
|
11249
|
+
updateRectangleOverlay = async () => {
|
|
11250
|
+
const margins = await this.getCameraMargins();
|
|
11251
|
+
const video = document.getElementById('ScanDocAIVideoElement');
|
|
11252
|
+
const rectangle = document.querySelector('.desktopRectangle');
|
|
11253
|
+
if (!video || !rectangle) return;
|
|
11254
|
+
const rect = video.getBoundingClientRect(); // Only visible portion
|
|
11255
|
+
const width = rect.width;
|
|
11256
|
+
const height = rect.height;
|
|
11257
|
+
const leftPx = margins.leftPct * width;
|
|
11258
|
+
const rightPx = margins.rightPct * width;
|
|
11259
|
+
const topPx = margins.topPct * height;
|
|
11260
|
+
const bottomPx = margins.bottomPct * height;
|
|
11261
|
+
|
|
11262
|
+
// Position rectangle in actual pixels (not %)
|
|
11263
|
+
rectangle.style.left = `${rect.left + leftPx}px`;
|
|
11264
|
+
rectangle.style.top = `${rect.top + topPx}px`;
|
|
11265
|
+
rectangle.style.width = `${width - leftPx - rightPx}px`;
|
|
11266
|
+
rectangle.style.height = `${height - topPx - bottomPx}px`;
|
|
11267
|
+
};
|
|
11248
11268
|
async analyzeVideoStream() {
|
|
11249
11269
|
if (!this.isRunning) {
|
|
11250
11270
|
return;
|
|
@@ -11405,21 +11425,16 @@ class ExtractorVideo {
|
|
|
11405
11425
|
await this.video.play().catch(e => {
|
|
11406
11426
|
console.warn(`Error on video play: ${e}`);
|
|
11407
11427
|
});
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
rectangle.style.right = `${clamp(margins.rightPct + buffer)}%`;
|
|
11419
|
-
}
|
|
11420
|
-
}), 500);
|
|
11421
|
-
}
|
|
11422
|
-
});
|
|
11428
|
+
this.video.onloadedmetadata = () => {
|
|
11429
|
+
this.updateRectangleOverlay();
|
|
11430
|
+
};
|
|
11431
|
+
setTimeout(() => this.updateRectangleOverlay(), 500);
|
|
11432
|
+
const scheduleOverlayUpdate = (delay = 500) => {
|
|
11433
|
+
clearTimeout(this.updateOverlayTimeout);
|
|
11434
|
+
this.updateOverlayTimeout = setTimeout(() => this.updateRectangleOverlay(), delay);
|
|
11435
|
+
};
|
|
11436
|
+
window.addEventListener("resize", () => scheduleOverlayUpdate());
|
|
11437
|
+
window.addEventListener("orientationchange", () => scheduleOverlayUpdate(700));
|
|
11423
11438
|
this.scanStartTime = Date.now(); // Reset timer
|
|
11424
11439
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11425
11440
|
this.showMessage("Starting scanning");
|
|
@@ -11491,14 +11506,12 @@ class ExtractorVideo {
|
|
|
11491
11506
|
}
|
|
11492
11507
|
|
|
11493
11508
|
.desktopRectangle {
|
|
11494
|
-
position: absolute
|
|
11509
|
+
position: fixed; /* not absolute anymore */
|
|
11495
11510
|
border-radius: 30px;
|
|
11496
|
-
display: flex;
|
|
11497
|
-
justify-content: center;
|
|
11498
|
-
align-items: center;
|
|
11499
|
-
z-index: 3;
|
|
11500
11511
|
border: 5px dashed #5078bb;
|
|
11501
11512
|
transition: all 0.3s ease;
|
|
11513
|
+
pointer-events: none;
|
|
11514
|
+
z-index: 1000;
|
|
11502
11515
|
}
|
|
11503
11516
|
|
|
11504
11517
|
.backgroundOverlay {
|