mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Merge pull request #732 from lightpanda-io/intersection_observer_threshold
IntersectionObserver's threshold option should be an union
This commit is contained in:
@@ -51,7 +51,7 @@ pub const IntersectionObserver = struct {
|
|||||||
var options = IntersectionObserverOptions{
|
var options = IntersectionObserverOptions{
|
||||||
.root = parser.documentToNode(parser.documentHTMLToDocument(page.window.document)),
|
.root = parser.documentToNode(parser.documentHTMLToDocument(page.window.document)),
|
||||||
.rootMargin = "0px 0px 0px 0px",
|
.rootMargin = "0px 0px 0px 0px",
|
||||||
.threshold = &.{0.0},
|
.threshold = .{ .single = 0.0 },
|
||||||
};
|
};
|
||||||
if (options_) |*o| {
|
if (options_) |*o| {
|
||||||
if (o.root) |root| {
|
if (o.root) |root| {
|
||||||
@@ -107,7 +107,12 @@ pub const IntersectionObserver = struct {
|
|||||||
const IntersectionObserverOptions = struct {
|
const IntersectionObserverOptions = struct {
|
||||||
root: ?*parser.Node, // Element or Document
|
root: ?*parser.Node, // Element or Document
|
||||||
rootMargin: ?[]const u8,
|
rootMargin: ?[]const u8,
|
||||||
threshold: ?[]const f32,
|
threshold: ?Threshold,
|
||||||
|
|
||||||
|
const Threshold = union(enum) {
|
||||||
|
single: f32,
|
||||||
|
list: []const f32,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry
|
// https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry
|
||||||
|
|||||||
Reference in New Issue
Block a user