66<br >
77[ ![ npm Version] ( https://badgen.net/npm/v/scroll-snap-slider )] ( https://www.npmjs.com/package/scroll-snap-slider )
88[ ![ Dependency Count: 0] ( https://badgen.net/bundlephobia/dependency-count/scroll-snap-slider )] ( https://bundlephobia.com/result?p=scroll-snap-slider )
9- [ ![ minzippped Size] ( https://badgen.net/bundlephobia/minzip/scroll-snap-slider )] ( https://bundlephobia.com/result?p=scroll-snap-slider )
9+ [ ![ minzipped Size] ( https://badgen.net/bundlephobia/minzip/scroll-snap-slider )] ( https://bundlephobia.com/result?p=scroll-snap-slider )
1010
1111Mostly CSS slider with great performance.
1212
@@ -54,9 +54,9 @@ the entrypoint changing from 'ScrollSnapSlider' to 'index'.
5454| index | 348 B | 143 B |
5555| ScrollSnapAutoplay | 1479 B | 559 B |
5656| ScrollSnapDraggable | 2459 B | 772 B |
57- | ScrollSnapLoop | 1840 B | 623 B |
57+ | ScrollSnapLoop | 1849 B | 615 B |
5858| ScrollSnapPlugin | 70 B | 110 B |
59- | ScrollSnapSlider | 2361 B | 811 B |
59+ | ScrollSnapSlider | 2361 B | 809 B |
6060
6161## Restrictions
6262
@@ -77,9 +77,7 @@ yarn add scroll-snap-slider
7777
7878## Usage
7979
80- HTML + CSS are enough for a working slider. You can use IDs and anchor links to create navigation buttons.
81-
82- The ES6 class provided in this package augments the slider with a few events and methods.
80+ The class provided in this package augments a slider with a few events and methods.
8381
8482### Markup
8583
@@ -111,7 +109,7 @@ You can add whatever markup inside the slides.
111109
112110### Additional Styles
113111
114- Prevents page navigation on horizontal scrolling, i.E. on MacOS .
112+ Prevents page navigation on horizontal scrolling, i.E. on macOS .
115113[ \[ Support tables\] ] ( https://caniuse.com/?search=overscroll-behavior )
116114
117115``` css
@@ -138,44 +136,44 @@ events and exposes a few methods, with which you can enhance your slider's behav
138136** Default behaviour:**
139137
140138``` javascript
141- import {ScrollSnapSlider } from ' scroll-snap-slider'
139+ import { ScrollSnapSlider } from ' scroll-snap-slider'
142140
143141const element = document .querySelector (' .example-slider' )
144- const slider = new ScrollSnapSlider ({element})
142+ const slider = new ScrollSnapSlider ({ element })
145143
146144slider .addEventListener (' slide-start' , function (event ) {
147- console .info (` Started sliding towards slide ${ event .detail } .` )
145+ console .info (` Started sliding towards slide ${ event .detail } .` )
148146})
149147
150148slider .addEventListener (' slide-pass' , function (event ) {
151- console .info (` Passing slide ${ event .detail } .` )
149+ console .info (` Passing slide ${ event .detail } .` )
152150})
153151
154152slider .addEventListener (' slide-stop' , function (event ) {
155- console .info (` Stopped sliding at slide ${ event .detail } .` )
153+ console .info (` Stopped sliding at slide ${ event .detail } .` )
156154})
157155```
158156
159157** Advanced config:**
160158
161159``` javascript
162- import {ScrollSnapSlider } from ' scroll-snap-slider'
160+ import { ScrollSnapSlider } from ' scroll-snap-slider'
163161
164162// Do not automatically attach scroll listener
165163const slider = new ScrollSnapSlider ({
166- element: document .querySelector (' .example-slider' ),
167- scrollTimeout: 50 , // Sets a shorter timeout to detect scroll end
168- roundingMethod: Math .round , // Dispatch 'slide-pass' events around the center of each slide
169- // roundingMethod: Math.ceil, // Dispatch 'slide-pass' events as soon as the next one is visible
170- // roundingMethod: Math.floor, // Dispatch 'slide-pass' events only when the next one is fully visible
171- sizingMethod (slider ) {
172-
173- // with padding
174- return slider .element .firstElementChild .offsetWidth
175-
176- // without padding
177- // return slider.element.firstElementChild.clientWidth
178- }
164+ element: document .querySelector (' .example-slider' ),
165+ scrollTimeout: 50 , // Sets a shorter timeout to detect scroll end
166+ roundingMethod: Math .round , // Dispatch 'slide-pass' events around the center of each slide
167+ // roundingMethod: Math.ceil, // Dispatch 'slide-pass' events as soon as the next one is visible
168+ // roundingMethod: Math.floor, // Dispatch 'slide-pass' events only when the next one is fully visible
169+ sizingMethod (slider ) {
170+
171+ // with padding
172+ return slider .element .firstElementChild .offsetWidth
173+
174+ // without padding
175+ // return slider.element.firstElementChild.clientWidth
176+ }
179177})
180178```
181179
@@ -191,14 +189,14 @@ You can add one or multiple of the available Plugins:
191189Additional Note: The ` ScrollSnapDraggable ` and ` ScrollSnapLoop ` ** do not** work well together.
192190
193191``` javascript
194- import {ScrollSnapSlider } from ' scroll-snap-slider/src/ScrollSnapSlider.js'
195- import {ScrollSnapAutoplay } from ' scroll-snap-slider/src/ScrollSnapAutoplay.js'
196- import {ScrollSnapLoop } from ' scroll-snap-slider/src/ScrollSnapLoop.js'
192+ import { ScrollSnapSlider } from ' scroll-snap-slider/src/ScrollSnapSlider.js'
193+ import { ScrollSnapAutoplay } from ' scroll-snap-slider/src/ScrollSnapAutoplay.js'
194+ import { ScrollSnapLoop } from ' scroll-snap-slider/src/ScrollSnapLoop.js'
197195
198196const element = document .querySelector (' .example-slider' )
199- const slider = new ScrollSnapSlider ({element}).with ([
200- new ScrollSnapAutoplay (1200 ),
201- new ScrollSnapLoop
197+ const slider = new ScrollSnapSlider ({ element }).with ([
198+ new ScrollSnapAutoplay (1200 ),
199+ new ScrollSnapLoop
202200])
203201```
204202
@@ -207,48 +205,48 @@ Creating your own plugin:
207205``` javascript
208206export class CustomPlugin extends ScrollSnapPlugin {
209207
210- /**
211- * Pass any config here
212- * @param {*} config
213- */
214- constructor (config ) {
215- super ()
216-
217- this .config = config
218- }
219-
220- /**
221- * Chose a unique plugin name. If you need multiple instances of the same plugin on a slider, each must return a unique id.
222- * @return {String}
223- */
224- get id () {
225- return ' lubba-wubba-dub-dub'
226- }
227-
228- /**
229- * Attach listeners, fetch DOM things, save reference to the slider
230- * @param {ScrollSnapSlider} slider
231- * @override
232- */
233- enable (slider ) {
234- // TODO method stub
235- }
236-
237- /**
238- * Free resources, remove listeners, ...
239- * @override
240- */
241- disable () {
242- // TODO method stub
243- }
208+ /**
209+ * Pass any config here
210+ * @param {*} config
211+ */
212+ constructor (config ) {
213+ super ()
214+
215+ this .config = config
216+ }
217+
218+ /**
219+ * Chose a unique plugin name. If you need multiple instances of the same plugin on a slider, each must return a unique id.
220+ * @return {String}
221+ */
222+ get id () {
223+ return ' lubba-wubba-dub-dub'
224+ }
225+
226+ /**
227+ * Attach listeners, fetch DOM things, save reference to the slider
228+ * @param {ScrollSnapSlider} slider
229+ * @override
230+ */
231+ enable (slider ) {
232+ // TODO method stub
233+ }
234+
235+ /**
236+ * Free resources, remove listeners, ...
237+ * @override
238+ */
239+ disable () {
240+ // TODO method stub
241+ }
244242}
245243```
246244
247245## API
248246
249247| Method | Description |
250248| --------------------------------| -----------------------------------------------------------------------------|
251- | ` slideTo(index: Number): void ` | Scrolls to slide with at ` index ` . |
249+ | ` slideTo(index: Number): void ` | Scrolls to slide at ` index ` . |
252250| ` addEventListener(...) ` | This is a shortcut for ` slider.element.addEventListener(...) ` . |
253251| ` removeEventListener(...) ` | This is a shortcut for ` slider.element.removeEventListener(...) ` . |
254252| ` attachEventListeners() ` | Enables the JS behaviour of this plugin. This is called in the constructor. |
0 commit comments