-
Notifications
You must be signed in to change notification settings - Fork 221
Intersection observer api #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
*/ | ||
IntersectionObserver.prototype._getRootRect = function() { | ||
console.log('window.document: '+ window.document); | ||
console.log('document: '+ document); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document == null
🧐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click.js
Executes the following in the isolated world:
const visibleRatio = await new Promise(resolve => {
const observer = new IntersectionObserver(entries => {
resolve(entries[0].intersectionRatio);
observer.disconnect();
});
observer.observe(element);
});
return threshold === 1 ? visibleRatio === 1 : visibleRatio > threshold;
Note that opt_options
is not passed so this.root
is null meaning document
should be used as root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a lot of work to add natively to Zig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly wanted to learn and understand the polyfills, then solve the core issues.
With the current code it runs, but returns false instead of true for the click example.
So I think that is the right time to switch to a native Zig implementation.
I'll make a new PR to at least add loading the polyfill and make issues for the isolated page recreation and delay loading polyfills issues.
}); | ||
|
||
pub const CSSStyleDeclaration = struct { | ||
pub fn get_display(_: *CSSStyleDeclaration) []const u8 { | ||
return "anythingbutnotnone"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unset
is probably better (it has a real meaning here)
}); | ||
|
||
pub const CSSStyleDeclaration = struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe moved to the css
folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're too fast lol, I'm closing this PR
IntersectionObserver implementation using polyfill.
Additional apis needed to make this work.
This turns out to be a good test to make sure the IsolatedWorld works correctly.
A Zig native implementation is likely preferable in the future.