我有这段代码,我试图在其中捕获所有拖动事件。此代码仅适用于第一次拖动和停止不适用于连续拖动。
是因为 takeUntil 取消了外部 observable 吗?我怎样才能使代码工作。
const { Observable, fromEvent } = rxjs;
const { takeUntil, switchMap } = rxjs.operators;
const mouseups = fromEvent(document.querySelector('.container'),
'mouseup');
const mousedowns = fromEvent(document.querySelector('.container'),
'mousedown');
const mousemoves = fromEvent(document.querySelector('.container'),
'mousemove');
const source = mousedowns.pipe(
switchMap(e => mousemoves),
takeUntil(mouseups)
);
source.subscribe(e => console.log(e));