Skip to content

Commit e6023fe

Browse files
committed
fix(slider): remove slider wrapper el and update API comments
Closes #3449 #4562 #4559 #2622
1 parent 2acec3a commit e6023fe

File tree

5 files changed

+128
-64
lines changed

5 files changed

+128
-64
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ In order to turn them off, you need to pass an argument and set it to `false`
6363
## 7.2.12
6464
### New feature
6565
- **igxSlider** - exposing new `labels` property accepting a collection of literal values that become equally spread over the slider, by placing each element as a thumb label.
66+
- **igxSlider** - deprecate **isContiunous** property.
6667

6768
## 7.2.9
6869
- `Pager`
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
1-
<div
2-
#slider
3-
class="igx-slider"
4-
[class.igx-slider--disabled]="disabled"
5-
(pointerdown)="findClosestThumb($event)"
6-
(pan)="update($event.srcEvent.clientX)"
7-
(tap)="onTap($event)">
8-
<div class="igx-slider__track">
9-
<div #track class="igx-slider__track-fill"></div>
10-
<div #ticks class="igx-slider__track-ticks"></div>
11-
</div>
12-
<div class="igx-slider__thumbs">
13-
<igx-thumb *ngIf="isRange"
14-
#thumbFrom
15-
[type]="0"
16-
[value]="lowerLabel"
17-
[disabled]="disabled"
18-
[continuous]="continuous"
19-
[onPan]="onPan"
20-
[stepDistance]="stepDistance"
21-
[step]="step"
22-
[fromHandler]="true"
23-
[templateRef]="thumbFromTemplateRef"
24-
[context]="context"
25-
(onChange)="onThumbChange()"
26-
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
27-
<igx-thumb
28-
#thumbTo
29-
[type]="1"
30-
[value]="upperLabel"
31-
[disabled]="disabled"
32-
[continuous]="continuous"
33-
[onPan]="onPan"
34-
[stepDistance]="stepDistance"
35-
[step]="step"
36-
[templateRef]="thumbToTemplateRef"
37-
[context]="context"
38-
(onChange)="onThumbChange()"
39-
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
40-
</div>
1+
<div class="igx-slider__track">
2+
<div #track class="igx-slider__track-fill"></div>
3+
<div #ticks class="igx-slider__track-ticks"></div>
4+
</div>
5+
<div class="igx-slider__thumbs">
6+
<igx-thumb *ngIf="isRange"
7+
#thumbFrom
8+
[type]="0"
9+
[value]="lowerLabel"
10+
[disabled]="disabled"
11+
[continuous]="continuous"
12+
[onPan]="onPan"
13+
[stepDistance]="stepDistance"
14+
[step]="step"
15+
[fromHandler]="true"
16+
[templateRef]="thumbFromTemplateRef"
17+
[context]="context"
18+
(onChange)="onThumbChange()"
19+
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
20+
<igx-thumb
21+
#thumbTo
22+
[type]="1"
23+
[value]="upperLabel"
24+
[disabled]="disabled"
25+
[continuous]="continuous"
26+
[onPan]="onPan"
27+
[stepDistance]="stepDistance"
28+
[step]="step"
29+
[templateRef]="thumbToTemplateRef"
30+
[context]="context"
31+
(onChange)="onThumbChange()"
32+
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
4133
</div>

projects/igniteui-angular/src/lib/slider/slider.component.ts

+90-22
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,21 @@ export class IgxSliderComponent implements
139139
private _onChangeCallback: (_: any) => void = noop;
140140
private _onTouchedCallback: () => void = noop;
141141

142-
@ViewChild('slider')
143-
private slider: ElementRef;
144-
142+
/**
143+
* @hidden
144+
*/
145145
@ViewChild('track')
146146
private track: ElementRef;
147147

148+
/**
149+
* @hidden
150+
*/
148151
@ViewChild('ticks')
149152
private ticks: ElementRef;
150153

154+
/**
155+
* @hidden
156+
*/
151157
@ViewChildren(IgxSliderThumbComponent)
152158
private thumbs: QueryList<IgxSliderThumbComponent> = new QueryList<IgxSliderThumbComponent>();
153159

@@ -159,7 +165,14 @@ export class IgxSliderComponent implements
159165
return this.thumbs.find(thumb => thumb.type === SliderHandle.TO);
160166
}
161167

168+
/**
169+
* @hidden
170+
*/
162171
public stepDistance = this._step;
172+
173+
/**
174+
* @hidden
175+
*/
163176
public onPan: Subject<number> = new Subject<number>();
164177

165178
/**
@@ -204,6 +217,19 @@ export class IgxSliderComponent implements
204217
return this.disabled;
205218
}
206219

220+
/**
221+
* @hidden
222+
*/
223+
@HostBinding('class.igx-slider')
224+
public slierClass = true;
225+
226+
/**
227+
* @hidden
228+
*/
229+
@HostBinding('class.igx-slider--disabled')
230+
public get disabledClass() {
231+
return this.disabled;
232+
}
207233

208234
/**
209235
* An @Input property that sets the value of the `id` attribute.
@@ -216,6 +242,20 @@ export class IgxSliderComponent implements
216242
@Input()
217243
public id = `igx-slider-${NEXT_ID++}`;
218244

245+
/**
246+
* An @Input property that gets the type of the `IgxSliderComponent`. The slider can be SliderType.SLIDER(default) or SliderType.RANGE.
247+
* ```typescript
248+
* @ViewChild("slider2")
249+
* public slider: IgxSliderComponent;
250+
* ngAfterViewInit(){
251+
* let type = this.slider.type;
252+
* }
253+
*/
254+
@Input()
255+
public get type() {
256+
return this._type;
257+
}
258+
219259
/**
220260
* An @Input property that sets the type of the `IgxSliderComponent`. The slider can be SliderType.SLIDER(default) or SliderType.RANGE.
221261
* ```typescript
@@ -225,11 +265,6 @@ export class IgxSliderComponent implements
225265
* <igx-slider #slider2 [type]="sliderType" [(ngModel)]="rangeValue" [minValue]="0" [maxValue]="100">
226266
* ```
227267
*/
228-
@Input()
229-
public get type() {
230-
return this._type;
231-
}
232-
233268
public set type(type: SliderType) {
234269
this._type = type;
235270

@@ -639,17 +674,25 @@ export class IgxSliderComponent implements
639674
public onValueChange = new EventEmitter<ISliderValueChangeEventArgs>();
640675

641676

642-
constructor(private renderer: Renderer2) { }
677+
constructor(private renderer: Renderer2, private _el: ElementRef) { }
678+
679+
/**
680+
* @hidden
681+
*/
682+
@HostListener('pointerdown', ['$event'])
683+
public onPointerDown($event) {
684+
this.findClosestThumb($event);
643685

644-
@HostListener('pointerdown')
645-
public onPointerDown() {
646686
if (!this.thumbTo.isActive && this.thumbFrom === undefined) {
647687
return;
648688
}
649689

650690
this.showThumbLabels();
651691
}
652692

693+
/**
694+
* @hidden
695+
*/
653696
@HostListener('pointerup')
654697
public onPointerUp() {
655698
if (!this.thumbTo.isActive && this.thumbFrom === undefined) {
@@ -659,16 +702,38 @@ export class IgxSliderComponent implements
659702
this.hideThumbLabels();
660703
}
661704

705+
/**
706+
* @hidden
707+
*/
662708
@HostListener('focus')
663709
public onFocus() {
664710
this.toggleThumbLabels();
665711
}
666712

713+
/**
714+
* @hidden
715+
*/
667716
@HostListener('blur')
668717
public onBlur() {
669718
this.hideThumbLabels();
670719
}
671720

721+
/**
722+
* @hidden
723+
*/
724+
@HostListener('pan', ['$event'])
725+
public onPanListener($event) {
726+
this.update($event.srcEvent.clientX)
727+
}
728+
729+
/**
730+
* @hidden
731+
*/
732+
@HostListener('tap', ['$event'])
733+
public onTapListener($event) {
734+
this.onTap($event);
735+
}
736+
672737
/**
673738
*Returns whether the `IgxSliderComponent` type is RANGE.
674739
*```typescript
@@ -889,6 +954,9 @@ export class IgxSliderComponent implements
889954
this._onTouchedCallback();
890955
}
891956

957+
/**
958+
* @hidden
959+
*/
892960
public thumbChanged(value: number, thumbType: number) {
893961
const oldValue = this.value;
894962

@@ -922,7 +990,14 @@ export class IgxSliderComponent implements
922990
}
923991
}
924992

925-
public swapThumb(value: IRangeSliderValue) {
993+
/**
994+
* @hidden
995+
*/
996+
public onThumbChange() {
997+
this.toggleThumbLabels();
998+
}
999+
1000+
private swapThumb(value: IRangeSliderValue) {
9261001
if (this.thumbFrom.isActive) {
9271002
value.upper = this.upperValue;
9281003
value.lower = this.upperValue;
@@ -936,10 +1011,7 @@ export class IgxSliderComponent implements
9361011
return value;
9371012
}
9381013

939-
/**
940-
* @hidden
941-
*/
942-
public findClosestThumb(event) {
1014+
private findClosestThumb(event) {
9431015
if (this.isRange) {
9441016
this.closestHandle(event.clientX);
9451017
} else {
@@ -951,10 +1023,6 @@ export class IgxSliderComponent implements
9511023
event.preventDefault();
9521024
}
9531025

954-
public onThumbChange() {
955-
this.toggleThumbLabels();
956-
}
957-
9581026
private updateLowerBoundAndMinTravelZone() {
9591027
this.lowerBound = this.minValue;
9601028
this._pMin = 0;
@@ -976,7 +1044,7 @@ export class IgxSliderComponent implements
9761044
}
9771045

9781046
private calculateStepDistance() {
979-
return this.slider.nativeElement.getBoundingClientRect().width / (this.maxValue - this.minValue) * this.step;
1047+
return this._el.nativeElement.getBoundingClientRect().width / (this.maxValue - this.minValue) * this.step;
9801048
}
9811049

9821050
private toggleThumb() {
@@ -1027,7 +1095,7 @@ export class IgxSliderComponent implements
10271095
private closestHandle(mouseX) {
10281096
const fromOffset = this.thumbFrom.nativeElement.offsetLeft + this.thumbFrom.nativeElement.offsetWidth / 2;
10291097
const toOffset = this.thumbTo.nativeElement.offsetLeft + this.thumbTo.nativeElement.offsetWidth / 2;
1030-
const xPointer = mouseX - this.slider.nativeElement.getBoundingClientRect().left;
1098+
const xPointer = mouseX - this._el.nativeElement.getBoundingClientRect().left;
10311099
const match = this.closestTo(xPointer, [fromOffset, toOffset]);
10321100

10331101
if (match === fromOffset) {

projects/igniteui-angular/src/lib/slider/thumb/thumb-slider.component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { Subject } from 'rxjs';
1515
import { takeUntil } from 'rxjs/operators';
1616
import { SliderHandle } from '../slider.component';
1717

18+
/**
19+
* @hidden
20+
*/
1821
@Component({
1922
selector: 'igx-thumb',
2023
templateUrl: 'thumb-slider.component.html',

src/app/slider/slider.sample.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ <h4 class="sample-title">Slider</h4>
1313

1414
<article class="sample-column">
1515
<h4 class="sample-title">Range slider</h4>
16-
<igx-slider #slider2 [type]="sliderType" [(ngModel)]="rangeValue" [minValue]="0" [maxValue]="100">
16+
<igx-slider #slider2 [type]="sliderType" [disabled]="true" [(ngModel)]="rangeValue" [minValue]="0" [maxValue]="100">
1717
</igx-slider>
1818
</article>
1919

2020
<article class="sample-column">
2121
<h4 class="sample-title">Range label slider</h4>
22-
<igx-slider #slider2 [type]="sliderType" [(ngModel)]="rangeLabel"
22+
<igx-slider #slider3 [type]="sliderType" [(ngModel)]="rangeLabel"
2323
[labels]="['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']">
2424
<ng-template igxSliderThumbFrom let-value let-labels="labels">
2525
<span class="ellipsis">{{ labels[value.lower] }}</span>

0 commit comments

Comments
 (0)