scandit-capacitor-datacapture-barcode 8.2.0-beta.1 → 8.2.0

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.
@@ -9,6 +9,7 @@ export declare class BarcodeFindView {
9
9
  constructor(props: BarcodeFindViewProps);
10
10
  private set htmlElementState(value);
11
11
  private get htmlElementState();
12
+ private updatePositionAndSize;
12
13
  private orientationChangeListener;
13
14
  get barcodeFindViewUiListener(): BarcodeFindViewUiListener | null;
14
15
  set barcodeFindViewUiListener(value: BarcodeFindViewUiListener | null);
package/dist/index.js CHANGED
@@ -527,13 +527,21 @@ class BarcodeCountView {
527
527
  this.baseBarcodeCountView.setToolbarSettings(settings);
528
528
  }
529
529
  connectToElement(element) {
530
- this.baseBarcodeCountView.createNativeView(this.viewId).then(() => {
531
- this.htmlElement = element;
530
+ // Pre-compute position/size before creating native view
531
+ this.htmlElement = element;
532
+ const boundingRect = element.getBoundingClientRect();
533
+ const initialTop = boundingRect.top;
534
+ const initialLeft = boundingRect.left;
535
+ const initialWidth = boundingRect.width;
536
+ const initialHeight = boundingRect.height;
537
+ this.baseBarcodeCountView.createNativeView(this.viewId).then(() => __awaiter(this, void 0, void 0, function* () {
538
+ // Immediately send position/size to native before any other processing
539
+ yield this.baseBarcodeCountView.setPositionAndSize(initialTop, initialLeft, initialWidth, initialHeight, false);
532
540
  this.htmlElementState = new HTMLElementState();
533
- // Initial update
541
+ // Initial update to sync state
534
542
  this.elementDidChange();
535
543
  this.subscribeToChangesOnHTMLElement();
536
- });
544
+ }));
537
545
  }
538
546
  detachFromElement() {
539
547
  this.baseBarcodeCountView.removeNativeView().then(() => {
@@ -647,7 +655,11 @@ class BarcodeFindView {
647
655
  }
648
656
  set htmlElementState(newState) {
649
657
  const didChangeShown = this._htmlElementState.isShown !== newState.isShown;
658
+ const didChangePositionOrSize = this._htmlElementState.didChangeComparedTo(newState);
650
659
  this._htmlElementState = newState;
660
+ if (didChangePositionOrSize) {
661
+ this.updatePositionAndSize();
662
+ }
651
663
  if (didChangeShown) {
652
664
  if (this._htmlElementState.isShown) {
653
665
  this._show();
@@ -660,6 +672,12 @@ class BarcodeFindView {
660
672
  get htmlElementState() {
661
673
  return this._htmlElementState;
662
674
  }
675
+ updatePositionAndSize() {
676
+ if (!this.htmlElementState || !this.htmlElementState.isValid) {
677
+ return;
678
+ }
679
+ this.baseBarcodeFindView.setPositionAndSize(this.htmlElementState.position.top, this.htmlElementState.position.left, this.htmlElementState.size.width, this.htmlElementState.size.height, this.htmlElementState.shouldBeUnderContent);
680
+ }
663
681
  get barcodeFindViewUiListener() {
664
682
  return this.baseBarcodeFindView.barcodeFindViewUiListener;
665
683
  }
@@ -781,14 +799,22 @@ class BarcodeFindView {
781
799
  return this.baseBarcodeFindView.pauseSearching();
782
800
  }
783
801
  connectToElement(element) {
802
+ // Pre-compute position/size before creating native view
803
+ this.htmlElement = element;
804
+ const boundingRect = element.getBoundingClientRect();
805
+ const initialTop = boundingRect.top;
806
+ const initialLeft = boundingRect.left;
807
+ const initialWidth = boundingRect.width;
808
+ const initialHeight = boundingRect.height;
784
809
  const viewId = (Date.now() / 1000) | 0;
785
- this.baseBarcodeFindView.createNativeView(viewId).then(() => {
786
- this.htmlElement = element;
810
+ this.baseBarcodeFindView.createNativeView(viewId).then(() => __awaiter(this, void 0, void 0, function* () {
811
+ // Immediately send position/size to native before any other processing
812
+ yield this.baseBarcodeFindView.setPositionAndSize(initialTop, initialLeft, initialWidth, initialHeight, false);
787
813
  this.htmlElementState = new HTMLElementState();
788
- // Initial update
814
+ // Initial update to sync state
789
815
  this.elementDidChange();
790
816
  this.subscribeToChangesOnHTMLElement();
791
- });
817
+ }));
792
818
  }
793
819
  detachFromElement() {
794
820
  this.baseBarcodeFindView.removeNativeView().then(() => {
@@ -1085,13 +1111,21 @@ class BarcodePickView extends DefaultSerializeable {
1085
1111
  return this._htmlElementState;
1086
1112
  }
1087
1113
  connectToElement(element) {
1088
- this.baseBarcodePickView.createNativeView(this.viewId).then(() => {
1089
- this.htmlElement = element;
1114
+ // Pre-compute position/size before creating native view
1115
+ this.htmlElement = element;
1116
+ const boundingRect = element.getBoundingClientRect();
1117
+ const initialTop = boundingRect.top;
1118
+ const initialLeft = boundingRect.left;
1119
+ const initialWidth = boundingRect.width;
1120
+ const initialHeight = boundingRect.height;
1121
+ this.baseBarcodePickView.createNativeView(this.viewId).then(() => __awaiter(this, void 0, void 0, function* () {
1122
+ // Immediately send position/size to native before any other processing
1123
+ yield this.baseBarcodePickView.setPickViewPositionAndSize(initialTop, initialLeft, initialWidth, initialHeight, false);
1090
1124
  this.htmlElementState = new HTMLElementState();
1091
- // Initial update
1125
+ // Initial update to sync state
1092
1126
  this.elementDidChange();
1093
1127
  this.subscribeToChangesOnHTMLElement();
1094
- });
1128
+ }));
1095
1129
  }
1096
1130
  detachFromElement() {
1097
1131
  this.baseBarcodePickView.removeNativeView().then(() => {
@@ -1254,10 +1288,18 @@ class BarcodeArView extends DefaultSerializeable {
1254
1288
  }
1255
1289
  connectToElement(element) {
1256
1290
  return __awaiter(this, void 0, void 0, function* () {
1257
- yield this.baseBarcodeArView.createNativeView(this.viewId);
1291
+ // Pre-compute position/size before creating native view
1258
1292
  this.htmlElement = element;
1293
+ const boundingRect = element.getBoundingClientRect();
1294
+ const initialTop = boundingRect.top;
1295
+ const initialLeft = boundingRect.left;
1296
+ const initialWidth = boundingRect.width;
1297
+ const initialHeight = boundingRect.height;
1298
+ yield this.baseBarcodeArView.createNativeView(this.viewId);
1299
+ // Immediately send position/size to native before any other processing
1300
+ yield this.baseBarcodeArView.setPositionAndSize(initialTop, initialLeft, initialWidth, initialHeight, false);
1259
1301
  this.htmlElementState = new HTMLElementState();
1260
- // Initial update
1302
+ // Initial update to sync state
1261
1303
  this.elementDidChange();
1262
1304
  this.subscribeToChangesOnHTMLElement();
1263
1305
  });