File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -958,6 +958,21 @@ describe('MdSlider without forms', () => {
958
958
expect ( sliderInstance . value ) . toBe ( 30 ) ;
959
959
} ) ;
960
960
961
+ it ( 'should re-render when the direction changes' , ( ) => {
962
+ const thumbContainer =
963
+ sliderNativeElement . querySelector ( '.mat-slider-thumb-container' ) ! as HTMLElement ;
964
+
965
+ dispatchClickEventSequence ( sliderNativeElement , 0.7 ) ;
966
+ fixture . detectChanges ( ) ;
967
+
968
+ expect ( thumbContainer . style . transform ) . toContain ( 'translateX(-30%)' ) ;
969
+
970
+ testComponent . dir = 'rtl' ;
971
+ fixture . detectChanges ( ) ;
972
+
973
+ expect ( thumbContainer . style . transform ) . toContain ( 'translateX(-70%)' ) ;
974
+ } ) ;
975
+
961
976
it ( 'should increment inverted slider by 1 on right arrow pressed' , ( ) => {
962
977
testComponent . invert = true ;
963
978
fixture . detectChanges ( ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import {HammerInput} from '../core';
38
38
import { FocusOrigin , FocusOriginMonitor } from '../core/style/focus-origin-monitor' ;
39
39
import { CanDisable , mixinDisabled } from '../core/common-behaviors/disabled' ;
40
40
import { CanColor , mixinColor } from '../core/common-behaviors/color' ;
41
+ import { Subscription } from 'rxjs/Subscription' ;
41
42
42
43
43
44
/**
@@ -276,6 +277,9 @@ export class MdSlider extends _MdSliderMixinBase
276
277
*/
277
278
_isActive : boolean = false ;
278
279
280
+ /** Subscription to changes in the user's direction. */
281
+ private _dirChange : Subscription | undefined ;
282
+
279
283
/**
280
284
* Whether the axis of the slider is inverted.
281
285
* (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
@@ -413,10 +417,18 @@ export class MdSlider extends _MdSliderMixinBase
413
417
this . _focusOriginMonitor
414
418
. monitor ( this . _elementRef . nativeElement , renderer , true )
415
419
. subscribe ( ( origin : FocusOrigin ) => this . _isActive = ! ! origin && origin !== 'keyboard' ) ;
420
+
421
+ if ( _dir ) {
422
+ this . _dirChange = _dir . change . subscribe ( ( ) => _changeDetectorRef . markForCheck ( ) ) ;
423
+ }
416
424
}
417
425
418
426
ngOnDestroy ( ) {
419
427
this . _focusOriginMonitor . stopMonitoring ( this . _elementRef . nativeElement ) ;
428
+
429
+ if ( this . _dirChange ) {
430
+ this . _dirChange . unsubscribe ( ) ;
431
+ }
420
432
}
421
433
422
434
_onMouseenter ( ) {
You can’t perform that action at this time.
0 commit comments