@@ -117,8 +117,9 @@ export class MdSlider implements ControlValueAccessor {
117117
118118 private _controlValueAccessorChangeFn : ( value : any ) => void = ( ) => { } ;
119119
120- /** The last value for which a change event was emitted. */
121- private _lastEmittedValue : number = null ;
120+ /** The last values for which a change or input event was emitted. */
121+ private _lastChangeValue : number = null ;
122+ private _lastInputValue : number = null ;
122123
123124 /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
124125 onTouched : ( ) => any = ( ) => { } ;
@@ -301,6 +302,9 @@ export class MdSlider implements ControlValueAccessor {
301302 /** Event emitted when the slider value has changed. */
302303 @Output ( ) change = new EventEmitter < MdSliderChange > ( ) ;
303304
305+ /** Event emitted when the slider thumb moves. */
306+ @Output ( ) input = new EventEmitter < MdSliderChange > ( ) ;
307+
304308 constructor ( @Optional ( ) private _dir : Dir , elementRef : ElementRef ) {
305309 this . _renderer = new SliderRenderer ( elementRef ) ;
306310 }
@@ -325,6 +329,9 @@ export class MdSlider implements ControlValueAccessor {
325329 this . _isSliding = false ;
326330 this . _renderer . addFocus ( ) ;
327331 this . _updateValueFromPosition ( { x : event . clientX , y : event . clientY } ) ;
332+
333+ /* Emits a change and input event if the value changed. */
334+ this . _emitInputEvent ( ) ;
328335 this . _emitValueIfChanged ( ) ;
329336 }
330337
@@ -336,6 +343,9 @@ export class MdSlider implements ControlValueAccessor {
336343 // Prevent the slide from selecting anything else.
337344 event . preventDefault ( ) ;
338345 this . _updateValueFromPosition ( { x : event . center . x , y : event . center . y } ) ;
346+
347+ // Native range elements always emit `input` events when the value changed while sliding.
348+ this . _emitInputEvent ( ) ;
339349 }
340350
341351 _onSlideStart ( event : HammerInput ) {
@@ -439,16 +449,23 @@ export class MdSlider implements ControlValueAccessor {
439449
440450 /** Emits a change event if the current value is different from the last emitted value. */
441451 private _emitValueIfChanged ( ) {
442- if ( this . value != this . _lastEmittedValue ) {
443- let event = new MdSliderChange ( ) ;
444- event . source = this ;
445- event . value = this . value ;
446- this . _lastEmittedValue = this . value ;
452+ if ( this . value != this . _lastChangeValue ) {
453+ let event = this . _createChangeEvent ( ) ;
454+ this . _lastChangeValue = this . value ;
447455 this . _controlValueAccessorChangeFn ( this . value ) ;
448456 this . change . emit ( event ) ;
449457 }
450458 }
451459
460+ /** Emits an input event when the current value is different from the last emitted value. */
461+ private _emitInputEvent ( ) {
462+ if ( this . value != this . _lastInputValue ) {
463+ let event = this . _createChangeEvent ( ) ;
464+ this . _lastInputValue = this . value ;
465+ this . input . emit ( event ) ;
466+ }
467+ }
468+
452469 /** Updates the amount of space between ticks as a percentage of the width of the slider. */
453470 private _updateTickIntervalPercent ( ) {
454471 if ( ! this . tickInterval ) {
@@ -466,6 +483,16 @@ export class MdSlider implements ControlValueAccessor {
466483 }
467484 }
468485
486+ /** Creates a slider change object from the specified value. */
487+ private _createChangeEvent ( value = this . value ) : MdSliderChange {
488+ let event = new MdSliderChange ( ) ;
489+
490+ event . source = this ;
491+ event . value = value ;
492+
493+ return event ;
494+ }
495+
469496 /** Calculates the percentage of the slider that a value is. */
470497 private _calculatePercentage ( value : number ) {
471498 return ( value - this . min ) / ( this . max - this . min ) ;
0 commit comments