|
| 1 | +# Dics: Definitive Image Comparison Slider |
| 2 | + |
| 3 | +<a target="_blank" href="http://codictados.com"><img |
| 4 | +src="http://codictados.com/wp-content/uploads/2015/07/logo263x781.png" |
| 5 | +alt="Codictados"></a> |
| 6 | + |
| 7 | +Made by <a href="http://abelcabezaroman.com/" target="_blank">Abel Cabeza Román</a>, a |
| 8 | +<a href="http://codictados.com">Codictados</a> developer. |
| 9 | + |
| 10 | +## DEMO |
| 11 | + |
| 12 | +<a target="_blank" |
| 13 | +href="http://codictados.com/portfolio/definitive-image-comparison-slider-demo/">See |
| 14 | +examples</a> |
| 15 | + |
| 16 | +## Description |
| 17 | + |
| 18 | +Light Vanilla Javascript library (8kb minified) to compare multiples images with |
| 19 | +sliders. Also, you can add text and filters to your images. |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +Download the library. |
| 24 | + |
| 25 | +```bash |
| 26 | +npm i dics |
| 27 | +``` |
| 28 | + |
| 29 | +And import it to your project. |
| 30 | + |
| 31 | +```html |
| 32 | +<link rel="stylesheet" href="dics.css"> |
| 33 | +<script src="dics.js"></script> |
| 34 | +``` |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +You only have to create a container and add your images. You can add all |
| 39 | +images you want!! If you add the `alt` attribute, you will view the text |
| 40 | +in the image comparison. |
| 41 | + |
| 42 | +```html |
| 43 | +<div class="b-dics"> |
| 44 | + <img src="01.jpg"> |
| 45 | + <img src="02.jpg" alt="Japan Yellow"> |
| 46 | + <img src="03.jpg" alt="Japan Orange"> |
| 47 | + <img src="04.jpg" alt="Japan Black & White"> |
| 48 | +</div> |
| 49 | +``` |
| 50 | + |
| 51 | +Finally, you need to initialize the component like this. |
| 52 | + |
| 53 | +```javascript |
| 54 | +new Dics({ |
| 55 | + container: document.querySelector('.b-dics') |
| 56 | +}); |
| 57 | +``` |
| 58 | + |
| 59 | +Or this. |
| 60 | + |
| 61 | +```javascript |
| 62 | +new Dics({ |
| 63 | + container: document.querySelectorAll('.b-dics'), |
| 64 | + linesOrientation: 'vertical', |
| 65 | + textPosition: 'left', |
| 66 | + arrayBackgroundColorText: ['#000000', '#FFFFFF'], |
| 67 | + arrayColorText: ['#FFFFFF', '#000000'], |
| 68 | + linesColor: 'rgb(0,0,0)' |
| 69 | +}); |
| 70 | +``` |
| 71 | + |
| 72 | +## Options |
| 73 | + |
| 74 | +If you want you can include different options. |
| 75 | + |
| 76 | +| Option | Description | Example | |
| 77 | +| --- | --- | --- | |
| 78 | +| container | **REQUIRED**: HTML container | `document.querySelector('.b-dics')` | |
| 79 | +| filters | Array of CSS string filters |`['blur(3px)', 'grayscale(1)', 'sepia(1)', 'saturate(3)']` | |
| 80 | +| hideTexts | Show text only when you hover the image container |`true`,`false`| |
| 81 | +| textPosition | Set the prefer text position |`'center'`,`'top'`, `'right'`, `'bottom'`, `'left'` | |
| 82 | +| linesOrientation | Change the orientation of lines |`'horizontal'`,`'vertical'` | |
| 83 | +| rotate | Rotate the image container (not too useful but it's a beatiful effect. String of rotate CSS rule) |`'45deg'`| |
| 84 | +| arrayBackgroundColorText | Change the bacground-color of sections texts with an array |`['#000000', '#FFFFFF']`| |
| 85 | +| arrayColorText | Change the color of texts with an array |`['#FFFFFF', '#000000']`| |
| 86 | +| linesColor | Change the lines and arrows color |`'rgb(0,0,0)'`| |
| 87 | + |
| 88 | + |
| 89 | +## Contributing |
| 90 | +Pull requests are welcome. For major changes, please open an issue first |
| 91 | +to discuss what you would like to change. |
0 commit comments