@stemy/ngx-utils 19.7.7 → 19.7.8
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 +170 -157
- package/fesm2022/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +12 -8
- package/ngx-utils/components/interactive-canvas/interactive-canvas.component.d.ts +47 -32
- package/ngx-utils/components/interactive-canvas/interactive-item.component.d.ts +5 -3
- package/ngx-utils/ngx-utils.imports.d.ts +2 -3
- package/ngx-utils/tokens.d.ts +1 -1
- package/ngx-utils/utils/misc.d.ts +4 -2
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'zone.js';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, PLATFORM_ID, Inject, Injectable, Optional, Injector, untracked, computed, signal,
|
|
4
|
+
import { InjectionToken, PLATFORM_ID, Inject, Injectable, Optional, Injector, inject, untracked, computed, signal, DestroyRef, isDevMode, ErrorHandler, EventEmitter, createComponent, NgZone, Pipe, input, output, ChangeDetectorRef, ElementRef, effect, HostListener, Directive, Input, HostBinding, Output, TemplateRef, ChangeDetectionStrategy, ViewEncapsulation, Component, ViewChild, forwardRef, ContentChild, ContentChildren, Renderer2, model, contentChildren, provideAppInitializer, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
5
5
|
import * as i2 from '@angular/router';
|
|
6
6
|
import { ActivatedRouteSnapshot, Scroll, NavigationEnd, Router, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer, ROUTES } from '@angular/router';
|
|
7
7
|
import { BehaviorSubject, Observable, firstValueFrom, Subject, Subscription, from, delay, timer, TimeoutError, combineLatest, of, lastValueFrom } from 'rxjs';
|
|
@@ -2503,14 +2503,17 @@ function provideEntryComponents(components, moduleId) {
|
|
|
2503
2503
|
multi: true
|
|
2504
2504
|
};
|
|
2505
2505
|
}
|
|
2506
|
+
function provideOptions(options) {
|
|
2507
|
+
return {
|
|
2508
|
+
provide: OPTIONS_TOKEN,
|
|
2509
|
+
useValue: options
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2506
2512
|
function provideWithOptions(type, options) {
|
|
2507
2513
|
return {
|
|
2508
2514
|
useFactory: function (parent) {
|
|
2509
2515
|
const providers = [
|
|
2510
|
-
|
|
2511
|
-
provide: OPTIONS_TOKEN,
|
|
2512
|
-
useValue: options
|
|
2513
|
-
},
|
|
2516
|
+
provideOptions(options),
|
|
2514
2517
|
{
|
|
2515
2518
|
provide: type,
|
|
2516
2519
|
useClass: type
|
|
@@ -2524,6 +2527,10 @@ function provideWithOptions(type, options) {
|
|
|
2524
2527
|
deps: [Injector]
|
|
2525
2528
|
};
|
|
2526
2529
|
}
|
|
2530
|
+
function injectOptions(defaults) {
|
|
2531
|
+
const options = inject(OPTIONS_TOKEN, { optional: true });
|
|
2532
|
+
return Object.assign({}, defaults, options || {});
|
|
2533
|
+
}
|
|
2527
2534
|
|
|
2528
2535
|
class TimerUtils {
|
|
2529
2536
|
static createTimeout(func, time) {
|
|
@@ -7765,14 +7772,6 @@ class InteractiveItemComponent {
|
|
|
7765
7772
|
get shapes() {
|
|
7766
7773
|
return this.mShapes;
|
|
7767
7774
|
}
|
|
7768
|
-
get hovered() {
|
|
7769
|
-
return this.canvas?.hoveredItem === this;
|
|
7770
|
-
}
|
|
7771
|
-
set hovered(value) {
|
|
7772
|
-
if (!this.canvas)
|
|
7773
|
-
return;
|
|
7774
|
-
this.canvas.hoveredItem = value ? this : null;
|
|
7775
|
-
}
|
|
7776
7775
|
get x() {
|
|
7777
7776
|
return this.pos.x;
|
|
7778
7777
|
}
|
|
@@ -7812,6 +7811,22 @@ class InteractiveItemComponent {
|
|
|
7812
7811
|
this.validPos = new Point(value.x, value.y);
|
|
7813
7812
|
this.valid = true;
|
|
7814
7813
|
}
|
|
7814
|
+
get hovered() {
|
|
7815
|
+
return this.canvas?.hoveredItem === this;
|
|
7816
|
+
}
|
|
7817
|
+
set hovered(value) {
|
|
7818
|
+
if (!this.canvas)
|
|
7819
|
+
return;
|
|
7820
|
+
this.canvas.hoveredItem = value ? this : null;
|
|
7821
|
+
}
|
|
7822
|
+
get selected() {
|
|
7823
|
+
return this.canvas?.selectedItem === this;
|
|
7824
|
+
}
|
|
7825
|
+
set selected(value) {
|
|
7826
|
+
if (!this.canvas)
|
|
7827
|
+
return;
|
|
7828
|
+
this.canvas.selectedItem = value ? this : null;
|
|
7829
|
+
}
|
|
7815
7830
|
constructor() {
|
|
7816
7831
|
this.active = false;
|
|
7817
7832
|
this.index = -1;
|
|
@@ -7873,7 +7888,7 @@ class InteractiveItemComponent {
|
|
|
7873
7888
|
restrictPosition(x, y) {
|
|
7874
7889
|
return {
|
|
7875
7890
|
x: clamp(x, this.canvas.xRange),
|
|
7876
|
-
y: this.canvas.
|
|
7891
|
+
y: this.canvas.isInfinite
|
|
7877
7892
|
? overflow(y, this.canvas.yRange)
|
|
7878
7893
|
: clamp(y, this.canvas.yRange)
|
|
7879
7894
|
};
|
|
@@ -7924,9 +7939,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
7924
7939
|
type: Input
|
|
7925
7940
|
}] } });
|
|
7926
7941
|
|
|
7942
|
+
const emptyDash = [];
|
|
7927
7943
|
class InteractiveCanvasComponent {
|
|
7944
|
+
get isInfinite() {
|
|
7945
|
+
return this.infinite();
|
|
7946
|
+
}
|
|
7947
|
+
get realWidth() {
|
|
7948
|
+
return this.width();
|
|
7949
|
+
}
|
|
7950
|
+
get realHeight() {
|
|
7951
|
+
return this.height();
|
|
7952
|
+
}
|
|
7928
7953
|
get items() {
|
|
7929
|
-
return this
|
|
7954
|
+
return this.itemList();
|
|
7930
7955
|
}
|
|
7931
7956
|
get canvas() {
|
|
7932
7957
|
return this.canvasElem?.nativeElement;
|
|
@@ -7935,7 +7960,14 @@ class InteractiveCanvasComponent {
|
|
|
7935
7960
|
return this.items[this.lockedIndex];
|
|
7936
7961
|
}
|
|
7937
7962
|
get selectedItem() {
|
|
7938
|
-
return this.items[this.selectedIndex];
|
|
7963
|
+
return this.items[this.selectedIndex()];
|
|
7964
|
+
}
|
|
7965
|
+
set selectedItem(item) {
|
|
7966
|
+
const ix = !item ? -1 : this.items.indexOf(item);
|
|
7967
|
+
const selected = untracked(() => this.selectedIndex());
|
|
7968
|
+
if (ix === selected)
|
|
7969
|
+
return;
|
|
7970
|
+
this.selectedIndex.set(ix);
|
|
7939
7971
|
}
|
|
7940
7972
|
get hoveredItem() {
|
|
7941
7973
|
return this.items[this.hoveredIndex];
|
|
@@ -7943,31 +7975,59 @@ class InteractiveCanvasComponent {
|
|
|
7943
7975
|
set hoveredItem(item) {
|
|
7944
7976
|
this.hoveredIndex = !item ? -1 : this.items.indexOf(item);
|
|
7945
7977
|
}
|
|
7946
|
-
constructor(
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
this.
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
this.
|
|
7957
|
-
this.
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
this.
|
|
7962
|
-
this.
|
|
7963
|
-
this.
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
this
|
|
7978
|
+
constructor() {
|
|
7979
|
+
/**
|
|
7980
|
+
* Injectable options
|
|
7981
|
+
* @private
|
|
7982
|
+
*/
|
|
7983
|
+
this.options = injectOptions({
|
|
7984
|
+
infinite: false,
|
|
7985
|
+
resizeMode: "fit",
|
|
7986
|
+
panOffset: 0
|
|
7987
|
+
});
|
|
7988
|
+
this.renderer = inject(Renderer2);
|
|
7989
|
+
this.universal = inject(UniversalService);
|
|
7990
|
+
/**
|
|
7991
|
+
* Is the canvas infinitely scrollable?
|
|
7992
|
+
*/
|
|
7993
|
+
this.infinite = input(this.options.infinite);
|
|
7994
|
+
this.resizeMode = input(this.options.resizeMode);
|
|
7995
|
+
this.horizontal = input(false);
|
|
7996
|
+
/**
|
|
7997
|
+
* Real life-size width of the canvas
|
|
7998
|
+
*/
|
|
7999
|
+
this.width = input(100);
|
|
8000
|
+
/**
|
|
8001
|
+
* Real life-size height of the canvas
|
|
8002
|
+
*/
|
|
8003
|
+
this.height = input(100);
|
|
8004
|
+
/**
|
|
8005
|
+
* Canvas params
|
|
8006
|
+
*/
|
|
8007
|
+
this.params = input({}, {
|
|
8008
|
+
transform: (v) => v || {}
|
|
8009
|
+
});
|
|
8010
|
+
/**
|
|
8011
|
+
* Model signal for selected index
|
|
8012
|
+
*/
|
|
8013
|
+
this.selectedIndex = model(0);
|
|
8014
|
+
/**
|
|
8015
|
+
* Relative offset of the panning. It is based on the rendered canvas height
|
|
8016
|
+
*/
|
|
8017
|
+
this.panOffset = input(this.options.panOffset);
|
|
8018
|
+
this.renderCtx = input({});
|
|
8019
|
+
this.beforeItems = input([]);
|
|
8020
|
+
this.afterItems = input([]);
|
|
8021
|
+
this.onRotate = output();
|
|
8022
|
+
this.onItemPan = output();
|
|
8023
|
+
this.onItemPanned = output();
|
|
8024
|
+
this.onPan = output();
|
|
8025
|
+
this.onPanned = output();
|
|
8026
|
+
this.itemList = contentChildren(InteractiveItemComponent);
|
|
7968
8027
|
this.tempCanvas = this.universal.isServer ? null : document.createElement("canvas");
|
|
7969
8028
|
this.shouldDraw = !this.universal.isServer;
|
|
7970
8029
|
this.hoveredIndex = null;
|
|
8030
|
+
this.oldLength = 0;
|
|
7971
8031
|
this.xRange = [0, 1];
|
|
7972
8032
|
this.yRange = [0, 1];
|
|
7973
8033
|
this.ratio = 1;
|
|
@@ -7982,26 +8042,34 @@ class InteractiveCanvasComponent {
|
|
|
7982
8042
|
this.touched = false;
|
|
7983
8043
|
this.panStartRotation = 0;
|
|
7984
8044
|
this.panStartPos = Point.Zero;
|
|
8045
|
+
effect(() => {
|
|
8046
|
+
const items = this.itemList();
|
|
8047
|
+
const index = untracked(() => this.selectedIndex());
|
|
8048
|
+
const grow = items.length > this.oldLength;
|
|
8049
|
+
items.forEach((item, ix) => {
|
|
8050
|
+
item.canvas = this;
|
|
8051
|
+
item.index = ix;
|
|
8052
|
+
});
|
|
8053
|
+
this.fixRotation();
|
|
8054
|
+
const last = Math.max(0, items.length - 1);
|
|
8055
|
+
const selected = Math.min(grow ? last : index, last);
|
|
8056
|
+
this.selectedItem = items[selected];
|
|
8057
|
+
this.oldLength = items.length;
|
|
8058
|
+
});
|
|
8059
|
+
effect(() => {
|
|
8060
|
+
const realWidth = this.width();
|
|
8061
|
+
const realHeight = this.height();
|
|
8062
|
+
const params = this.params();
|
|
8063
|
+
this.xRange = normalizeRange(params.xRange || [0, realWidth]);
|
|
8064
|
+
this.yRange = normalizeRange(params.yRange || [0, realHeight]);
|
|
8065
|
+
this.resize();
|
|
8066
|
+
});
|
|
7985
8067
|
}
|
|
7986
8068
|
ngOnInit() {
|
|
7987
8069
|
this.redraw();
|
|
7988
8070
|
}
|
|
7989
8071
|
ngOnDestroy() {
|
|
7990
8072
|
this.shouldDraw = false;
|
|
7991
|
-
this.subscription?.unsubscribe();
|
|
7992
|
-
}
|
|
7993
|
-
ngOnChanges() {
|
|
7994
|
-
this.params = this.params || {};
|
|
7995
|
-
this.renderCtx = this.renderCtx || {};
|
|
7996
|
-
this.beforeItems = this.beforeItems || [];
|
|
7997
|
-
this.afterItems = this.afterItems || [];
|
|
7998
|
-
this.xRange = normalizeRange(this.params.xRange || [0, this.realWidth]);
|
|
7999
|
-
this.yRange = normalizeRange(this.params.yRange || [0, this.realHeight]);
|
|
8000
|
-
this.resize();
|
|
8001
|
-
}
|
|
8002
|
-
ngAfterViewInit() {
|
|
8003
|
-
this.subscription = this.itemList.changes.subscribe(() => this.fixItems());
|
|
8004
|
-
this.fixItems();
|
|
8005
8073
|
}
|
|
8006
8074
|
async tempPaint(cb) {
|
|
8007
8075
|
const renderCanvas = this.canvas;
|
|
@@ -8017,20 +8085,24 @@ class InteractiveCanvasComponent {
|
|
|
8017
8085
|
bgCtx.globalCompositeOperation = "source-over";
|
|
8018
8086
|
}
|
|
8019
8087
|
resize() {
|
|
8020
|
-
|
|
8088
|
+
const realWidth = this.width();
|
|
8089
|
+
const realHeight = this.height();
|
|
8090
|
+
const horizontal = this.horizontal();
|
|
8091
|
+
const resizeMode = this.resizeMode();
|
|
8092
|
+
if (!this.canvasElem || !this.containerElem)
|
|
8021
8093
|
return;
|
|
8022
8094
|
const canvas = this.canvasElem.nativeElement;
|
|
8023
8095
|
const container = this.containerElem.nativeElement;
|
|
8024
8096
|
// Calculate canvas size
|
|
8025
|
-
const axisX =
|
|
8026
|
-
const axisY =
|
|
8027
|
-
const resize =
|
|
8097
|
+
const axisX = horizontal ? "height" : "width";
|
|
8098
|
+
const axisY = horizontal ? "width" : "height";
|
|
8099
|
+
const resize = resizeMode == "fit" ? Math.min : Math.max;
|
|
8028
8100
|
canvas.width = container.clientWidth;
|
|
8029
8101
|
canvas.height = container.clientHeight;
|
|
8030
|
-
this.ratio = resize(canvas[axisX] /
|
|
8031
|
-
if (
|
|
8032
|
-
canvas[axisX] =
|
|
8033
|
-
canvas[axisY] =
|
|
8102
|
+
this.ratio = resize(canvas[axisX] / realWidth, canvas[axisY] / realHeight);
|
|
8103
|
+
if (resizeMode == "fit") {
|
|
8104
|
+
canvas[axisX] = realWidth * this.ratio;
|
|
8105
|
+
canvas[axisY] = realHeight * this.ratio;
|
|
8034
8106
|
}
|
|
8035
8107
|
this.styles = getComputedStyle(canvas);
|
|
8036
8108
|
this.ctx = canvas.getContext("2d");
|
|
@@ -8073,6 +8145,7 @@ class InteractiveCanvasComponent {
|
|
|
8073
8145
|
}
|
|
8074
8146
|
onPanMove($event) {
|
|
8075
8147
|
const item = this.lockedItem;
|
|
8148
|
+
const horizontal = this.horizontal();
|
|
8076
8149
|
const deltaX = $event.deltaX / this.ratio;
|
|
8077
8150
|
const deltaY = $event.deltaY / this.ratio;
|
|
8078
8151
|
const data = {
|
|
@@ -8081,19 +8154,21 @@ class InteractiveCanvasComponent {
|
|
|
8081
8154
|
deltaX,
|
|
8082
8155
|
deltaY
|
|
8083
8156
|
};
|
|
8084
|
-
if (
|
|
8157
|
+
if (horizontal) {
|
|
8085
8158
|
data.deltaX = -deltaY;
|
|
8086
8159
|
data.deltaY = +deltaX;
|
|
8087
8160
|
}
|
|
8088
8161
|
if (item) {
|
|
8089
8162
|
item.moveTo(this.panStartPos.x + data.deltaX, this.panStartPos.y + data.deltaY);
|
|
8090
8163
|
this.onItemPan.emit(data);
|
|
8164
|
+
return;
|
|
8091
8165
|
}
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8166
|
+
const infinite = untracked(() => this.infinite());
|
|
8167
|
+
if (!infinite)
|
|
8168
|
+
return;
|
|
8169
|
+
this.rotation = this.panStartRotation + (horizontal ? deltaX : deltaY) / this.realHeight * 360;
|
|
8170
|
+
this.fixRotation();
|
|
8171
|
+
this.onPan.emit(data);
|
|
8097
8172
|
}
|
|
8098
8173
|
onPanEnd() {
|
|
8099
8174
|
const item = this.lockedItem;
|
|
@@ -8113,14 +8188,17 @@ class InteractiveCanvasComponent {
|
|
|
8113
8188
|
this.lockedIndex = -1;
|
|
8114
8189
|
}
|
|
8115
8190
|
fixRotation() {
|
|
8191
|
+
// No need to track params changes because this function will be called from an effect
|
|
8192
|
+
// already depending on params anyway
|
|
8193
|
+
const params = untracked(() => this.params());
|
|
8116
8194
|
if (this.fullHeight <= 0)
|
|
8117
8195
|
return;
|
|
8118
8196
|
this.rotation = overflow(Math.round(this.rotation * 100) / 100, -180, 180);
|
|
8119
8197
|
this.basePan = this.rotation / 360 * this.fullHeight
|
|
8120
|
-
+ this.canvasHeight * this.panOffset;
|
|
8198
|
+
+ this.canvasHeight * untracked(() => this.panOffset());
|
|
8121
8199
|
this.cycles = this.infinite
|
|
8122
8200
|
? [this.basePan - this.fullHeight, this.basePan, this.basePan + this.fullHeight] : [0];
|
|
8123
|
-
this.excludedAreas = (
|
|
8201
|
+
this.excludedAreas = (params.excludedAreas || []).flatMap(coords => {
|
|
8124
8202
|
const x = coords.x * this.ratio;
|
|
8125
8203
|
const y = coords.y * this.ratio;
|
|
8126
8204
|
const width = coords.width * this.ratio;
|
|
@@ -8134,25 +8212,12 @@ class InteractiveCanvasComponent {
|
|
|
8134
8212
|
});
|
|
8135
8213
|
this.onRotate.emit(this.rotation);
|
|
8136
8214
|
}
|
|
8137
|
-
fixItems() {
|
|
8138
|
-
const items = this.itemList.toArray();
|
|
8139
|
-
this.$items.next(items);
|
|
8140
|
-
items.forEach((item, ix) => {
|
|
8141
|
-
item.canvas = this;
|
|
8142
|
-
item.index = ix;
|
|
8143
|
-
});
|
|
8144
|
-
this.fixRotation();
|
|
8145
|
-
}
|
|
8146
8215
|
selectItem(pointer) {
|
|
8147
8216
|
const selected = this.getIndexUnderPointer(pointer);
|
|
8217
|
+
const item = this.items[selected];
|
|
8148
8218
|
this.touched = false;
|
|
8149
|
-
if (
|
|
8150
|
-
this.
|
|
8151
|
-
this.selectedIndexChange.emit(this.selectedIndex);
|
|
8152
|
-
const item = this.selectedItem;
|
|
8153
|
-
if (!item)
|
|
8154
|
-
return;
|
|
8155
|
-
item.active = !item.active;
|
|
8219
|
+
if (item) {
|
|
8220
|
+
this.selectedItem = item;
|
|
8156
8221
|
}
|
|
8157
8222
|
this.hoveredIndex = selected;
|
|
8158
8223
|
}
|
|
@@ -8160,7 +8225,7 @@ class InteractiveCanvasComponent {
|
|
|
8160
8225
|
if (!pointer || !this.canvas)
|
|
8161
8226
|
return null;
|
|
8162
8227
|
const canvasRect = this.canvas?.getBoundingClientRect();
|
|
8163
|
-
return this.horizontal
|
|
8228
|
+
return this.horizontal()
|
|
8164
8229
|
? new Point(canvasRect.bottom - pointer.clientY, pointer.clientX - canvasRect.left)
|
|
8165
8230
|
: new Point(pointer.clientX - canvasRect.left, pointer.clientY - canvasRect.top);
|
|
8166
8231
|
}
|
|
@@ -8214,35 +8279,15 @@ class InteractiveCanvasComponent {
|
|
|
8214
8279
|
await this.drawItem(ctx, item);
|
|
8215
8280
|
}
|
|
8216
8281
|
}
|
|
8217
|
-
if (lockedItem)
|
|
8218
|
-
await this.drawItem(ctx, lockedItem);
|
|
8219
|
-
}
|
|
8220
|
-
if (!this.debug)
|
|
8282
|
+
if (!lockedItem)
|
|
8221
8283
|
return;
|
|
8222
|
-
ctx
|
|
8223
|
-
ctx.strokeStyle = "rgba(114,232,45,0.55)";
|
|
8224
|
-
for (const item of this.items) {
|
|
8225
|
-
for (const shape of item.shapes) {
|
|
8226
|
-
ctx.save();
|
|
8227
|
-
ctx.translate(shape.x, shape.y);
|
|
8228
|
-
if (shape instanceof Rect || shape instanceof Oval) {
|
|
8229
|
-
ctx.rotate(toRadians(shape.rotation));
|
|
8230
|
-
if (shape instanceof Oval) {
|
|
8231
|
-
drawOval(ctx, shape.width, shape.height);
|
|
8232
|
-
}
|
|
8233
|
-
else {
|
|
8234
|
-
drawRect(ctx, shape.width, shape.height);
|
|
8235
|
-
}
|
|
8236
|
-
ctx.stroke();
|
|
8237
|
-
}
|
|
8238
|
-
ctx.restore();
|
|
8239
|
-
}
|
|
8240
|
-
}
|
|
8284
|
+
await this.drawItem(ctx, lockedItem);
|
|
8241
8285
|
}
|
|
8242
8286
|
async drawItem(ctx, item) {
|
|
8243
8287
|
for (const shape of item.shapes) {
|
|
8244
8288
|
ctx.save();
|
|
8245
8289
|
ctx.translate(shape.x, shape.y);
|
|
8290
|
+
ctx.setLineDash(emptyDash);
|
|
8246
8291
|
ctx.lineWidth = 1;
|
|
8247
8292
|
ctx.strokeStyle = "black";
|
|
8248
8293
|
ctx.fillStyle = "white";
|
|
@@ -8255,19 +8300,26 @@ class InteractiveCanvasComponent {
|
|
|
8255
8300
|
const canvas = ctx.canvas;
|
|
8256
8301
|
if (canvas.width < 1 || canvas.height < 1)
|
|
8257
8302
|
return;
|
|
8303
|
+
ctx.lineWidth = 1;
|
|
8304
|
+
ctx.strokeStyle = "black";
|
|
8305
|
+
ctx.fillStyle = "white";
|
|
8306
|
+
ctx.setLineDash(emptyDash);
|
|
8258
8307
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
8259
8308
|
ctx.save();
|
|
8260
|
-
if (this.horizontal) {
|
|
8309
|
+
if (this.horizontal()) {
|
|
8261
8310
|
ctx.rotate(-Math.PI / 2);
|
|
8262
8311
|
ctx.translate(-this.canvasWidth, 0);
|
|
8263
8312
|
}
|
|
8313
|
+
const renderCtx = untracked(() => this.renderCtx());
|
|
8314
|
+
const beforeItems = untracked(() => this.beforeItems());
|
|
8315
|
+
const afterItems = untracked(() => this.afterItems());
|
|
8264
8316
|
try {
|
|
8265
|
-
for (const renderer of
|
|
8266
|
-
await renderer(this,
|
|
8317
|
+
for (const renderer of beforeItems) {
|
|
8318
|
+
await renderer(this, renderCtx);
|
|
8267
8319
|
}
|
|
8268
8320
|
await this.drawItems();
|
|
8269
|
-
for (const renderer of
|
|
8270
|
-
await renderer(this,
|
|
8321
|
+
for (const renderer of afterItems) {
|
|
8322
|
+
await renderer(this, renderCtx);
|
|
8271
8323
|
}
|
|
8272
8324
|
}
|
|
8273
8325
|
catch (e) {
|
|
@@ -8275,57 +8327,18 @@ class InteractiveCanvasComponent {
|
|
|
8275
8327
|
}
|
|
8276
8328
|
ctx.restore();
|
|
8277
8329
|
}
|
|
8278
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: InteractiveCanvasComponent, deps: [
|
|
8279
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
8330
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: InteractiveCanvasComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
8331
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.14", type: InteractiveCanvasComponent, isStandalone: false, selector: "interactive-canvas", inputs: { infinite: { classPropertyName: "infinite", publicName: "infinite", isSignal: true, isRequired: false, transformFunction: null }, resizeMode: { classPropertyName: "resizeMode", publicName: "resizeMode", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: false, transformFunction: null }, selectedIndex: { classPropertyName: "selectedIndex", publicName: "selectedIndex", isSignal: true, isRequired: false, transformFunction: null }, panOffset: { classPropertyName: "panOffset", publicName: "panOffset", isSignal: true, isRequired: false, transformFunction: null }, renderCtx: { classPropertyName: "renderCtx", publicName: "renderCtx", isSignal: true, isRequired: false, transformFunction: null }, beforeItems: { classPropertyName: "beforeItems", publicName: "beforeItems", isSignal: true, isRequired: false, transformFunction: null }, afterItems: { classPropertyName: "afterItems", publicName: "afterItems", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedIndex: "selectedIndexChange", onRotate: "onRotate", onItemPan: "onItemPan", onItemPanned: "onItemPanned", onPan: "onPan", onPanned: "onPanned" }, host: { listeners: { "window:touchend": "onTouchEnd($event)", "window:mouseup": "onMouseUp($event)" } }, queries: [{ propertyName: "itemList", predicate: InteractiveItemComponent, isSignal: true }], viewQueries: [{ propertyName: "containerElem", first: true, predicate: ["containerElem"], descendants: true, static: true }, { propertyName: "canvasElem", first: true, predicate: ["canvasElem"], descendants: true, static: true }], ngImport: i0, template: "<div #containerElem\n [ngClass]=\"['interactive-canvas-container', horizontal() ? 'horizontal' : 'vertical']\"\n (resize)=\"resize()\"\n (touchstart)=\"onTouchStart($event)\"\n (mousedown)=\"onMouseDown($event)\"\n (mousemove)=\"onMouseMove($event)\"\n (mouseleave)=\"onMouseLeave()\"\n (panend)=\"onPanEnd()\"\n (panmove)=\"onPanMove($event)\"\n (panstart)=\"onPanStart()\">\n <canvas #canvasElem class=\"interactive-canvas-element\"></canvas>\n</div>\n", styles: [".interactive-canvas-container{width:100%;height:100%;position:relative;display:flex;align-items:center;justify-content:center}.interactive-canvas-container .interactive-canvas-element{position:absolute;pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i1$3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
|
|
8280
8332
|
}
|
|
8281
8333
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: InteractiveCanvasComponent, decorators: [{
|
|
8282
8334
|
type: Component,
|
|
8283
|
-
args: [{ standalone: false, selector: "interactive-canvas", template: "<div #containerElem\n [ngClass]=\"['interactive-canvas-container', horizontal ? 'horizontal' : 'vertical']\"\n (resize)=\"resize()\"\n (touchstart)=\"onTouchStart($event)\"\n (mousedown)=\"onMouseDown($event)\"\n (mousemove)=\"onMouseMove($event)\"\n (mouseleave)=\"onMouseLeave()\"\n (panend)=\"onPanEnd()\"\n (panmove)=\"onPanMove($event)\"\n (panstart)=\"onPanStart()\">\n <canvas #canvasElem class=\"interactive-canvas-element\"></canvas>\n</div>\n", styles: [".interactive-canvas-container{width:100%;height:100%;position:relative;display:flex;align-items:center;justify-content:center}.interactive-canvas-container .interactive-canvas-element{position:absolute;pointer-events:none}\n"] }]
|
|
8284
|
-
}], ctorParameters: () => [
|
|
8285
|
-
type: Input
|
|
8286
|
-
}], resizeMode: [{
|
|
8287
|
-
type: Input
|
|
8288
|
-
}], params: [{
|
|
8289
|
-
type: Input
|
|
8290
|
-
}], realWidth: [{
|
|
8291
|
-
type: Input
|
|
8292
|
-
}], realHeight: [{
|
|
8293
|
-
type: Input
|
|
8294
|
-
}], debug: [{
|
|
8295
|
-
type: Input
|
|
8296
|
-
}], horizontal: [{
|
|
8297
|
-
type: Input
|
|
8298
|
-
}], selectedIndex: [{
|
|
8299
|
-
type: Input
|
|
8300
|
-
}], panOffset: [{
|
|
8301
|
-
type: Input
|
|
8302
|
-
}], renderCtx: [{
|
|
8303
|
-
type: Input
|
|
8304
|
-
}], beforeItems: [{
|
|
8305
|
-
type: Input
|
|
8306
|
-
}], afterItems: [{
|
|
8307
|
-
type: Input
|
|
8308
|
-
}], selectedIndexChange: [{
|
|
8309
|
-
type: Output
|
|
8310
|
-
}], onRotate: [{
|
|
8311
|
-
type: Output
|
|
8312
|
-
}], onItemPan: [{
|
|
8313
|
-
type: Output
|
|
8314
|
-
}], onItemPanned: [{
|
|
8315
|
-
type: Output
|
|
8316
|
-
}], onPan: [{
|
|
8317
|
-
type: Output
|
|
8318
|
-
}], onPanned: [{
|
|
8319
|
-
type: Output
|
|
8320
|
-
}], containerElem: [{
|
|
8335
|
+
args: [{ standalone: false, selector: "interactive-canvas", template: "<div #containerElem\n [ngClass]=\"['interactive-canvas-container', horizontal() ? 'horizontal' : 'vertical']\"\n (resize)=\"resize()\"\n (touchstart)=\"onTouchStart($event)\"\n (mousedown)=\"onMouseDown($event)\"\n (mousemove)=\"onMouseMove($event)\"\n (mouseleave)=\"onMouseLeave()\"\n (panend)=\"onPanEnd()\"\n (panmove)=\"onPanMove($event)\"\n (panstart)=\"onPanStart()\">\n <canvas #canvasElem class=\"interactive-canvas-element\"></canvas>\n</div>\n", styles: [".interactive-canvas-container{width:100%;height:100%;position:relative;display:flex;align-items:center;justify-content:center}.interactive-canvas-container .interactive-canvas-element{position:absolute;pointer-events:none}\n"] }]
|
|
8336
|
+
}], ctorParameters: () => [], propDecorators: { containerElem: [{
|
|
8321
8337
|
type: ViewChild,
|
|
8322
8338
|
args: ["containerElem", { static: true }]
|
|
8323
8339
|
}], canvasElem: [{
|
|
8324
8340
|
type: ViewChild,
|
|
8325
8341
|
args: ["canvasElem", { static: true }]
|
|
8326
|
-
}], itemList: [{
|
|
8327
|
-
type: ContentChildren,
|
|
8328
|
-
args: [InteractiveItemComponent]
|
|
8329
8342
|
}], onTouchEnd: [{
|
|
8330
8343
|
type: HostListener,
|
|
8331
8344
|
args: ["window:touchend", ["$event"]]
|
|
@@ -9124,5 +9137,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
9124
9137
|
* Generated bundle index. Do not edit.
|
|
9125
9138
|
*/
|
|
9126
9139
|
|
|
9127
|
-
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, drawOval, drawRect, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, hashCode, impatientPromise, isBrowser, isPoint, lengthOfPt, lerpPts, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, subPts, switchClass, toDegrees, toRadians, tripleProduct };
|
|
9140
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AsyncMethodTargetDirective, AuthGuard, BASE_CONFIG, BUTTON_TYPE, BackgroundDirective, BaseDialogService, BaseHttpClient, BaseHttpService, BaseToasterService, BtnComponent, BtnDefaultComponent, CONFIG_SERVICE, CacheService, CanvasColor, CanvasUtils, ChipsComponent, ChunkPipe, Circle, CloseBtnComponent, ComponentLoaderDirective, ComponentLoaderService, ConfigService, DIALOG_SERVICE, DateUtils, DragDropEventPlugin, DropListComponent, DropdownBoxComponent, DropdownContentDirective, DropdownDirective, DropdownToggleDirective, DynamicTableComponent, DynamicTableTemplateDirective, EPSILON, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FakeModuleComponent, FileSystemEntry, FileUtils, FilterPipe, FindPipe, ForbiddenZone, FormatNumberPipe, FormatterService, GenericValue, GetOffsetPipe, GetTypePipe, GetValuePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, ICON_MAP, ICON_SERVICE, ICON_TYPE, IConfiguration, IconComponent, IconDefaultComponent, IconDirective, IconService, IncludesPipe, Initializer, InteractiveCanvasComponent, InteractiveCircleComponent, InteractiveItemComponent, InteractiveRectComponent, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, OPTIONS_TOKEN, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, Oval, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, STATIC_SCHEMAS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SocketClient, SocketService, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TabsComponent, TabsItemDirective, TabsTemplateDirective, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UploadComponent, ValuedPromise, ValuesPipe, addPts, cachedFactory, cancelablePromise, checkTransitions, clamp, computedPrevious, createTypedProvider, cssStyles, cssVariables, distance, distanceSq, dividePts, dotProduct, drawOval, drawRect, ensurePoint, getComponentDef, getCssVariables, getRoot, gjkDistance, gjkIntersection, hashCode, impatientPromise, injectOptions, isBrowser, isPoint, lengthOfPt, lerpPts, multiplyPts, negatePt, normalizePt, normalizeRange, overflow, parseSelector, perpendicular, provideEntryComponents, provideOptions, provideWithOptions, rotateDeg, rotateRad, selectorMatchesList, subPts, switchClass, toDegrees, toRadians, tripleProduct };
|
|
9128
9141
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|