microboard-temp 0.5.150 → 0.5.152

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.
@@ -20853,10 +20853,13 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
20857
- this.Mbr = item.getMbrWithChildren().copy();
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
20858
  } else {
20859
- this.Mbr.combine([item.getMbrWithChildren()]);
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20860
20863
  }
20861
20864
  this.subject.publish(this.items);
20862
20865
  };
@@ -20870,8 +20873,14 @@ class SpatialIndex {
20870
20873
  }
20871
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20872
20875
  this.itemsIndex.remove(item);
20873
- this.Mbr = new Mbr;
20874
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20875
20884
  this.subject.publish(this.items);
20876
20885
  }
20877
20886
  copy() {
@@ -21180,6 +21189,22 @@ class Items {
21180
21189
  getMbr() {
21181
21190
  return this.index.getMbr();
21182
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21183
21208
  getInView() {
21184
21209
  const { left, top, right, bottom } = this.view.getMbr();
21185
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -57085,7 +57110,7 @@ function onBoardLoad(board) {
57085
57110
  const hasItemsInBoard = board.items.listAll().length !== 0;
57086
57111
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57087
57112
  if (isItemsOutOfView && hasItemsInBoard) {
57088
- board.camera.zoomToFit(board.items.getMbr());
57113
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57089
57114
  }
57090
57115
  if (!hasItemsInBoard) {
57091
57116
  board.camera.zoomToViewCenter(1);
package/dist/cjs/index.js CHANGED
@@ -20853,10 +20853,13 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
20857
- this.Mbr = item.getMbrWithChildren().copy();
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
20858
  } else {
20859
- this.Mbr.combine([item.getMbrWithChildren()]);
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20860
20863
  }
20861
20864
  this.subject.publish(this.items);
20862
20865
  };
@@ -20870,8 +20873,14 @@ class SpatialIndex {
20870
20873
  }
20871
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20872
20875
  this.itemsIndex.remove(item);
20873
- this.Mbr = new Mbr;
20874
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20875
20884
  this.subject.publish(this.items);
20876
20885
  }
20877
20886
  copy() {
@@ -21180,6 +21189,22 @@ class Items {
21180
21189
  getMbr() {
21181
21190
  return this.index.getMbr();
21182
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21183
21208
  getInView() {
21184
21209
  const { left, top, right, bottom } = this.view.getMbr();
21185
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -57085,7 +57110,7 @@ function onBoardLoad(board) {
57085
57110
  const hasItemsInBoard = board.items.listAll().length !== 0;
57086
57111
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57087
57112
  if (isItemsOutOfView && hasItemsInBoard) {
57088
- board.camera.zoomToFit(board.items.getMbr());
57113
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57089
57114
  }
57090
57115
  if (!hasItemsInBoard) {
57091
57116
  board.camera.zoomToViewCenter(1);
package/dist/cjs/node.js CHANGED
@@ -23325,10 +23325,13 @@ class SpatialIndex {
23325
23325
  }
23326
23326
  change = (item) => {
23327
23327
  this.itemsIndex.change(item);
23328
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
23329
- this.Mbr = item.getMbrWithChildren().copy();
23328
+ if (this.itemsArray.length === 0) {
23329
+ this.Mbr = new Mbr;
23330
23330
  } else {
23331
- this.Mbr.combine([item.getMbrWithChildren()]);
23331
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23332
+ for (let i = 1;i < this.itemsArray.length; i++) {
23333
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23334
+ }
23332
23335
  }
23333
23336
  this.subject.publish(this.items);
23334
23337
  };
@@ -23342,8 +23345,14 @@ class SpatialIndex {
23342
23345
  }
23343
23346
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23344
23347
  this.itemsIndex.remove(item);
23345
- this.Mbr = new Mbr;
23346
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23348
+ if (this.itemsArray.length === 0) {
23349
+ this.Mbr = new Mbr;
23350
+ } else {
23351
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23352
+ for (let i = 1;i < this.itemsArray.length; i++) {
23353
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23354
+ }
23355
+ }
23347
23356
  this.subject.publish(this.items);
23348
23357
  }
23349
23358
  copy() {
@@ -23652,6 +23661,22 @@ class Items {
23652
23661
  getMbr() {
23653
23662
  return this.index.getMbr();
23654
23663
  }
23664
+ getFilteredMbr() {
23665
+ const MAX_ITEM_SIZE = 1e6;
23666
+ const items = this.listAll();
23667
+ let mbr = null;
23668
+ for (const item of items) {
23669
+ const itemMbr = item.getMbr();
23670
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23671
+ if (mbr === null) {
23672
+ mbr = itemMbr.copy();
23673
+ } else {
23674
+ mbr.combine([itemMbr]);
23675
+ }
23676
+ }
23677
+ }
23678
+ return mbr ?? this.getMbr();
23679
+ }
23655
23680
  getInView() {
23656
23681
  const { left, top, right, bottom } = this.view.getMbr();
23657
23682
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -59558,7 +59583,7 @@ function onBoardLoad(board) {
59558
59583
  const hasItemsInBoard = board.items.listAll().length !== 0;
59559
59584
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59560
59585
  if (isItemsOutOfView && hasItemsInBoard) {
59561
- board.camera.zoomToFit(board.items.getMbr());
59586
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59562
59587
  }
59563
59588
  if (!hasItemsInBoard) {
59564
59589
  board.camera.zoomToViewCenter(1);
@@ -20696,10 +20696,13 @@ class SpatialIndex {
20696
20696
  }
20697
20697
  change = (item) => {
20698
20698
  this.itemsIndex.change(item);
20699
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
20700
- this.Mbr = item.getMbrWithChildren().copy();
20699
+ if (this.itemsArray.length === 0) {
20700
+ this.Mbr = new Mbr;
20701
20701
  } else {
20702
- this.Mbr.combine([item.getMbrWithChildren()]);
20702
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20703
+ for (let i = 1;i < this.itemsArray.length; i++) {
20704
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20705
+ }
20703
20706
  }
20704
20707
  this.subject.publish(this.items);
20705
20708
  };
@@ -20713,8 +20716,14 @@ class SpatialIndex {
20713
20716
  }
20714
20717
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20715
20718
  this.itemsIndex.remove(item);
20716
- this.Mbr = new Mbr;
20717
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20719
+ if (this.itemsArray.length === 0) {
20720
+ this.Mbr = new Mbr;
20721
+ } else {
20722
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20723
+ for (let i = 1;i < this.itemsArray.length; i++) {
20724
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20725
+ }
20726
+ }
20718
20727
  this.subject.publish(this.items);
20719
20728
  }
20720
20729
  copy() {
@@ -21023,6 +21032,22 @@ class Items {
21023
21032
  getMbr() {
21024
21033
  return this.index.getMbr();
21025
21034
  }
21035
+ getFilteredMbr() {
21036
+ const MAX_ITEM_SIZE = 1e6;
21037
+ const items = this.listAll();
21038
+ let mbr = null;
21039
+ for (const item of items) {
21040
+ const itemMbr = item.getMbr();
21041
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21042
+ if (mbr === null) {
21043
+ mbr = itemMbr.copy();
21044
+ } else {
21045
+ mbr.combine([itemMbr]);
21046
+ }
21047
+ }
21048
+ }
21049
+ return mbr ?? this.getMbr();
21050
+ }
21026
21051
  getInView() {
21027
21052
  const { left, top, right, bottom } = this.view.getMbr();
21028
21053
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -56928,7 +56953,7 @@ function onBoardLoad(board) {
56928
56953
  const hasItemsInBoard = board.items.listAll().length !== 0;
56929
56954
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56930
56955
  if (isItemsOutOfView && hasItemsInBoard) {
56931
- board.camera.zoomToFit(board.items.getMbr());
56956
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56932
56957
  }
56933
56958
  if (!hasItemsInBoard) {
56934
56959
  board.camera.zoomToViewCenter(1);
package/dist/esm/index.js CHANGED
@@ -20689,10 +20689,13 @@ class SpatialIndex {
20689
20689
  }
20690
20690
  change = (item) => {
20691
20691
  this.itemsIndex.change(item);
20692
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
20693
- this.Mbr = item.getMbrWithChildren().copy();
20692
+ if (this.itemsArray.length === 0) {
20693
+ this.Mbr = new Mbr;
20694
20694
  } else {
20695
- this.Mbr.combine([item.getMbrWithChildren()]);
20695
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20696
+ for (let i = 1;i < this.itemsArray.length; i++) {
20697
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20698
+ }
20696
20699
  }
20697
20700
  this.subject.publish(this.items);
20698
20701
  };
@@ -20706,8 +20709,14 @@ class SpatialIndex {
20706
20709
  }
20707
20710
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20708
20711
  this.itemsIndex.remove(item);
20709
- this.Mbr = new Mbr;
20710
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20712
+ if (this.itemsArray.length === 0) {
20713
+ this.Mbr = new Mbr;
20714
+ } else {
20715
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20716
+ for (let i = 1;i < this.itemsArray.length; i++) {
20717
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20718
+ }
20719
+ }
20711
20720
  this.subject.publish(this.items);
20712
20721
  }
20713
20722
  copy() {
@@ -21016,6 +21025,22 @@ class Items {
21016
21025
  getMbr() {
21017
21026
  return this.index.getMbr();
21018
21027
  }
21028
+ getFilteredMbr() {
21029
+ const MAX_ITEM_SIZE = 1e6;
21030
+ const items = this.listAll();
21031
+ let mbr = null;
21032
+ for (const item of items) {
21033
+ const itemMbr = item.getMbr();
21034
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21035
+ if (mbr === null) {
21036
+ mbr = itemMbr.copy();
21037
+ } else {
21038
+ mbr.combine([itemMbr]);
21039
+ }
21040
+ }
21041
+ }
21042
+ return mbr ?? this.getMbr();
21043
+ }
21019
21044
  getInView() {
21020
21045
  const { left, top, right, bottom } = this.view.getMbr();
21021
21046
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -56921,7 +56946,7 @@ function onBoardLoad(board) {
56921
56946
  const hasItemsInBoard = board.items.listAll().length !== 0;
56922
56947
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56923
56948
  if (isItemsOutOfView && hasItemsInBoard) {
56924
- board.camera.zoomToFit(board.items.getMbr());
56949
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56925
56950
  }
56926
56951
  if (!hasItemsInBoard) {
56927
56952
  board.camera.zoomToViewCenter(1);
package/dist/esm/node.js CHANGED
@@ -23156,10 +23156,13 @@ class SpatialIndex {
23156
23156
  }
23157
23157
  change = (item) => {
23158
23158
  this.itemsIndex.change(item);
23159
- if (this.Mbr.getWidth() === 0 && this.Mbr.getHeight() === 0) {
23160
- this.Mbr = item.getMbrWithChildren().copy();
23159
+ if (this.itemsArray.length === 0) {
23160
+ this.Mbr = new Mbr;
23161
23161
  } else {
23162
- this.Mbr.combine([item.getMbrWithChildren()]);
23162
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23163
+ for (let i = 1;i < this.itemsArray.length; i++) {
23164
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23165
+ }
23163
23166
  }
23164
23167
  this.subject.publish(this.items);
23165
23168
  };
@@ -23173,8 +23176,14 @@ class SpatialIndex {
23173
23176
  }
23174
23177
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23175
23178
  this.itemsIndex.remove(item);
23176
- this.Mbr = new Mbr;
23177
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23179
+ if (this.itemsArray.length === 0) {
23180
+ this.Mbr = new Mbr;
23181
+ } else {
23182
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23183
+ for (let i = 1;i < this.itemsArray.length; i++) {
23184
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23185
+ }
23186
+ }
23178
23187
  this.subject.publish(this.items);
23179
23188
  }
23180
23189
  copy() {
@@ -23483,6 +23492,22 @@ class Items {
23483
23492
  getMbr() {
23484
23493
  return this.index.getMbr();
23485
23494
  }
23495
+ getFilteredMbr() {
23496
+ const MAX_ITEM_SIZE = 1e6;
23497
+ const items = this.listAll();
23498
+ let mbr = null;
23499
+ for (const item of items) {
23500
+ const itemMbr = item.getMbr();
23501
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23502
+ if (mbr === null) {
23503
+ mbr = itemMbr.copy();
23504
+ } else {
23505
+ mbr.combine([itemMbr]);
23506
+ }
23507
+ }
23508
+ }
23509
+ return mbr ?? this.getMbr();
23510
+ }
23486
23511
  getInView() {
23487
23512
  const { left, top, right, bottom } = this.view.getMbr();
23488
23513
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -59389,7 +59414,7 @@ function onBoardLoad(board) {
59389
59414
  const hasItemsInBoard = board.items.listAll().length !== 0;
59390
59415
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59391
59416
  if (isItemsOutOfView && hasItemsInBoard) {
59392
- board.camera.zoomToFit(board.items.getMbr());
59417
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59393
59418
  }
59394
59419
  if (!hasItemsInBoard) {
59395
59420
  board.camera.zoomToViewCenter(1);
@@ -62,6 +62,7 @@ export declare class Items {
62
62
  getGroupItemsEnclosedOrCrossed(left: number, top: number, right: number, bottom: number): BaseItem[];
63
63
  getUnderPoint(point: Point, tolerance?: number): Item[];
64
64
  getMbr(): Mbr;
65
+ getFilteredMbr(): Mbr;
65
66
  getInView(): Item[];
66
67
  getItemsInView(): Item[];
67
68
  getGroupItemsInView(): BaseItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.150",
3
+ "version": "0.5.152",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",