Increase accuracy of various Web APIs (#2946)

This commit is contained in:
daxpedda
2023-07-10 23:55:43 +02:00
committed by Kirill Chibisov
parent fab0f62c5a
commit 1d80005b91
9 changed files with 73 additions and 38 deletions

View File

@@ -12,19 +12,9 @@ impl IntersectionObserverHandle {
where
F: 'static + FnMut(bool),
{
let mut skip = true;
let closure = Closure::new(move |entries: Array| {
let entry: IntersectionObserverEntry = entries.get(0).unchecked_into();
let is_intersecting = entry.is_intersecting();
// skip first intersection
if skip && is_intersecting {
skip = false;
return;
}
callback(is_intersecting);
callback(entry.is_intersecting());
});
let observer = IntersectionObserver::new(closure.as_ref().unchecked_ref())
// we don't provide any `options`