6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
+ import { Directionality } from '@angular/cdk/bidi' ;
9
10
import {
10
11
BooleanInput ,
11
12
coerceBooleanProperty ,
@@ -29,6 +30,7 @@ import {
29
30
NgZone ,
30
31
OnDestroy ,
31
32
OnInit ,
33
+ Optional ,
32
34
Output ,
33
35
QueryList ,
34
36
ViewChild ,
@@ -46,6 +48,7 @@ import {
46
48
} from '@angular/material/core' ;
47
49
import { SpecificEventListener , EventType } from '@material/base' ;
48
50
import { MDCSliderAdapter , MDCSliderFoundation , Thumb , TickMark } from '@material/slider' ;
51
+ import { Subscription } from 'rxjs' ;
49
52
50
53
/** Represents a drag event emitted by the MatSlider component. */
51
54
export interface MatSliderDragEvent {
@@ -582,14 +585,19 @@ export class MatSlider extends _MatSliderMixinBase implements AfterViewInit, OnD
582
585
/** The display value of the end thumb. */
583
586
_endValueIndicatorText : string ;
584
587
588
+ /** Subscription to changes to the directionality (LTR / RTL) context for the application. */
589
+ private _dirChangeSubscription : Subscription ;
590
+
585
591
constructor (
586
592
readonly _cdr : ChangeDetectorRef ,
587
593
readonly _elementRef : ElementRef < HTMLElement > ,
588
594
private readonly _platform : Platform ,
595
+ @Optional ( ) private _dir : Directionality ,
589
596
@Inject ( DOCUMENT ) document : any ) {
590
597
super ( _elementRef ) ;
591
598
this . _document = document ;
592
599
this . _window = this . _document . defaultView || window ;
600
+ this . _dirChangeSubscription = this . _dir . change . subscribe ( ( ) => this . _reinitialize ( ) ) ;
593
601
}
594
602
595
603
ngAfterViewInit ( ) {
@@ -622,6 +630,12 @@ export class MatSlider extends _MatSliderMixinBase implements AfterViewInit, OnD
622
630
if ( this . _platform . isBrowser ) {
623
631
this . _foundation . destroy ( ) ;
624
632
}
633
+ this . _dirChangeSubscription . unsubscribe ( ) ;
634
+ }
635
+
636
+ /** Returns true if the language direction for this slider element is right to left. */
637
+ _isRTL ( ) {
638
+ return this . _dir && this . _dir . value === 'rtl' ;
625
639
}
626
640
627
641
/**
@@ -777,8 +791,7 @@ class SliderAdapter implements MDCSliderAdapter {
777
791
return this . _delegate . _elementRef . nativeElement . getBoundingClientRect ( ) ;
778
792
}
779
793
isRTL = ( ) : boolean => {
780
- // TODO(wagnermaciel): Actually implementing this.
781
- return false ;
794
+ return this . _delegate . _isRTL ( ) ;
782
795
}
783
796
setThumbStyleProperty = ( propertyName : string , value : string , thumbPosition : Thumb ) : void => {
784
797
this . _delegate . _getThumbElement ( thumbPosition ) . style . setProperty ( propertyName , value ) ;
0 commit comments