├── _redirects ├── .gitignore ├── test ├── test.css ├── index.html ├── qunit │ ├── qunit.css │ └── qunit.js └── tests.js ├── demo ├── imgs │ ├── bike.jpg │ ├── cows.jpg │ ├── large.jpg │ ├── monkey.jpg │ ├── monks.jpg │ ├── bike-thmb.jpg │ ├── cows-thmb.jpg │ ├── interior.jpg │ ├── large-thmb.jpg │ ├── monkey-thmb.jpg │ ├── monks-thmb.jpg │ └── interior-thmb.jpg ├── docs.css └── index.html ├── dist ├── snapper-init.js ├── snapper.css └── snapper.js ├── src ├── snapper-init.js ├── snapper.scss ├── snapper.js └── lib │ └── intersection-observer.js ├── package.json ├── LICENSE ├── Gruntfile.js └── README.md /_redirects: -------------------------------------------------------------------------------- 1 | / /demo -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules -------------------------------------------------------------------------------- /test/test.css: -------------------------------------------------------------------------------- 1 | /* 2 | Styles for testing snapper 3 | */ 4 | -------------------------------------------------------------------------------- /demo/imgs/bike.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/bike.jpg -------------------------------------------------------------------------------- /demo/imgs/cows.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/cows.jpg -------------------------------------------------------------------------------- /demo/imgs/large.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/large.jpg -------------------------------------------------------------------------------- /demo/imgs/monkey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/monkey.jpg -------------------------------------------------------------------------------- /demo/imgs/monks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/monks.jpg -------------------------------------------------------------------------------- /demo/imgs/bike-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/bike-thmb.jpg -------------------------------------------------------------------------------- /demo/imgs/cows-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/cows-thmb.jpg -------------------------------------------------------------------------------- /demo/imgs/interior.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/interior.jpg -------------------------------------------------------------------------------- /demo/imgs/large-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/large-thmb.jpg -------------------------------------------------------------------------------- /demo/imgs/monkey-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/monkey-thmb.jpg -------------------------------------------------------------------------------- /demo/imgs/monks-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/monks-thmb.jpg -------------------------------------------------------------------------------- /demo/imgs/interior-thmb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/filamentgroup/snapper/HEAD/demo/imgs/interior-thmb.jpg -------------------------------------------------------------------------------- /dist/snapper-init.js: -------------------------------------------------------------------------------- 1 | /* snapper css snap points carousel */ 2 | ;(function( w, $ ){ 3 | // auto-init on enhance 4 | $( document ).bind( "enhance", function( e ){ 5 | $( ".snapper", e.target ).add( e.target ).filter( ".snapper" ).snapper(); 6 | }); 7 | }( this, jQuery )); -------------------------------------------------------------------------------- /src/snapper-init.js: -------------------------------------------------------------------------------- 1 | /* snapper css snap points carousel */ 2 | ;(function( w, $ ){ 3 | // auto-init on enhance 4 | $( document ).bind( "enhance", function( e ){ 5 | $( ".snapper", e.target ).add( e.target ).filter( ".snapper" ).snapper(); 6 | }); 7 | }( this, jQuery )); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fg-snapper", 3 | "version": "4.0.0-2", 4 | "description": "A CSS Snap-Points based carousel (and lightweight polyfill)", 5 | "author": { 6 | "name": "Scott Jehl, Filament Group, Inc.", 7 | "url": "http://filamentgroup.com" 8 | }, 9 | "main": "dist/snapper.js", 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/filamentgroup/snapper.git" 13 | }, 14 | "keywords": [ 15 | "CSS", 16 | "snap points" 17 | ], 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/filamentgroup/snapper/issues" 21 | }, 22 | "devDependencies": { 23 | "grunt": "^1.0.4", 24 | "grunt-cli": "^1.3.2", 25 | "grunt-contrib-copy": "^1.0.0", 26 | "grunt-contrib-qunit": "^3.1.0", 27 | "grunt-contrib-watch": "^0.6.1", 28 | "grunt-sass": "^3.1.0", 29 | "matchdep": "^2.0.0", 30 | "node-sass": "^4.13.1" 31 | }, 32 | "dependencies": { 33 | "jquery": "3.4.1", 34 | "intersection-observer": "0.7.0" 35 | }, 36 | "scripts": { 37 | "test": "grunt", 38 | "build": "grunt" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Filament Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
33 |
36 |
39 |
30 |
33 |
36 |
39 |
29 | A snapper carousel with some thumbnail links.
57 | Thumbnails are just regular links to a slide's ID attribute. The scrollbar is cropped from sight using the optional snapper_pane_crop div (only recommended when thumbnails or next/prev navigation is in play).
64 |
67 |
70 |
73 |
76 |
79 |
82 |
85 |
88 |
91 |
94 |
97 |
100 |
103 |
106 | A snapper carousel with next/prev links automatically added through the addition of a data-snapper-nextprev attribute.
Also, this demo includes an optional ".snapper_nextprev_contain" div, which the next/prev nav will append to if present. This element wraps the scroll pane and allows you to precisely position arrows based on the height of the pane, without the thumbnails or dot nav.
135 |
142 |
145 |
148 |
151 |
154 |
157 | This example plays nicely with CSS breakpoints to show a different number of slides depending on the viewport size. To use breakpoints in this way, for back compat, be sure to include Snap Points that correspond to the item widths. See CSS for this example
188 | 189 |
195 |
198 |
201 |
204 |
207 |
210 |
219 | /* breakpoints example */
220 | @media (min-width: 30em){
221 | .snapper_item {
222 | width: 50%;
223 | }
224 | .snapper_pane {
225 | scroll-snap-points-x: repeat(50%);
226 | }
227 | }
228 | @media (min-width: 50em){
229 | .snapper_item {
230 | width: 33.333%;
231 | }
232 | .snapper_pane {
233 | scroll-snap-points-x: repeat(33.33333%);
234 | }
235 | }
236 |
237 |
238 |
239 |
240 |
241 | By setting the data-snapper-autoplay attribute on the class="snapper" element to a natural number value snapper will automatically rotate through the images. The value represents a the millisecond delay between item transitions. In the example below we have data-snapper-autoplay="2000"
You can also set the attribute on snapper_item elements to get individual timing.
244 |
250 |
253 |
256 |
259 |
262 |
265 |
299 |
302 |
305 |
308 |
311 |
314 |
323 | .revealexample .snapper_item {
324 | width: 45%;
325 | }
326 | .revealexample .snapper_pane {
327 | scroll-snap-points-x: repeat(45%);
328 | }
329 |
330 |
331 |
332 | A snapper carousel with data-snapper-loop will append items to either end as needed so the scroll is infinite. This is recommended for 1-slide-at-a-time carousels.
342 |
345 |
348 |
351 |
354 |
357 |