...
This commit is contained in:
16
Presentation/HushianWebApp/wwwroot/scroll-visibility.js
Normal file
16
Presentation/HushianWebApp/wwwroot/scroll-visibility.js
Normal file
@@ -0,0 +1,16 @@
|
||||
window.observeVisibility = (dotNetRef) => {
|
||||
const elements = document.querySelectorAll(".chat-bubble[data-id]");
|
||||
const observer = new IntersectionObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
const id = entry.target.getAttribute("data-id");
|
||||
dotNetRef.invokeMethodAsync("MarkAsRead", parseInt(id));
|
||||
observer.unobserve(entry.target); // دیگه دوباره نخونه
|
||||
}
|
||||
});
|
||||
}, {
|
||||
threshold: 0.6 // 60٪ از پیام دیده بشه
|
||||
});
|
||||
|
||||
elements.forEach(el => observer.observe(el));
|
||||
};
|
Reference in New Issue
Block a user