Increase accuracy of various Web APIs (#2946)

This commit is contained in:
daxpedda 2023-07-10 23:55:43 +02:00 committed by GitHub
parent db8de03142
commit c4d70d75c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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`