@plait/core 0.0.44 → 0.0.45

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.
@@ -757,7 +757,7 @@ function getViewBox(board) {
757
757
  }
758
758
  function getViewportClientBox(board) {
759
759
  const hideScrollbar = board.options.hideScrollbar;
760
- const scrollBarWidth = hideScrollbar ? 0 : SCROLL_BAR_WIDTH;
760
+ const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
761
761
  const container = board.host?.parentElement;
762
762
  const containerRect = container?.getBoundingClientRect();
763
763
  const width = containerRect.width - scrollBarWidth;
@@ -1250,9 +1250,13 @@ class PlaitBoardComponent {
1250
1250
  this.hasInitialized = true;
1251
1251
  }
1252
1252
  ngOnChanges(changes) {
1253
- const valueChange = changes['plaitValue'];
1254
- if (valueChange && this.hasInitialized) {
1255
- this.board.children = valueChange.currentValue;
1253
+ if (this.hasInitialized) {
1254
+ const valueChange = changes['plaitValue'];
1255
+ const options = changes['plaitOptions'];
1256
+ if (valueChange)
1257
+ this.board.children = valueChange.currentValue;
1258
+ if (options)
1259
+ this.board.options = options.currentValue;
1256
1260
  this.cdr.markForCheck();
1257
1261
  }
1258
1262
  }
@@ -1364,7 +1368,7 @@ class PlaitBoardComponent {
1364
1368
  const container = this.elementRef.nativeElement?.parentElement;
1365
1369
  const containerRect = container?.getBoundingClientRect();
1366
1370
  const hideScrollbar = this.board.options.hideScrollbar;
1367
- const scrollBarWidth = hideScrollbar ? 0 : SCROLL_BAR_WIDTH;
1371
+ const scrollBarWidth = hideScrollbar ? SCROLL_BAR_WIDTH : 0;
1368
1372
  const width = `${containerRect.width + scrollBarWidth}px`;
1369
1373
  const height = `${containerRect.height + scrollBarWidth}px`;
1370
1374
  this.renderer2.setStyle(this.contentContainer.nativeElement, 'width', width);
@@ -1398,15 +1402,17 @@ class PlaitBoardComponent {
1398
1402
  const box = [minX, minY, width, height];
1399
1403
  const scrollLeft = (viewportWidth - viewportBox.width) * offsetXRatio;
1400
1404
  const scrollTop = (viewportHeight - viewportBox.height) * offsetYRatio;
1401
- this.resizeViewport();
1402
1405
  this.renderer2.setStyle(this.host, 'display', 'block');
1403
1406
  this.renderer2.setStyle(this.host, 'width', `${viewportWidth}px`);
1404
1407
  this.renderer2.setStyle(this.host, 'height', `${viewportHeight}px`);
1405
1408
  this.renderer2.setStyle(this.host, 'cursor', this.isMoveMode ? 'grab' : 'default');
1406
- this.renderer2.setAttribute(this.host, 'viewBox', box.join());
1409
+ if (width > 0 && height > 0) {
1410
+ this.renderer2.setAttribute(this.host, 'viewBox', box.join());
1411
+ }
1407
1412
  this.setScroll(scrollLeft, scrollTop);
1408
1413
  }
1409
1414
  updateViewport() {
1415
+ this.resizeViewport();
1410
1416
  this.viewportChange();
1411
1417
  }
1412
1418
  // 拖拽模式