@@ -18,7 +18,6 @@ import {
18
18
AfterViewInit ,
19
19
Attribute ,
20
20
ChangeDetectionStrategy ,
21
- ChangeDetectorRef ,
22
21
Component ,
23
22
ElementRef ,
24
23
EventEmitter ,
@@ -37,7 +36,7 @@ import {
37
36
import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
38
37
import { ThemePalette } from '@angular/material/core' ;
39
38
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
40
- import { MDCSliderAdapter , MDCSliderFoundation } from '@material/slider' ;
39
+ import { MDCSliderAdapter , MDCSliderFoundation , Thumb } from '@material/slider' ;
41
40
import { Subscription } from 'rxjs' ;
42
41
43
42
/**
@@ -53,10 +52,14 @@ const MIN_AUTO_TICK_SEPARATION = 30;
53
52
*/
54
53
const TICK_MARKER_SIZE = 2 ;
55
54
55
+ // TODO: disabled until we implement the new MDC slider.
56
56
/** Event options used to bind passive listeners. */
57
+ // tslint:disable-next-line:no-unused-variable
57
58
const passiveListenerOptions = normalizePassiveListenerOptions ( { passive : true } ) ;
58
59
60
+ // TODO: disabled until we implement the new MDC slider.
59
61
/** Event options used to bind active listeners. */
62
+ // tslint:disable-next-line:no-unused-variable
60
63
const activeListenerOptions = normalizePassiveListenerOptions ( { passive : false } ) ;
61
64
62
65
/**
@@ -222,87 +225,35 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
222
225
223
226
/** Adapter for the MDC slider foundation. */
224
227
private _sliderAdapter : MDCSliderAdapter = {
225
- hasClass : ( className ) => this . _elementRef . nativeElement . classList . contains ( className ) ,
226
- addClass : ( className ) => this . _elementRef . nativeElement . classList . add ( className ) ,
227
- removeClass : ( className ) => this . _elementRef . nativeElement . classList . remove ( className ) ,
228
- getAttribute : ( name ) => this . _elementRef . nativeElement . getAttribute ( name ) ,
229
- setAttribute : ( name , value ) => this . _elementRef . nativeElement . setAttribute ( name , value ) ,
230
- removeAttribute : ( name ) => this . _elementRef . nativeElement . removeAttribute ( name ) ,
231
- computeBoundingRect : ( ) => this . _elementRef . nativeElement . getBoundingClientRect ( ) ,
232
- getTabIndex : ( ) => this . _elementRef . nativeElement . tabIndex ,
233
- registerInteractionHandler : ( evtType , handler ) =>
234
- // Interaction event handlers (which handle keyboard interaction) cannot be passive
235
- // as they will prevent the default behavior. Additionally we can't run these event
236
- // handlers outside of the Angular zone because we rely on the events to cause the
237
- // component tree to be re-checked.
238
- // TODO: take in the event listener options from the adapter once MDC supports it.
239
- this . _elementRef . nativeElement . addEventListener ( evtType , handler , activeListenerOptions ) ,
240
- deregisterInteractionHandler : ( evtType , handler ) =>
241
- this . _elementRef . nativeElement . removeEventListener ( evtType , handler ) ,
242
- registerThumbContainerInteractionHandler : ( evtType , handler ) => {
243
- // The thumb container interaction handlers are currently just used for transition
244
- // events which don't need to run in the Angular zone.
245
- this . _ngZone . runOutsideAngular ( ( ) => {
246
- this . _thumbContainer . nativeElement
247
- . addEventListener ( evtType , handler , passiveListenerOptions ) ;
248
- } ) ;
249
- } ,
250
- deregisterThumbContainerInteractionHandler : ( evtType , handler ) => {
251
- this . _thumbContainer . nativeElement
252
- . removeEventListener ( evtType , handler , passiveListenerOptions ) ;
253
- } ,
254
- registerBodyInteractionHandler : ( evtType , handler ) =>
255
- // Body event handlers (which handle thumb sliding) cannot be passive as they will
256
- // prevent the default behavior. Additionally we can't run these event handlers
257
- // outside of the Angular zone because we rely on the events to cause the component
258
- // tree to be re-checked.
259
- document . body . addEventListener ( evtType , handler ) ,
260
- deregisterBodyInteractionHandler : ( evtType , handler ) =>
261
- document . body . removeEventListener ( evtType , handler ) ,
262
- registerResizeHandler : ( handler ) => {
263
- // The resize handler is currently responsible for detecting slider dimension
264
- // changes and therefore doesn't cause a value change that needs to be propagated.
265
- this . _ngZone . runOutsideAngular ( ( ) => window . addEventListener ( 'resize' , handler ) ) ;
266
- } ,
267
- deregisterResizeHandler : ( handler ) => window . removeEventListener ( 'resize' , handler ) ,
268
- notifyInput :
269
- ( ) => {
270
- const newValue = this . _foundation . getValue ( ) ;
271
- // MDC currently fires the input event multiple times.
272
- // TODO(devversion): remove this check once the input notifications are fixed.
273
- if ( newValue !== this . value ) {
274
- this . value = newValue ;
275
- this . input . emit ( this . _createChangeEvent ( newValue ) ) ;
276
- }
277
- } ,
278
- notifyChange :
279
- ( ) => {
280
- // TODO(devversion): bug in MDC where only the "change" event is emitted if a keypress
281
- // updated the value. Material and native range sliders also emit an input event.
282
- // Usually we sync the "value" in the "input" event, but as a workaround we now sync
283
- // the value in the "change" event.
284
- this . value = this . _foundation . getValue ( ) ;
285
- this . _emitChangeEvent ( this . value ! ) ;
286
- } ,
287
- setThumbContainerStyleProperty :
288
- ( propertyName , value ) => {
289
- this . _thumbContainer . nativeElement . style . setProperty ( propertyName , value ) ;
290
- } ,
291
- setTrackStyleProperty :
292
- ( propertyName , value ) => {
293
- this . _track . nativeElement . style . setProperty ( propertyName , value ) ;
294
- } ,
295
- setMarkerValue :
296
- ( ) => {
297
- // Mark the component for check as the thumb label needs to be re-rendered.
298
- this . _changeDetectorRef . markForCheck ( ) ;
299
- } ,
300
- setTrackMarkers :
301
- ( step , max , min ) => {
302
- this . _trackMarker . nativeElement . style . setProperty (
303
- 'background' , this . _getTrackMarkersBackground ( min , max , step ) ) ;
304
- } ,
305
- isRTL : ( ) => this . _isRtl ( ) ,
228
+ hasClass : ( _className : string ) => false ,
229
+ addClass : ( _className : string ) => { } ,
230
+ removeClass : ( _className : string ) => { } ,
231
+ getAttribute : ( _attribute : string ) => null ,
232
+ addThumbClass : ( _className : string , _thumb : Thumb ) => { } ,
233
+ removeThumbClass : ( _className : string , _thumb : Thumb ) => { } ,
234
+ getThumbAttribute : ( _attribute : string , _thumb : Thumb ) => null ,
235
+ setThumbAttribute : ( _attribute : string , _value : string , _thumb : Thumb ) => { } ,
236
+ getThumbKnobWidth : ( _thumb : Thumb ) => 0 ,
237
+ isThumbFocused : ( _thumb : Thumb ) => false ,
238
+ focusThumb : ( _thumb : Thumb ) => { } ,
239
+ getThumbBoundingClientRect : ( _thumb : Thumb ) => null ! ,
240
+ getBoundingClientRect : ( ) => null ! ,
241
+ isRTL : ( ) => false ,
242
+ setThumbStyleProperty : ( _propertyName : string , _value : string , _thumb : Thumb ) => { } ,
243
+ setTrackActiveStyleProperty : ( _propertyName : string , _value : string ) => { } ,
244
+ setValueIndicatorText : ( _value : number , _thumb : Thumb ) => { } ,
245
+ updateTickMarks : ( ) => { } ,
246
+ setPointerCapture : ( _pointerId : number ) => { } ,
247
+ emitChangeEvent : ( _value : number , _thumb : Thumb ) => { } ,
248
+ emitInputEvent : ( _value : number , _thumb : Thumb ) => { } ,
249
+ registerEventHandler : ( ) => { } ,
250
+ deregisterEventHandler : ( ) => { } ,
251
+ registerThumbEventHandler : ( ) => { } ,
252
+ deregisterThumbEventHandler : ( ) => { } ,
253
+ registerBodyEventHandler : ( ) => { } ,
254
+ deregisterBodyEventHandler : ( ) => { } ,
255
+ registerWindowEventHandler : ( ) => { } ,
256
+ deregisterWindowEventHandler : ( ) => { } ,
306
257
} ;
307
258
308
259
/** Instance of the MDC slider foundation for this slider. */
@@ -327,7 +278,6 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
327
278
328
279
constructor (
329
280
private _elementRef : ElementRef < HTMLElement > ,
330
- private _changeDetectorRef : ChangeDetectorRef ,
331
281
private _ngZone : NgZone ,
332
282
private _platform : Platform ,
333
283
@Optional ( ) private _dir : Directionality ,
@@ -354,7 +304,7 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
354
304
// The MDC slider foundation accesses DOM globals, so we cannot initialize the
355
305
// foundation on the server. The foundation would be needed to move the thumb
356
306
// to the proper position and to render the ticks.
357
- this . _foundation . init ( ) ;
307
+ // this._foundation.init();
358
308
359
309
// The standard Angular Material slider is always using discrete values. We always
360
310
// want to enable discrete values and support ticks, but want to still provide
@@ -437,14 +387,18 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
437
387
return event ;
438
388
}
439
389
390
+ // TODO: disabled until we implement the new MDC slider.
440
391
/** Emits a change event and notifies the control value accessor. */
392
+ // tslint:disable-next-line:no-unused-variable
441
393
private _emitChangeEvent ( newValue : number ) {
442
394
this . _controlValueAccessorChangeFn ( newValue ) ;
443
395
this . valueChange . emit ( newValue ) ;
444
396
this . change . emit ( this . _createChangeEvent ( newValue ) ) ;
445
397
}
446
398
399
+ // TODO: disabled until we implement the new MDC slider.
447
400
/** Computes the CSS background value for the track markers (aka ticks). */
401
+ // tslint:disable-next-line:no-unused-variable
448
402
private _getTrackMarkersBackground ( min : number , max : number , step : number ) {
449
403
if ( ! this . tickInterval ) {
450
404
return '' ;
@@ -476,32 +430,39 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
476
430
// the markers dynamically. This is a workaround until we can get a public API for it. See:
477
431
// https://github.com/material-components/material-components-web/issues/5020
478
432
( this . _foundation as any ) . hasTrackMarker_ = this . tickInterval !== 0 ;
479
- this . _foundation . setupTrackMarker ( ) ;
433
+
434
+ // TODO: disabled until we implement the new MDC slider.
435
+ // this._foundation.setupTrackMarker();
480
436
}
481
437
482
438
/** Syncs the "step" input value with the MDC foundation. */
483
439
private _syncStep ( ) {
484
- this . _foundation . setStep ( this . step ) ;
440
+ // TODO: disabled until we implement the new MDC slider.
441
+ // this._foundation.setStep(this.step);
485
442
}
486
443
487
444
/** Syncs the "max" input value with the MDC foundation. */
488
445
private _syncMax ( ) {
489
- this . _foundation . setMax ( this . max ) ;
446
+ // TODO: disabled until we implement the new MDC slider.
447
+ // this._foundation.setMax(this.max);
490
448
}
491
449
492
450
/** Syncs the "min" input value with the MDC foundation. */
493
451
private _syncMin ( ) {
494
- this . _foundation . setMin ( this . min ) ;
452
+ // TODO: disabled until we implement the new MDC slider.
453
+ // this._foundation.setMin(this.min);
495
454
}
496
455
497
456
/** Syncs the "value" input binding with the MDC foundation. */
498
457
private _syncValue ( ) {
499
- this . _foundation . setValue ( this . value ! ) ;
458
+ // TODO: disabled until we implement the new MDC slider.
459
+ // this._foundation.setValue(this.value!);
500
460
}
501
461
502
462
/** Syncs the "disabled" input value with the MDC foundation. */
503
463
private _syncDisabled ( ) {
504
- this . _foundation . setDisabled ( this . disabled ) ;
464
+ // TODO: disabled until we implement the new MDC slider.
465
+ // this._foundation.setDisabled(this.disabled);
505
466
}
506
467
507
468
/** Whether the slider is displayed in RTL-mode. */
0 commit comments