scandoc-ai-components 0.0.75 → 0.0.76

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11365,6 +11365,10 @@ 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());
11368
11372
  this.scanStartTime = Date.now(); // Reset timer
11369
11373
  setTimeout(() => this.analyzeVideoStream(), ExtractorVideo.FREQUENCY_MS);
11370
11374
  this.showMessage("Starting scanning");
@@ -11397,6 +11401,28 @@ class ExtractorVideo {
11397
11401
  messageElement.innerText = message;
11398
11402
  }
11399
11403
  }
11404
+ adjustOverlayPosition() {
11405
+ const video = this.video;
11406
+ const overlay = document.querySelector(".desktopRectangle");
11407
+ if (!video || !overlay || video.videoWidth === 0 || video.videoHeight === 0) return;
11408
+ const videoRatio = video.videoWidth / video.videoHeight;
11409
+ const container = video.parentElement;
11410
+ const containerRatio = container.clientWidth / container.clientHeight;
11411
+ let scaleWidth, scaleHeight;
11412
+ if (videoRatio > containerRatio) {
11413
+ scaleWidth = container.clientWidth;
11414
+ scaleHeight = container.clientWidth / videoRatio;
11415
+ } else {
11416
+ scaleHeight = container.clientHeight;
11417
+ scaleWidth = container.clientHeight * videoRatio;
11418
+ }
11419
+ const offsetX = (container.clientWidth - scaleWidth) / 2;
11420
+ const offsetY = (container.clientHeight - scaleHeight) / 2;
11421
+ overlay.style.left = `${offsetX + scaleWidth * 0.05}px`;
11422
+ overlay.style.top = `${offsetY + scaleHeight * 0.05}px`;
11423
+ overlay.style.width = `${scaleWidth * 0.90}px`;
11424
+ overlay.style.height = `${scaleHeight * 0.90}px`;
11425
+ }
11400
11426
  getHTML() {
11401
11427
  const cfgValues = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getScanDocAIConfigValues)();
11402
11428
  const borderColor = cfgValues.VIDEO_COLORS?.borderColor;
@@ -11440,7 +11466,6 @@ class ExtractorVideo {
11440
11466
 
11441
11467
  .desktopRectangle {
11442
11468
  position: absolute;
11443
- top: 5%; left: 5%; right: 5%; bottom: 5%;
11444
11469
  border: 5px dashed ${borderColor};
11445
11470
  border-radius: 30px;
11446
11471
  pointer-events: none;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "scandoc-ai-components",
3
3
  "author": "ScanDoc-AI",
4
- "version": "0.0.75",
4
+ "version": "0.0.76",
5
5
  "private": false,
6
6
  "description": "Pure JavaScript package for integrating ScanDoc-AI services.",
7
7
  "keywords": [