@metadev/daga 1.4.0 → 1.4.1

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/Changelog.md CHANGED
@@ -4,7 +4,14 @@ List of releases and changes.
4
4
 
5
5
  ![Daga logo](https://metadev.pro/icons/daga-logo-header.svg)
6
6
 
7
- ## 1.4.0 Tizona
7
+ ## Next release Colada
8
+
9
+ ## v. 1.4.1
10
+
11
+ - Fix bug with diagram changes not triggering validation [#91](https://github.com/metadevpro/daga/pull/91)
12
+ - Compensate for scroll when getting cursor position relative to screen [#92](https://github.com/metadevpro/daga/pull/92)
13
+
14
+ ## v. 1.4.0 Tizona
8
15
 
9
16
  - Enable configuring which components are present in a diagram [#66](https://github.com/metadevpro/daga/pull/66)
10
17
  - Add `zoom` configurable user action and enable configuring whether zooming and panning is enabled [#66](https://github.com/metadevpro/daga/pull/66)
@@ -4487,6 +4487,13 @@ class DiagramCanvas {
4487
4487
  getPointerLocationRelativeToBody(event) {
4488
4488
  return d3.pointer(this.getEventHoldingCoordinates(event), d3.select('body').node());
4489
4489
  }
4490
+ getPointerLocationRelativeToScreen(event) {
4491
+ const pointerLocationRelativeToBody = this.getPointerLocationRelativeToBody(event);
4492
+ return [
4493
+ pointerLocationRelativeToBody[0] - window.scrollX,
4494
+ pointerLocationRelativeToBody[1] - window.scrollY
4495
+ ];
4496
+ }
4490
4497
  updateModelInView() {
4491
4498
  this.updateNodesInView();
4492
4499
  this.updateSectionsInView();
@@ -6713,7 +6720,7 @@ class ErrorsComponent {
6713
6720
  this.Side = Side;
6714
6721
  }
6715
6722
  ngAfterViewInit() {
6716
- merge([this.canvas.validatorChanges$, this.canvas.diagramChanges$])
6723
+ merge(this.canvas.validatorChanges$, this.canvas.diagramChanges$)
6717
6724
  .pipe(
6718
6725
  // delay to avoid errors of variables changing right after checking
6719
6726
  delay(1), map(() => this.validate()))
@@ -6877,7 +6884,7 @@ class PaletteComponent {
6877
6884
  .drag()
6878
6885
  .on(DragEvents.Drag, (event) => {
6879
6886
  if (this.canvas.canUserPerformAction(DiagramActions.AddNode)) {
6880
- const pointerCoords = this.canvas.getPointerLocationRelativeToBody(event);
6887
+ const pointerCoords = this.canvas.getPointerLocationRelativeToScreen(event);
6881
6888
  if (pointerCoords.length < 2 ||
6882
6889
  isNaN(pointerCoords[0]) ||
6883
6890
  isNaN(pointerCoords[1])) {
@@ -6893,7 +6900,7 @@ class PaletteComponent {
6893
6900
  .on(DragEvents.Start, (event) => {
6894
6901
  if (this.canvas.canUserPerformAction(DiagramActions.AddNode)) {
6895
6902
  d3.select('body').style('cursor', 'grabbing');
6896
- const pointerCoords = this.canvas.getPointerLocationRelativeToBody(event);
6903
+ const pointerCoords = this.canvas.getPointerLocationRelativeToScreen(event);
6897
6904
  if (pointerCoords.length < 2 ||
6898
6905
  isNaN(pointerCoords[0]) ||
6899
6906
  isNaN(pointerCoords[1])) {
@@ -6926,14 +6933,14 @@ class PaletteComponent {
6926
6933
  // can't place, it's unique and that node is already in the model
6927
6934
  return;
6928
6935
  }
6929
- const pointerCoordsRelativeToBody = this.canvas.getPointerLocationRelativeToBody(event);
6930
- if (pointerCoordsRelativeToBody.length < 2 ||
6931
- isNaN(pointerCoordsRelativeToBody[0]) ||
6932
- isNaN(pointerCoordsRelativeToBody[1])) {
6936
+ const pointerCoordsRelativeToScreen = this.canvas.getPointerLocationRelativeToScreen(event);
6937
+ if (pointerCoordsRelativeToScreen.length < 2 ||
6938
+ isNaN(pointerCoordsRelativeToScreen[0]) ||
6939
+ isNaN(pointerCoordsRelativeToScreen[1])) {
6933
6940
  // can't place, position is incorrect
6934
6941
  return;
6935
6942
  }
6936
- const element = document.elementFromPoint(pointerCoordsRelativeToBody[0], pointerCoordsRelativeToBody[1]);
6943
+ const element = document.elementFromPoint(pointerCoordsRelativeToScreen[0], pointerCoordsRelativeToScreen[1]);
6937
6944
  if (element &&
6938
6945
  !this.canvas.selectCanvasView().node()?.contains(element)) {
6939
6946
  // can't place, node hasn't been dropped on the canvas