Increase accuracy of various Web APIs (#2946)
This commit is contained in:
parent
db8de03142
commit
c4d70d75c1
9 changed files with 73 additions and 38 deletions
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue