This repository was archived by the owner on Dec 26, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 134134 freeScroll : false ,
135135 slideshow : false ,
136136 infinite : false ,
137+ childSelector : '[data-anchor]' ,
137138 events : {
138139 wheel : true ,
139140 mouse : true ,
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" ;
175176
176177 this . anchors = [ ] ;
177178
178179 this . pages . forEach ( function ( page , i ) {
179- var clean = page . dataset . anchor . replace ( / \s + / , "-" ) . toLowerCase ( ) ;
180+ if ( typeof page . dataset . anchor !== 'undefined' ) {
181+ var clean = page . dataset . anchor . replace ( / \s + / , "-" ) . toLowerCase ( ) ;
182+ } else {
183+ var clean = page . classList . value . replace ( / \s + / , "-" ) . toLowerCase ( ) ;
184+ }
180185 if ( page . id !== clean ) {
181186 page . id = clean ;
182187 }
724729 }
725730
726731 // prevent firing if not on a page
727- if ( ! evt . target . closest ( "[data-anchor]" ) ) {
732+ if ( ! evt . target . closest ( this . childSelector ) ) {
728733 return false ;
729734 }
730735
You can’t perform that action at this time.
0 commit comments