ngx-round-slider 21.0.0
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/README.md +64 -0
- package/ng-package.json +7 -0
- package/package.json +20 -0
- package/src/lib/ngx-round-slider-styles.ts +9 -0
- package/src/lib/ngx-round-slider.css +45 -0
- package/src/lib/ngx-round-slider.html +67 -0
- package/src/lib/ngx-round-slider.spec.ts +68 -0
- package/src/lib/ngx-round-slider.ts +220 -0
- package/src/public-api.ts +1 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +10 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# NgxRoundSlider
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build ngx-round-slider
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd dist/ngx-round-slider
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
40
|
+
```bash
|
|
41
|
+
npm publish
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running unit tests
|
|
45
|
+
|
|
46
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ng test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Running end-to-end tests
|
|
53
|
+
|
|
54
|
+
For end-to-end (e2e) testing, run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ng e2e
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
61
|
+
|
|
62
|
+
## Additional Resources
|
|
63
|
+
|
|
64
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
package/ng-package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ngx-round-slider",
|
|
3
|
+
"version": "21.0.0",
|
|
4
|
+
"main": "bundles/ngx-round-slider.umd.js",
|
|
5
|
+
"module": "fesm2022/ngx-round-slider.mjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./fesm2022/ngx-round-slider.mjs",
|
|
9
|
+
"require": "./bundles/ngx-round-slider.umd.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"@angular/common": "^20.0.0 || ^21.0.0",
|
|
14
|
+
"@angular/core": "^20.0.0 || ^21.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"tslib": "^2.3.0"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--ngx-round-slider-path-selected-range: #0060e4;
|
|
3
|
+
--ngx-round-slider-path-selected-range-cone: rgba(0, 96, 228, 0.5);
|
|
4
|
+
--ngx-round-slider-path-outbound-dashed: #818080;
|
|
5
|
+
--ngx-round-slider-path-allowed-range-border: #5a5a5a;
|
|
6
|
+
--ngx-round-slider-path-allowed-range-center: #858585;
|
|
7
|
+
--ngx-round-slider-path-zero-line: #5a5a5a;
|
|
8
|
+
--ngx-round-slider-handler-fill: #3a3a3a;
|
|
9
|
+
--ngx-round-slider-handler-stroke: #3a3a3a;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.path-selected-range {
|
|
13
|
+
fill: transparent;
|
|
14
|
+
stroke: var(--ngx-round-slider-path-selected-range);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.path-selected-range-cone {
|
|
18
|
+
fill: var(--ngx-round-slider-path-selected-range-cone);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.path-outbound-dashed {
|
|
22
|
+
fill: transparent;
|
|
23
|
+
stroke: var(--ngx-round-slider-path-outbound-dashed);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.path-allowed-range-border {
|
|
27
|
+
fill: transparent;
|
|
28
|
+
stroke: var(--ngx-round-slider-path-allowed-range-border);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.path-allowed-range-center {
|
|
32
|
+
fill: transparent;
|
|
33
|
+
stroke: var(--ngx-round-slider-path-allowed-range-center);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.path-zero-line {
|
|
37
|
+
fill: transparent;
|
|
38
|
+
stroke: var(--ngx-round-slider-path-zero-line);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.handler {
|
|
42
|
+
cursor: move;
|
|
43
|
+
fill: var(--ngx-round-slider-handler-fill);
|
|
44
|
+
stroke: var(--ngx-round-slider-handler-stroke);
|
|
45
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
[attr.width]="radius * 2 + 20"
|
|
3
|
+
[attr.height]="radius * 2 + 20"
|
|
4
|
+
(mousemove)="updateAngle($event)"
|
|
5
|
+
(mouseup)="activeHandler = null">
|
|
6
|
+
|
|
7
|
+
<!-- área preenchida (cone do intervalo selecionado) -->
|
|
8
|
+
<path
|
|
9
|
+
[class]="styleClasses?.pathSelectedRangeCone ?? 'path-selected-range-cone'"
|
|
10
|
+
[attr.d]="getConePath()"
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<foreignObject [attr.x]="strokePathWidth" [attr.y]="0" [attr.width]="(radius*2) - strokePathWidth"
|
|
14
|
+
[attr.height]="radius">
|
|
15
|
+
<ng-content select="[top]"></ng-content>
|
|
16
|
+
</foreignObject>
|
|
17
|
+
<foreignObject [attr.x]="strokePathWidth" [attr.y]="radius" [attr.width]="(radius*2) - strokePathWidth"
|
|
18
|
+
[attr.height]="radius">
|
|
19
|
+
<ng-content select="[bottom]"></ng-content>
|
|
20
|
+
</foreignObject>
|
|
21
|
+
|
|
22
|
+
<g>
|
|
23
|
+
<!-- arco pontilhado (fora dos limites) -->
|
|
24
|
+
<path
|
|
25
|
+
[class]="styleClasses?.pathOutboundDashed ?? 'path-outbound-dashed'"
|
|
26
|
+
[attr.d]="getExcludedArcPath()"
|
|
27
|
+
stroke-width="2"
|
|
28
|
+
stroke-dasharray="6,4"
|
|
29
|
+
/>
|
|
30
|
+
<!-- arco cinza (limite permitido) -->
|
|
31
|
+
<path
|
|
32
|
+
[class]="styleClasses?.pathAllowedRangeBorder ?? 'path-allowed-range-border'"
|
|
33
|
+
[attr.d]="getLimitArcPath()"
|
|
34
|
+
[attr.stroke-width]="strokePathWidth"
|
|
35
|
+
/>
|
|
36
|
+
<path
|
|
37
|
+
[class]="styleClasses?.pathAllowedRangeCenter ?? 'path-allowed-range-center'"
|
|
38
|
+
[attr.d]="getLimitArcPath()"
|
|
39
|
+
[attr.stroke-width]="strokePathWidth - (strokePathWidth/5)"
|
|
40
|
+
/>
|
|
41
|
+
</g>
|
|
42
|
+
|
|
43
|
+
<!-- arco selecionado -->
|
|
44
|
+
<path
|
|
45
|
+
[class]="styleClasses?.pathSelectedRange ?? 'path-selected-range'"
|
|
46
|
+
[attr.d]="getArcPath()"
|
|
47
|
+
[attr.stroke-width]="strokePathWidth"
|
|
48
|
+
/>
|
|
49
|
+
<!-- 0(zero) line -->
|
|
50
|
+
<line
|
|
51
|
+
[class]="styleClasses?.pathZeroLine ?? 'path-zero-line'"
|
|
52
|
+
[attr.x1]="0" [attr.y1]="radius+10" [attr.x2]="strokePathWidth+4" [attr.y2]="radius+10"
|
|
53
|
+
stroke-width="1" stroke-linecap="round" />
|
|
54
|
+
|
|
55
|
+
<!-- handles -->
|
|
56
|
+
@for (handle of circleHandlersOrder; track handle) {
|
|
57
|
+
@if (!disabled) {
|
|
58
|
+
<circle
|
|
59
|
+
[class]="styleClasses?.handler ?? 'handler'"
|
|
60
|
+
[attr.r]="strokePathWidth/2"
|
|
61
|
+
[attr.cx]="getHandleX(handle === 'start' ? start : end) + radius + 10"
|
|
62
|
+
[attr.cy]="getHandleY(handle === 'start' ? start : end) + radius + 10"
|
|
63
|
+
(mousedown)="setActive(handle)"
|
|
64
|
+
/>
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</svg>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { NgxRoundSlider } from './ngx-round-slider';
|
|
2
|
+
|
|
3
|
+
describe('NgxRoundSlider', () => {
|
|
4
|
+
let component: NgxRoundSlider;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
component = new NgxRoundSlider();
|
|
8
|
+
component.radius = 100;
|
|
9
|
+
component.min = 0;
|
|
10
|
+
component.max = 360;
|
|
11
|
+
component.start = 0;
|
|
12
|
+
component.end = 360;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function mockMouseEvent(x: number, y: number, svgSize = 200): MouseEvent {
|
|
16
|
+
const event = {
|
|
17
|
+
clientX: x,
|
|
18
|
+
clientY: y,
|
|
19
|
+
target: {
|
|
20
|
+
closest: () => ({
|
|
21
|
+
getBoundingClientRect: () => ({
|
|
22
|
+
left: 0,
|
|
23
|
+
top: 0,
|
|
24
|
+
width: svgSize,
|
|
25
|
+
height: svgSize,
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
} as unknown as MouseEvent;
|
|
30
|
+
return event;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it('deve permitir que o start chegue em 0°', () => {
|
|
34
|
+
component.setActive('start');
|
|
35
|
+
// ponto à esquerda do centro
|
|
36
|
+
const event = mockMouseEvent(0, 100);
|
|
37
|
+
component.updateAngle(event);
|
|
38
|
+
expect(component.start).toBe(0);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('deve permitir que o end chegue em 360°', () => {
|
|
42
|
+
component.setActive('end');
|
|
43
|
+
// ponto à esquerda do centro
|
|
44
|
+
const event = mockMouseEvent(0, 100);
|
|
45
|
+
component.updateAngle(event);
|
|
46
|
+
expect(component.end).toBe(360);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('não deve permitir que start ultrapasse end', () => {
|
|
50
|
+
component.start = 100;
|
|
51
|
+
component.end = 120;
|
|
52
|
+
component.setActive('start');
|
|
53
|
+
// tenta mover start para 130 (maior que end)
|
|
54
|
+
const event = mockMouseEvent(200, 100);
|
|
55
|
+
component.updateAngle(event);
|
|
56
|
+
expect(component.start).toBeLessThan(component.end);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('não deve permitir que end seja menor que start', () => {
|
|
60
|
+
component.start = 100;
|
|
61
|
+
component.end = 120;
|
|
62
|
+
component.setActive('end');
|
|
63
|
+
// tenta mover end para 90 (menor que start)
|
|
64
|
+
const event = mockMouseEvent(150, 100);
|
|
65
|
+
component.updateAngle(event);
|
|
66
|
+
expect(component.end).toBeGreaterThanOrEqual(component.start);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
Component,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
Output,
|
|
7
|
+
ViewEncapsulation,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import { NgxRoundSliderStyles } from './ngx-round-slider-styles';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'ngx-round-slider',
|
|
13
|
+
standalone: true,
|
|
14
|
+
imports: [],
|
|
15
|
+
templateUrl: './ngx-round-slider.html',
|
|
16
|
+
styleUrl: './ngx-round-slider.css',
|
|
17
|
+
})
|
|
18
|
+
export class NgxRoundSlider implements AfterViewInit {
|
|
19
|
+
@Input() disabled = false;
|
|
20
|
+
@Input() radius = 100;
|
|
21
|
+
@Input() strokePathWidth = 20;
|
|
22
|
+
|
|
23
|
+
@Input() start = 0;
|
|
24
|
+
@Output() startChange = new EventEmitter<number>();
|
|
25
|
+
@Input() end = 0;
|
|
26
|
+
@Output() endChange = new EventEmitter<number>();
|
|
27
|
+
@Input() min = 0;
|
|
28
|
+
@Input() max = 360;
|
|
29
|
+
|
|
30
|
+
@Input() styleClasses?: NgxRoundSliderStyles;
|
|
31
|
+
|
|
32
|
+
// handlers
|
|
33
|
+
circleHandlersOrder: ('start' | 'end')[] = ['start', 'end'];
|
|
34
|
+
activeHandler: 'start' | 'end' | null = null;
|
|
35
|
+
inversionToleraceDeg = 5;
|
|
36
|
+
|
|
37
|
+
ngAfterViewInit(): void {
|
|
38
|
+
if (this.start < this.min) {
|
|
39
|
+
this.start = this.min;
|
|
40
|
+
this.startChange.emit(this.start);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (this.end > this.max) {
|
|
44
|
+
this.end = this.max;
|
|
45
|
+
this.endChange.emit(this.end);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.start > this.end) {
|
|
49
|
+
const oldStart = this.start;
|
|
50
|
+
const oldEnd = this.end;
|
|
51
|
+
|
|
52
|
+
this.start = oldEnd;
|
|
53
|
+
this.startChange.emit(this.start);
|
|
54
|
+
this.end = oldStart;
|
|
55
|
+
this.endChange.emit(this.end);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setActive(handle: 'start' | 'end') {
|
|
60
|
+
this.activeHandler = handle;
|
|
61
|
+
this.circleHandlersOrder = this.activeHandler === 'start' ? ['end', 'start'] : ['start', 'end'];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
updateAngle(event: MouseEvent) {
|
|
65
|
+
if (!this.activeHandler) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const svg = (event.target as SVGElement).closest('svg');
|
|
70
|
+
if (!svg) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const rect = svg.getBoundingClientRect();
|
|
75
|
+
const cx = rect.left + rect.width / 2;
|
|
76
|
+
const cy = rect.top + rect.height / 2;
|
|
77
|
+
|
|
78
|
+
const dx = event.clientX - cx;
|
|
79
|
+
const dy = event.clientY - cy;
|
|
80
|
+
|
|
81
|
+
// atan2 retorna em radianos, converter para graus
|
|
82
|
+
let deg = Math.atan2(-dy, -dx) * (180 / Math.PI);
|
|
83
|
+
|
|
84
|
+
// normaliza para [0, 360)
|
|
85
|
+
if (deg < 0) {
|
|
86
|
+
deg += 360;
|
|
87
|
+
}
|
|
88
|
+
deg = Math.round(deg);
|
|
89
|
+
|
|
90
|
+
// se for o start, 360 deve virar 0
|
|
91
|
+
if (this.activeHandler === 'start' && deg === 360) {
|
|
92
|
+
deg = 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// se for o end, -0 deve virar 360
|
|
96
|
+
if (this.activeHandler === 'end' && deg === 0) {
|
|
97
|
+
deg = 360;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// inverte para comecar grau 0 na esquerda sentido horario
|
|
101
|
+
if (deg < 0 && this.activeHandler === 'end') {
|
|
102
|
+
deg += 360;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// corrige -0 → 0
|
|
106
|
+
if (Object.is(deg, -0)) {
|
|
107
|
+
deg = 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const isOutbound = deg < this.min || deg > this.max;
|
|
111
|
+
if (isOutbound) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (this.activeHandler === 'start') {
|
|
116
|
+
if (deg > this.end) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// caso especial: atualmente é 0 e 360 e quer diminuir: NAO DA
|
|
120
|
+
if (this.start === 0 && this.end === 360 && deg > (360 - this.inversionToleraceDeg)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.start = Math.round(deg);
|
|
125
|
+
this.startChange.emit(this.start);
|
|
126
|
+
} else if (this.activeHandler === 'end') {
|
|
127
|
+
if (deg < this.start) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// caso especial: atualmente é 0 e 360 e quer aumentar ate 10: NAO DA
|
|
131
|
+
if (this.start === 0 && this.end === 360 && deg < this.inversionToleraceDeg) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.end = Math.round(deg);
|
|
136
|
+
this.endChange.emit(this.end);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// coordenadas dos handles (0° = esquerda)
|
|
141
|
+
getHandleX(angle: number) {
|
|
142
|
+
return this.radius * Math.cos(((angle - 180) * Math.PI) / 180);
|
|
143
|
+
}
|
|
144
|
+
getHandleY(angle: number) {
|
|
145
|
+
return this.radius * Math.sin(((angle - 180) * Math.PI) / 180);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// arco cinza (limite permitido)
|
|
149
|
+
getLimitArcPath() {
|
|
150
|
+
if (this.min === 0 && this.max === 360) {
|
|
151
|
+
const cx = this.radius + 10;
|
|
152
|
+
const cy = this.radius + 10;
|
|
153
|
+
return `M ${cx - this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx + this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx - this.radius} ${cy}`;
|
|
154
|
+
}
|
|
155
|
+
const startX = this.getHandleX(this.min) + this.radius + 10;
|
|
156
|
+
const startY = this.getHandleY(this.min) + this.radius + 10;
|
|
157
|
+
const endX = this.getHandleX(this.max) + this.radius + 10;
|
|
158
|
+
const endY = this.getHandleY(this.max) + this.radius + 10;
|
|
159
|
+
|
|
160
|
+
const largeArc = (this.max - this.min + 360) % 360 > 180 ? 1 : 0;
|
|
161
|
+
|
|
162
|
+
return `M ${startX} ${startY} A ${this.radius} ${this.radius} 0 ${largeArc} 1 ${endX} ${endY}`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// arco pontilhado (fora dos limites)
|
|
166
|
+
getExcludedArcPath() {
|
|
167
|
+
const cx = this.radius + 10;
|
|
168
|
+
const cy = this.radius + 10;
|
|
169
|
+
|
|
170
|
+
const startX = this.getHandleX(this.max) + cx;
|
|
171
|
+
const startY = this.getHandleY(this.max) + cy;
|
|
172
|
+
const endX = this.getHandleX(this.min) + cx;
|
|
173
|
+
const endY = this.getHandleY(this.min) + cy;
|
|
174
|
+
|
|
175
|
+
const largeArc = (this.min - this.max + 360) % 360 > 180 ? 1 : 0;
|
|
176
|
+
|
|
177
|
+
return `M ${startX} ${startY} A ${this.radius} ${this.radius} 0 ${largeArc} 1 ${endX} ${endY}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// arco entre start e end
|
|
181
|
+
getArcPath() {
|
|
182
|
+
if (this.start === 0 && this.end === 360) {
|
|
183
|
+
const cx = this.radius + 10;
|
|
184
|
+
const cy = this.radius + 10;
|
|
185
|
+
return `M ${cx - this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx + this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx - this.radius} ${cy}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const startX = this.getHandleX(this.start) + this.radius + 10;
|
|
189
|
+
const startY = this.getHandleY(this.start) + this.radius + 10;
|
|
190
|
+
const endX = this.getHandleX(this.end) + this.radius + 10;
|
|
191
|
+
const endY = this.getHandleY(this.end) + this.radius + 10;
|
|
192
|
+
|
|
193
|
+
const largeArc =
|
|
194
|
+
(this.start === 0 && this.end === 360) || (this.end - this.start + 360) % 360 > 180 ? 1 : 0;
|
|
195
|
+
|
|
196
|
+
return `M ${startX} ${startY} A ${this.radius} ${this.radius} 0 ${largeArc} 1 ${endX} ${endY}`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// área preenchida (cone do ângulo selecionado)
|
|
200
|
+
getConePath() {
|
|
201
|
+
if (this.start === 0 && this.end === 360) {
|
|
202
|
+
const cx = this.radius + 10;
|
|
203
|
+
const cy = this.radius + 10;
|
|
204
|
+
return `M ${cx - this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx + this.radius} ${cy} A ${this.radius} ${this.radius} 0 1 1 ${cx - this.radius} ${cy}`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const cx = this.radius + 10;
|
|
208
|
+
const cy = this.radius + 10;
|
|
209
|
+
|
|
210
|
+
const startX = this.getHandleX(this.start) + cx;
|
|
211
|
+
const startY = this.getHandleY(this.start) + cy;
|
|
212
|
+
const endX = this.getHandleX(this.end) + cx;
|
|
213
|
+
const endY = this.getHandleY(this.end) + cy;
|
|
214
|
+
|
|
215
|
+
const largeArc = (this.end - this.start + 360) % 360 > 180 ? 1 : 0;
|
|
216
|
+
|
|
217
|
+
// M centro → L ponto inicial → arco até ponto final → Z fecha no centro
|
|
218
|
+
return `M ${cx} ${cy} L ${startX} ${startY} A ${this.radius} ${this.radius} 0 ${largeArc} 1 ${endX} ${endY} Z`;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/ngx-round-slider';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"types": ["vitest/globals"]
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
|
|
10
|
+
}
|