@stemy/ngx-utils 19.4.9 → 19.4.11
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/fesm2022/stemy-ngx-utils.mjs +75 -52
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/components/interactive-canvas/interactive-canvas.component.d.ts +9 -6
- package/ngx-utils/components/interactive-canvas/interactive-item.component.d.ts +4 -6
- package/ngx-utils/ngx-utils.imports.d.ts +2 -2
- package/package.json +1 -1
|
@@ -6904,7 +6904,7 @@ class InteractiveItemComponent {
|
|
|
6904
6904
|
this.pos = new Point(this.pos.x, value);
|
|
6905
6905
|
}
|
|
6906
6906
|
set position(value) {
|
|
6907
|
-
if (typeof value !== "object" || isNaN(value.x) || isNaN(value.y))
|
|
6907
|
+
if (typeof value !== "object" || isNaN(value.x) || isNaN(value.y) || value === this.pos)
|
|
6908
6908
|
return;
|
|
6909
6909
|
this.pos = new Point(value.x, value.y);
|
|
6910
6910
|
}
|
|
@@ -6933,34 +6933,27 @@ class InteractiveItemComponent {
|
|
|
6933
6933
|
this.onPanEnd = new EventEmitter();
|
|
6934
6934
|
this.active = false;
|
|
6935
6935
|
this.index = -1;
|
|
6936
|
-
this.
|
|
6936
|
+
this.cycles = [0];
|
|
6937
6937
|
this.pos = Point.Zero;
|
|
6938
6938
|
this.rotation = 0;
|
|
6939
6939
|
this.direction = "none";
|
|
6940
6940
|
this.mShapes = [];
|
|
6941
|
-
this.subscription = ObservableUtils.multiSubscription(this.
|
|
6942
|
-
this.deltaX = 0;
|
|
6943
|
-
this.deltaY = 0;
|
|
6944
|
-
}), this.onPan.subscribe(ev => {
|
|
6945
|
-
const dx = ev.deltaX - this.deltaX;
|
|
6946
|
-
const dy = ev.deltaY - this.deltaY;
|
|
6941
|
+
this.subscription = ObservableUtils.multiSubscription(this.onPan.subscribe(ev => {
|
|
6947
6942
|
switch (this.direction) {
|
|
6948
6943
|
case "free":
|
|
6949
|
-
this.x +=
|
|
6950
|
-
this.y +=
|
|
6944
|
+
this.x += ev.deltaX;
|
|
6945
|
+
this.y += ev.deltaY;
|
|
6951
6946
|
break;
|
|
6952
6947
|
case "horizontal":
|
|
6953
|
-
this.x +=
|
|
6948
|
+
this.x += ev.deltaX;
|
|
6954
6949
|
break;
|
|
6955
6950
|
case "vertical":
|
|
6956
|
-
this.y +=
|
|
6951
|
+
this.y += ev.deltaY;
|
|
6957
6952
|
break;
|
|
6958
6953
|
}
|
|
6959
6954
|
if (this.direction !== "none") {
|
|
6960
6955
|
this.calcShapes();
|
|
6961
6956
|
}
|
|
6962
|
-
this.deltaX = ev.deltaX;
|
|
6963
|
-
this.deltaY = ev.deltaY;
|
|
6964
6957
|
}));
|
|
6965
6958
|
}
|
|
6966
6959
|
ngOnDestroy() {
|
|
@@ -6969,13 +6962,13 @@ class InteractiveItemComponent {
|
|
|
6969
6962
|
ngOnChanges() {
|
|
6970
6963
|
this.calcShapes();
|
|
6971
6964
|
}
|
|
6972
|
-
calcShapes(
|
|
6965
|
+
calcShapes(cycles) {
|
|
6973
6966
|
const canvas = this.canvas;
|
|
6974
6967
|
const ratio = canvas.ratio;
|
|
6975
6968
|
const x = this.pos.x * ratio;
|
|
6976
|
-
this.
|
|
6977
|
-
this.mShapes =
|
|
6978
|
-
const y = this.pos.y * ratio +
|
|
6969
|
+
this.cycles = cycles ?? this.cycles;
|
|
6970
|
+
this.mShapes = this.cycles.map(pan => {
|
|
6971
|
+
const y = this.pos.y * ratio + pan;
|
|
6979
6972
|
return this.calcShape(x, y);
|
|
6980
6973
|
});
|
|
6981
6974
|
}
|
|
@@ -7031,6 +7024,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
|
|
|
7031
7024
|
}] } });
|
|
7032
7025
|
|
|
7033
7026
|
class InteractiveCanvasComponent {
|
|
7027
|
+
get selectedItem() {
|
|
7028
|
+
return this.items[this.selectedIndex];
|
|
7029
|
+
}
|
|
7030
|
+
get hoveredItem() {
|
|
7031
|
+
return this.items[this.hoveredIndex];
|
|
7032
|
+
}
|
|
7033
|
+
get lockedItem() {
|
|
7034
|
+
return this.items[this.lockedIndex];
|
|
7035
|
+
}
|
|
7034
7036
|
constructor(renderer) {
|
|
7035
7037
|
this.renderer = renderer;
|
|
7036
7038
|
this.horizontal = false;
|
|
@@ -7044,11 +7046,11 @@ class InteractiveCanvasComponent {
|
|
|
7044
7046
|
this.rotation = 0;
|
|
7045
7047
|
this.canvasWidth = 0;
|
|
7046
7048
|
this.canvasHeight = 0;
|
|
7047
|
-
this.
|
|
7048
|
-
this.selectedItem = null;
|
|
7049
|
+
this.hoveredIndex = null;
|
|
7049
7050
|
this.items = [];
|
|
7050
7051
|
this.touched = false;
|
|
7051
|
-
this.
|
|
7052
|
+
this.deltaX = 0;
|
|
7053
|
+
this.deltaY = 0;
|
|
7052
7054
|
}
|
|
7053
7055
|
ngOnInit() {
|
|
7054
7056
|
this.redraw();
|
|
@@ -7087,7 +7089,7 @@ class InteractiveCanvasComponent {
|
|
|
7087
7089
|
this.fixPan();
|
|
7088
7090
|
}
|
|
7089
7091
|
onTouchStart($event) {
|
|
7090
|
-
this.
|
|
7092
|
+
this.hoveredIndex = this.getIndexUnderPointer($event.touches.item(0));
|
|
7091
7093
|
this.touched = true;
|
|
7092
7094
|
}
|
|
7093
7095
|
onTouchEnd($event) {
|
|
@@ -7102,35 +7104,51 @@ class InteractiveCanvasComponent {
|
|
|
7102
7104
|
onMouseMove($event) {
|
|
7103
7105
|
if (this.touched)
|
|
7104
7106
|
return;
|
|
7105
|
-
this.
|
|
7107
|
+
this.hoveredIndex = this.getIndexUnderPointer($event);
|
|
7106
7108
|
this.updateCursor();
|
|
7107
7109
|
}
|
|
7108
7110
|
onMouseLeave() {
|
|
7109
|
-
this.
|
|
7111
|
+
this.hoveredIndex = null;
|
|
7110
7112
|
this.updateCursor();
|
|
7111
7113
|
}
|
|
7112
7114
|
onPanStart($event) {
|
|
7113
|
-
this.
|
|
7114
|
-
this.lockedItem?.onPanStart.emit(
|
|
7115
|
-
|
|
7115
|
+
this.lockedIndex = this.getIndexUnderPointer($event?.pointers[0]);
|
|
7116
|
+
this.lockedItem?.onPanStart.emit({
|
|
7117
|
+
pointers: [],
|
|
7118
|
+
deltaX: 0,
|
|
7119
|
+
deltaY: 0,
|
|
7120
|
+
item: this.lockedItem
|
|
7121
|
+
});
|
|
7122
|
+
this.deltaX = 0;
|
|
7123
|
+
this.deltaY = 0;
|
|
7116
7124
|
}
|
|
7117
7125
|
onPan($event) {
|
|
7118
|
-
|
|
7126
|
+
const item = this.lockedItem;
|
|
7127
|
+
const deltaX = ($event.deltaX - this.deltaX) / this.ratio;
|
|
7128
|
+
const deltaY = ($event.deltaY - this.deltaY) / this.ratio;
|
|
7129
|
+
if (item) {
|
|
7119
7130
|
const data = this.horizontal
|
|
7120
|
-
? { pointers: $event.pointers, deltaX:
|
|
7121
|
-
: { pointers: $event.pointers, deltaX
|
|
7122
|
-
data.item =
|
|
7123
|
-
|
|
7124
|
-
return;
|
|
7131
|
+
? { pointers: $event.pointers, deltaX: -deltaY, deltaY: +deltaX }
|
|
7132
|
+
: { pointers: $event.pointers, deltaX, deltaY };
|
|
7133
|
+
data.item = item;
|
|
7134
|
+
item.onPan.emit(data);
|
|
7125
7135
|
}
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7136
|
+
else if (this.resizeMode == "fill") {
|
|
7137
|
+
this.pan += this.horizontal ? deltaX : deltaY;
|
|
7138
|
+
this.fixPan();
|
|
7139
|
+
}
|
|
7140
|
+
this.deltaX = $event.deltaX;
|
|
7141
|
+
this.deltaY = $event.deltaY;
|
|
7129
7142
|
}
|
|
7130
7143
|
onPanEnd() {
|
|
7131
|
-
this.lockedItem
|
|
7132
|
-
|
|
7133
|
-
|
|
7144
|
+
const item = this.lockedItem;
|
|
7145
|
+
item?.onPanEnd.emit({
|
|
7146
|
+
pointers: [],
|
|
7147
|
+
deltaX: 0,
|
|
7148
|
+
deltaY: 0,
|
|
7149
|
+
item
|
|
7150
|
+
});
|
|
7151
|
+
this.lockedIndex = -1;
|
|
7134
7152
|
}
|
|
7135
7153
|
fixPan() {
|
|
7136
7154
|
if (this.fullHeight <= 0)
|
|
@@ -7143,8 +7161,9 @@ class InteractiveCanvasComponent {
|
|
|
7143
7161
|
}
|
|
7144
7162
|
this.rotation = Math.round(this.pan / this.fullHeight * 360);
|
|
7145
7163
|
const basePan = (this.rotation / 360 - 1) * this.fullHeight;
|
|
7164
|
+
const cycles = this.resizeMode == "fit" ? [0] : [basePan - this.fullHeight, basePan, basePan + this.fullHeight];
|
|
7146
7165
|
this.items.forEach(item => {
|
|
7147
|
-
item.calcShapes(
|
|
7166
|
+
item.calcShapes(cycles);
|
|
7148
7167
|
});
|
|
7149
7168
|
}
|
|
7150
7169
|
fixItems() {
|
|
@@ -7155,29 +7174,32 @@ class InteractiveCanvasComponent {
|
|
|
7155
7174
|
this.fixPan();
|
|
7156
7175
|
}
|
|
7157
7176
|
selectItem(pointer) {
|
|
7158
|
-
const selected = this.
|
|
7177
|
+
const selected = this.getIndexUnderPointer(pointer);
|
|
7159
7178
|
this.touched = false;
|
|
7160
|
-
this.
|
|
7161
|
-
|
|
7162
|
-
selected.active = !selected.active;
|
|
7163
|
-
const items = Array.from(this.items);
|
|
7164
|
-
this.selectedIndex = items.indexOf(selected);
|
|
7179
|
+
if (selected !== this.selectedIndex) {
|
|
7180
|
+
this.selectedIndex = selected;
|
|
7165
7181
|
this.selectedIndexChange.emit(this.selectedIndex);
|
|
7182
|
+
const item = this.selectedItem;
|
|
7183
|
+
if (!item)
|
|
7184
|
+
return;
|
|
7185
|
+
item.active = !item.active;
|
|
7166
7186
|
}
|
|
7167
7187
|
}
|
|
7168
|
-
|
|
7188
|
+
getIndexUnderPointer(pointer) {
|
|
7169
7189
|
if (!pointer || !this.canvasElem || !this.items)
|
|
7170
7190
|
return null;
|
|
7171
7191
|
const canvasRect = this.canvasElem.nativeElement.getBoundingClientRect();
|
|
7172
7192
|
const point = this.horizontal
|
|
7173
7193
|
? new Point(canvasRect.bottom - pointer.clientY, pointer.clientX - canvasRect.left)
|
|
7174
7194
|
: new Point(pointer.clientX - canvasRect.left, pointer.clientY - canvasRect.top);
|
|
7175
|
-
|
|
7195
|
+
const length = this.items.length;
|
|
7196
|
+
for (let ix = 0; ix < length; ix++) {
|
|
7197
|
+
const item = this.items[ix];
|
|
7176
7198
|
if (item?.hit(point)) {
|
|
7177
|
-
return item.disabled ? null :
|
|
7199
|
+
return item.disabled ? null : ix;
|
|
7178
7200
|
}
|
|
7179
7201
|
}
|
|
7180
|
-
return
|
|
7202
|
+
return -1;
|
|
7181
7203
|
}
|
|
7182
7204
|
updateCursor() {
|
|
7183
7205
|
const cursor = this.getCursor();
|
|
@@ -7185,9 +7207,10 @@ class InteractiveCanvasComponent {
|
|
|
7185
7207
|
this.renderer.setStyle(this.containerElem.nativeElement, "cursor", cursor);
|
|
7186
7208
|
}
|
|
7187
7209
|
getCursor() {
|
|
7188
|
-
|
|
7210
|
+
const hovered = this.hoveredItem;
|
|
7211
|
+
if (!hovered)
|
|
7189
7212
|
return "default";
|
|
7190
|
-
switch (
|
|
7213
|
+
switch (hovered.direction) {
|
|
7191
7214
|
case "free":
|
|
7192
7215
|
return "all-scroll";
|
|
7193
7216
|
case "horizontal":
|