Skip to content

Commit

Permalink
add a new opt to component-view to be able to configure the Intersect…
Browse files Browse the repository at this point in the history
…ionObserver threshold
  • Loading branch information
gyss committed Jan 23, 2025
1 parent 4d21116 commit b995f94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/o-tracking/src/javascript/events/component-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const decorateEventData = (eventData, viewedEl, opts) => {
* Listen for view events.
*
* @alias view#init
* @param {object} opts - To set custom category[String], selector[String], getContextData[Function]
* @param {object} opts - To set custom category[String], selector[String], getContextData[Function], intersectionObserverThreshold[Any]
* @returns {undefined}
*/
const init = (opts = {}) => {
Expand Down Expand Up @@ -75,7 +75,7 @@ const init = (opts = {}) => {
});
}

const observer = new IntersectionObserver(onChange, { threshold: [ 1.0 ] });
const observer = new IntersectionObserver(onChange, { threshold: opts.intersectionObserverThreshold || [ 1.0 ] });

elementsToTrack.forEach(el => observer.observe(el));
};
Expand Down

0 comments on commit b995f94

Please sign in to comment.