mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Allow multiple widgets for the same HTMLElement
This commit is contained in:
parent
f9bada6d0c
commit
2b6e1ff578
@ -1149,18 +1149,19 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
|
|||||||
|
|
||||||
this.intersectionObserver = new IntersectionObserver((widgets) => {
|
this.intersectionObserver = new IntersectionObserver((widgets) => {
|
||||||
widgets.forEach(({ isIntersecting, target, intersectionRatio }) => {
|
widgets.forEach(({ isIntersecting, target, intersectionRatio }) => {
|
||||||
const widget = this.skeletonList.find(w => w.getHTMLElementReference() == target);
|
this.skeletonList.forEach(widget => {
|
||||||
if (!widget) return;
|
if (widget.getHTMLElementReference() != target) return;
|
||||||
|
|
||||||
// old browsers do not have isIntersecting
|
// old browsers do not have isIntersecting
|
||||||
if (isIntersecting === undefined) {
|
if (isIntersecting === undefined) {
|
||||||
isIntersecting = intersectionRatio > 0;
|
isIntersecting = intersectionRatio > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.onScreen = isIntersecting;
|
widget.onScreen = isIntersecting;
|
||||||
if (isIntersecting) {
|
if (isIntersecting) {
|
||||||
widget.onScreenFunction(widget);
|
widget.onScreenFunction(widget);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}, { rootMargin: "30px 20px 30px 20px" });
|
}, { rootMargin: "30px 20px 30px 20px" });
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user