scandoc-ai-components 0.0.75 → 0.0.77
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 +31 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11365,6 +11365,11 @@ class ExtractorVideo {
|
|
|
11365
11365
|
await this.video.play().catch(e => {
|
|
11366
11366
|
console.warn(`Error on video play: ${e}`);
|
|
11367
11367
|
});
|
|
11368
|
+
this.video.addEventListener('loadeddata', () => {
|
|
11369
|
+
this.adjustOverlayPosition();
|
|
11370
|
+
});
|
|
11371
|
+
window.addEventListener('resize', () => this.adjustOverlayPosition());
|
|
11372
|
+
setTimeout(() => this.adjustOverlayPosition(), 500);
|
|
11368
11373
|
this.scanStartTime = Date.now(); // Reset timer
|
|
11369
11374
|
setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
|
|
11370
11375
|
this.showMessage("Starting scanning");
|
|
@@ -11397,6 +11402,32 @@ class ExtractorVideo {
|
|
|
11397
11402
|
messageElement.innerText = message;
|
|
11398
11403
|
}
|
|
11399
11404
|
}
|
|
11405
|
+
adjustOverlayPosition() {
|
|
11406
|
+
const video = this.video;
|
|
11407
|
+
const overlay = document.querySelector(".desktopRectangle");
|
|
11408
|
+
if (!video || !overlay || video.videoWidth === 0 || video.videoHeight === 0) return;
|
|
11409
|
+
const videoRatio = video.videoWidth / video.videoHeight;
|
|
11410
|
+
const container = video.parentElement;
|
|
11411
|
+
const containerRatio = container.clientWidth / container.clientHeight;
|
|
11412
|
+
let scaleWidth, scaleHeight;
|
|
11413
|
+
if (videoRatio > containerRatio) {
|
|
11414
|
+
scaleWidth = container.clientWidth;
|
|
11415
|
+
scaleHeight = container.clientWidth / videoRatio;
|
|
11416
|
+
} else {
|
|
11417
|
+
scaleHeight = container.clientHeight;
|
|
11418
|
+
scaleWidth = container.clientHeight * videoRatio;
|
|
11419
|
+
}
|
|
11420
|
+
const offsetX = (container.clientWidth - scaleWidth) / 2;
|
|
11421
|
+
const offsetY = (container.clientHeight - scaleHeight) / 2;
|
|
11422
|
+
const paddingRatio = 0.05;
|
|
11423
|
+
const minPadding = 16;
|
|
11424
|
+
const padX = Math.max(scaleWidth * paddingRatio, minPadding);
|
|
11425
|
+
const padY = Math.max(scaleHeight * paddingRatio, minPadding);
|
|
11426
|
+
overlay.style.left = `${offsetX + padX}px`;
|
|
11427
|
+
overlay.style.top = `${offsetY + padY}px`;
|
|
11428
|
+
overlay.style.width = `${scaleWidth - padX * 2}px`;
|
|
11429
|
+
overlay.style.height = `${scaleHeight - padY * 2}px`;
|
|
11430
|
+
}
|
|
11400
11431
|
getHTML() {
|
|
11401
11432
|
const cfgValues = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getScanDocAIConfigValues)();
|
|
11402
11433
|
const borderColor = cfgValues.VIDEO_COLORS?.borderColor;
|
|
@@ -11440,7 +11471,6 @@ class ExtractorVideo {
|
|
|
11440
11471
|
|
|
11441
11472
|
.desktopRectangle {
|
|
11442
11473
|
position: absolute;
|
|
11443
|
-
top: 5%; left: 5%; right: 5%; bottom: 5%;
|
|
11444
11474
|
border: 5px dashed ${borderColor};
|
|
11445
11475
|
border-radius: 30px;
|
|
11446
11476
|
pointer-events: none;
|