Skip to content

Commit 103f1df

Browse files
authored
Merge pull request #5718 from IgniteUI/slider-label-ie11-8.1.x
feat(slider): incorrectly positioned label ie11
2 parents d0872f1 + 745535b commit 103f1df

File tree

8 files changed

+185
-51
lines changed

8 files changed

+185
-51
lines changed

projects/igniteui-angular/src/lib/core/styles/components/slider/_slider-component.scss

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
@include e(thumb-#{$t}) {
3535
@extend %igx-thumb-display !optional;
3636

37-
.label {
38-
@extend %igx-thumb-label !optional;
39-
}
40-
4137
.dot {
4238
@extend %igx-thumb-dot !optional;
4339
}
@@ -46,12 +42,24 @@
4642
@include e(thumb-#{$t}, $m: active) {
4743
@extend %igx-thumb--active !optional;
4844

45+
.dot {
46+
@extend %igx-thumb-dot--active !optional;
47+
}
48+
}
49+
50+
@include e(label-#{$t}) {
51+
@extend %igx-label-display !optional;
52+
4953
.label {
50-
@extend %igx-thumb-label--active !optional;
54+
@extend %igx-thumb-label !optional;
5155
}
56+
}
5257

53-
.dot {
54-
@extend %igx-thumb-dot--active !optional;
58+
@include e(label-#{$t}, $m: active) {
59+
@extend %igx-thumb--active !optional;
60+
61+
.label {
62+
@extend %igx-thumb-label--active !optional;
5563
}
5664
}
5765
}
@@ -91,10 +99,6 @@
9199
@extend %igx-thumb-display !optional;
92100
@extend %igx-thumb--disabled !optional;
93101

94-
.label {
95-
@extend %igx-thumb-label !optional;
96-
}
97-
98102
.dot {
99103
@extend %igx-thumb-dot--disabled !optional;
100104
}

projects/igniteui-angular/src/lib/core/styles/components/slider/_slider-theme.scss

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,26 @@
166166
}
167167
}
168168

169-
%igx-thumb-label {
169+
%igx-label-display {
170170
position: absolute;
171171
display: flex;
172+
justify-content: center;
173+
align-items: center;
174+
flex-direction: column;
175+
height: $slider-thumb-height;
176+
outline-style: none;
177+
top: -#{rem($slider-thumb-radius)};
178+
margin: 0 auto;
179+
}
180+
181+
%igx-thumb-label {
182+
position: relative;
183+
display: flex;
172184
align-items: center;
173185
justify-content: center;
174186
flex: 0 0 auto;
175-
top: -#{rem($slider-thumb-height - 6px)};
187+
top: -#{rem($slider-thumb-height - 4px)};
188+
left: -50%;
176189
pointer-events: none;
177190
min-width: rem($slider-label-width);
178191
height: rem($slider-label-height);
@@ -181,7 +194,7 @@
181194
margin: 0 auto;
182195
font-size: $slider-label-font-size;
183196
font-weight: $slider-label-font-weight;
184-
line-height: 1;
197+
line-height: rem(18px);
185198
color: --var($theme, 'label-text-color');
186199
background: --var($theme, 'label-background-color');
187200
opacity: 0;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="label">
2+
<ng-container *ngTemplateOutlet="templateRef ? templateRef : thumbFromDefaultTemplate; context: context"></ng-container>
3+
</div>
4+
5+
<ng-template #thumbFromDefaultTemplate>
6+
{{ value }}
7+
</ng-template>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Component, NgModule, Input, TemplateRef, HostBinding, ElementRef } from '@angular/core';
2+
import { SliderHandle } from '../slider.common';
3+
4+
@Component({
5+
selector: 'igx-thumb-label',
6+
templateUrl: 'thumb-label.component.html'
7+
})
8+
export class IgxThumbLabelComponent {
9+
private _active: boolean;
10+
11+
@Input()
12+
public value: number;
13+
14+
@Input()
15+
public templateRef: TemplateRef<any>;
16+
17+
@Input()
18+
public context: any;
19+
20+
@Input()
21+
public type: SliderHandle;
22+
23+
@Input()
24+
public continuous: boolean;
25+
26+
@HostBinding('class.igx-slider__label-from')
27+
public get thumbFromClass() {
28+
return this.type === SliderHandle.FROM;
29+
}
30+
31+
@HostBinding('class.igx-slider__label-to')
32+
public get thumbToClass() {
33+
return this.type === SliderHandle.TO;
34+
}
35+
36+
@HostBinding('class.igx-slider__label-from--active')
37+
public get thumbFromActiveClass() {
38+
return this.type === SliderHandle.FROM && this.active;
39+
}
40+
41+
@HostBinding('class.igx-slider__label-to--active')
42+
public get thumbToActiveClass() {
43+
return this.type === SliderHandle.TO && this.active;
44+
}
45+
46+
constructor(private _elementRef: ElementRef) { }
47+
48+
public get nativeElement() {
49+
return this._elementRef.nativeElement;
50+
}
51+
52+
public get active() {
53+
return this._active;
54+
}
55+
56+
public set active(val: boolean) {
57+
if (this.continuous) {
58+
return;
59+
}
60+
61+
this._active = val;
62+
}
63+
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
<div #ticks class="igx-slider__track-ticks"></div>
44
</div>
55
<div class="igx-slider__thumbs">
6-
<igx-thumb *ngIf="isRange"
6+
<igx-thumb-label
7+
*ngIf="isRange"
8+
[type]="0"
9+
[value]="value"
10+
[templateRef]="thumbFromTemplateRef"
11+
[continuous]="continuous"
12+
[context]="context"></igx-thumb-label>
13+
14+
<igx-thumb *ngIf="isRange"
715
#thumbFrom
816
[type]="0"
917
[value]="lowerLabel"
@@ -17,7 +25,15 @@
1725
(onChange)="onThumbChange()"
1826
(onHoverChange)="onHoverChange($event)"
1927
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
20-
<igx-thumb
28+
29+
<igx-thumb-label
30+
[value]="value"
31+
[type]="1"
32+
[templateRef]="thumbToTemplateRef"
33+
[continuous]="continuous"
34+
[context]="context"></igx-thumb-label>
35+
36+
<igx-thumb
2137
#thumbTo
2238
[type]="1"
2339
[value]="upperLabel"
@@ -31,4 +47,5 @@
3147
(onChange)="onThumbChange()"
3248
(onHoverChange)="onHoverChange($event)"
3349
[thumbLabelVisibilityDuration]="thumbLabelVisibilityDuration"></igx-thumb>
50+
3451
</div>

0 commit comments

Comments
 (0)