Skip to content

Inject autoload intersectionobserver #969

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/core/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ const create_from_string = (string) => {
return document.createRange().createContextualFragment(string.trim());
};

/**
* Find the closest scrollable container.
*
* @param {Node} el - A DOM node to start the search.
* @param {String} [direction=xy] - The scroll direction we want to search for.
* "x" for a scroll direction in x-position,
* "y" for a scroll direction in y-position,
* "xy" for a both directions.
*
* @returns {(Node|null)} - The DOM Node which can act as a scrollable container or "null".
*/
const find_scroll_container = (el) => {
//
// These all have some sort of ``:scrollable`` support:
// jquery-ext
// pat inject
// pat-scroll
// pat-scroll-box
// bumper
};

const dom = {
toNodeArray: toNodeArray,
querySelectorAllAndMe: querySelectorAllAndMe,
Expand All @@ -157,6 +178,7 @@ const dom = {
create_from_string: create_from_string,
add_event_listener: events.add_event_listener, // BBB export. TODO: Remove in an upcoming version.
remove_event_listener: events.remove_event_listener, // BBB export. TODO: Remove in an upcoming version.
find_scroll_container: find_scroll_container,
};

export default dom;
2 changes: 1 addition & 1 deletion src/pat/inject/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ const inject = {
};
$el.click(trigger);

// Use case 1: a (heigh-constrained) scrollable parent
// Use case 1: a (height-constrained) scrollable parent
if ($scrollable.length) {
// if scrollable parent and visible -> trigger it
// we only look at the closest scrollable parent, no nesting
Expand Down