javascript - mouse drag issue with rxjs
问题描述
I am looking at the mouse drag example from learnrxjs.io
, it looks pretty straight forward to me.
const mousedown$ = fromEvent(document, 'mousedown')
const mouseup$ = fromEvent(document, 'mouseup');
const mousemove$ = fromEvent(document, 'mousemove');
// after mousedown, take position until mouse up
mousedown$.pipe(
mergeMap(_ => {
return mousemove$.pipe(
map((e: any) => ({
x: e.clientX,
y: e.clientY
})),
// complete inner observable on mouseup event
takeUntil(mouseup$)
)
})
)
.subscribe(console.log);
However i can't figure out why the console is logging every second once I do the following:
- Press the mouse
- Keep it pressed and don't move it
Here is the stackblitz
Can someone help me clarify this? Thanks!
Edit: It seems to happen in Chrome version 79.0.3945.117 (Official Build) (64-bit)
. I cannot reproduce the issue in Firefox 72.0.1 (64-bit)
...
Edit 2: finally ending up restarting my machine and the issue is gone...
解决方案
推荐阅读
- c++ - 为什么 C++ 标准库中没有 SIMD 功能?
- celery - 谁在 celery 中等待 apply_async(countdown=10)
- c++ - 用于创建对象的堆或堆栈?
- javascript - reactjs登录后如何创建受保护的路由
- javascript - 当社区添加了 URL 时,JSForce describeGlobal 不起作用
- listview - xamarin 表单列表视图多选
- database - 主主数据库架构中的主节点是共享相同的数据集还是拥有自己独特的数据集?
- azure - 没有 www 的 URL 重定向到不同的页面
- unity3d - Unity PlayerPrefs 在 WebGL 中构建游戏后加载不同的数据
- python - python selenium 如何选择聊天中的最后一条消息