@@ -11,7 +11,7 @@ import {ViewportRuler} from '@angular/cdk/scrolling';
1111import { Direction } from '@angular/cdk/bidi' ;
1212import { normalizePassiveListenerOptions } from '@angular/cdk/platform' ;
1313import { coerceBooleanProperty , coerceElement } from '@angular/cdk/coercion' ;
14- import { Subscription , Subject , Observable , Observer } from 'rxjs' ;
14+ import { Subscription , Subject , Observable } from 'rxjs' ;
1515import { DropListRefInternal as DropListRef } from './drop-list-ref' ;
1616import { DragDropRegistry } from './drag-drop-registry' ;
1717import { extendStyles , toggleNativeDragInteractions } from './drag-styling' ;
@@ -130,12 +130,6 @@ export class DragRef<T = any> {
130130 delta : { x : - 1 | 0 | 1 , y : - 1 | 0 | 1 } ;
131131 } > ( ) ;
132132
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-
139133 /** Keeps track of the direction in which the user is dragging along each axis. */
140134 private _pointerDirectionDelta : { x : - 1 | 0 | 1 , y : - 1 | 0 | 1 } ;
141135
@@ -260,15 +254,7 @@ export class DragRef<T = any> {
260254 pointerPosition : { x : number , y : number } ;
261255 event : MouseEvent | TouchEvent ;
262256 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 ( ) ;
272258
273259 /** Arbitrary data that can be attached to the drag item. */
274260 data : T ;
@@ -563,7 +549,7 @@ export class DragRef<T = any> {
563549 // Since this event gets fired for every pixel while dragging, we only
564550 // want to fire it if the consumer opted into it. Also we have to
565551 // 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 ) {
567553 this . _ngZone . run ( ( ) => {
568554 this . _moveEvents . next ( {
569555 source : this ,
0 commit comments