From 812f8352f513c31f2b91f42e4b4329f3ee2b7f4a Mon Sep 17 00:00:00 2001 From: MattMo Date: Mon, 2 Sep 2024 16:19:40 -0700 Subject: [PATCH] Fixed an issue where not all the results of the intersection observer were being checked. --- ignite-template.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ignite-template.js b/ignite-template.js index 5eb2594..565a7e3 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -1511,10 +1511,15 @@ class IgniteTemplate { //Setup a intersect observer if needed if (this._intersectObserverCallback && this._intersectObserverCallback.length > 0) { this._intersectObserver = new IntersectionObserver(results => { - if (results[0].isIntersecting) { - for (var i = 0; i < this._intersectObserverCallback.length; i++) { - if (this._intersectObserverCallback[i]) { - this._intersectObserverCallback[i](results[0]); + if (results) { + for (var i = 0; i < results.length; i++) { + if (results[i].isIntersecting && results[i].target == this.element) { + for (var i2 = 0; i2 < this._intersectObserverCallback.length; i2++) { + if (this._intersectObserverCallback[i2]) { + this._intersectObserverCallback[i2](results[i]); + } + } + break; } } }