@@ -11,7 +11,7 @@ import {ViewportRuler} from '@angular/cdk/scrolling';
11
11
import { Direction } from '@angular/cdk/bidi' ;
12
12
import { normalizePassiveListenerOptions } from '@angular/cdk/platform' ;
13
13
import { coerceBooleanProperty , coerceElement } from '@angular/cdk/coercion' ;
14
- import { Subscription , Subject , Observable , Observer } from 'rxjs' ;
14
+ import { Subscription , Subject , Observable } from 'rxjs' ;
15
15
import { DropListRefInternal as DropListRef } from './drop-list-ref' ;
16
16
import { DragDropRegistry } from './drag-drop-registry' ;
17
17
import { extendStyles , toggleNativeDragInteractions } from './drag-styling' ;
@@ -130,12 +130,6 @@ export class DragRef<T = any> {
130
130
delta : { x : - 1 | 0 | 1 , y : - 1 | 0 | 1 } ;
131
131
} > ( ) ;
132
132
133
- /**
134
- * Amount of subscriptions to the move event. Used to avoid
135
- * hitting the zone if the consumer didn't subscribe to it.
136
- */
137
- private _moveEventSubscriptions = 0 ;
138
-
139
133
/** Keeps track of the direction in which the user is dragging along each axis. */
140
134
private _pointerDirectionDelta : { x : - 1 | 0 | 1 , y : - 1 | 0 | 1 } ;
141
135
@@ -260,15 +254,7 @@ export class DragRef<T = any> {
260
254
pointerPosition : { x : number , y : number } ;
261
255
event : MouseEvent | TouchEvent ;
262
256
delta : { x : - 1 | 0 | 1 , y : - 1 | 0 | 1 } ;
263
- } > = new Observable ( ( observer : Observer < any > ) => {
264
- const subscription = this . _moveEvents . subscribe ( observer ) ;
265
- this . _moveEventSubscriptions ++ ;
266
-
267
- return ( ) => {
268
- subscription . unsubscribe ( ) ;
269
- this . _moveEventSubscriptions -- ;
270
- } ;
271
- } ) ;
257
+ } > = this . _moveEvents . asObservable ( ) ;
272
258
273
259
/** Arbitrary data that can be attached to the drag item. */
274
260
data : T ;
@@ -563,7 +549,7 @@ export class DragRef<T = any> {
563
549
// Since this event gets fired for every pixel while dragging, we only
564
550
// want to fire it if the consumer opted into it. Also we have to
565
551
// re-enter the zone because we run all of the events on the outside.
566
- if ( this . _moveEventSubscriptions > 0 ) {
552
+ if ( this . _moveEvents . observers . length ) {
567
553
this . _ngZone . run ( ( ) => {
568
554
this . _moveEvents . next ( {
569
555
source : this ,
0 commit comments