Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 28acb29

Browse files
author
Richard GrosJean
committed
adds option for custom child selector
1 parent 782d83d commit 28acb29

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pageable.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
freeScroll: false,
135135
slideshow: false,
136136
infinite: false,
137+
childSelector: '[data-anchor]',
137138
events: {
138139
wheel: true,
139140
mouse: true,
@@ -163,12 +164,12 @@
163164
this.container.appendChild(frag);
164165
}
165166

166-
// search for child nodes with the [data-anchor] attribute
167-
this.pages = this.container.querySelectorAll("[data-anchor]");
167+
// search for child nodes using the child selector
168+
this.pages = this.container.querySelectorAll(this.config.childSelector);
168169

169170
// none found
170171
if (!this.pages.length) {
171-
return console.error("Pageable:", "No child nodes with the [data-anchor] attribute could be found.");
172+
return console.error("Pageable:", "No child nodes matching the selector " + this.config.childSelector + " could be found.");
172173
}
173174

174175
this.horizontal = this.config.orientation === "horizontal";
@@ -724,7 +725,7 @@
724725
}
725726

726727
// prevent firing if not on a page
727-
if (!evt.target.closest("[data-anchor]")) {
728+
if (!evt.target.closest(this.childSelector)) {
728729
return false;
729730
}
730731

0 commit comments

Comments
 (0)