[英]How to prevent scrolling on like events using Socket.io? - Angular 7
When Array Element Update Use Socket.io then Page Scrolled Down in Angular 7. Please Tell How to stop page scroll down in like event.当数组元素更新使用 Socket.io 然后页面在 Angular 中向下滚动 7. 请告诉如何在类似事件中停止页面向下滚动。
this.socket.on(discussion.id, (reponse: any) =>
{
for (const [index, discussion] of this.discussionList.entries()) {
if (reponse.data.id == discussion.id)
{
reponse.data.displayComment = discussion.displayComment;
this.discussionList[index] = reponse.data;
console.log('Updated');
break; //Stop this loop, we found it!
}
console.log('finding....');
}
});
You basically updating some random item in array which is rendered as list.您基本上更新了数组中呈现为列表的一些随机项。 Of course your list will change content and new content can appear in current view.当然,您的列表会更改内容,新内容会出现在当前视图中。 Its how html in browser works - nothing related to "Angular 7".它是 html 在浏览器中的工作方式——与“Angular 7”无关。 Scroll not changed - changed what is visible in current scroll.滚动未更改 - 更改了当前滚动中可见的内容。
What you want to do is plain JS madness:你想要做的是简单的 JS 疯狂:
It is messy, heavy for performance but thats a price of changing random piece of html on page.它很乱,性能很重,但这是改变页面上随机 html 的代价。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.