*Using Fontawesome
Put in document`s head this:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://raw.githubusercontent.com/MuffinKing-jpeg/js-slider/master/muffin-slider/slider.js" defer></script>In case if you want to use touch or keyboard controls add few more rows:
Keyboard control:
<script src="https://raw.githubusercontent.com/MuffinKing-jpeg/js-slider/master/muffin-slider/slider-key-controls.js" defer></script>Touch controls:
<script src="https://raw.githubusercontent.com/MuffinKing-jpeg/js-slider/master/muffin-slider/slider-touch-controls.js" defer></script>I can't figure out how to make it working just with adding two files , so...
<script src="https://raw.githubusercontent.com/MuffinKing-jpeg/js-slider/master/muffin-slider/slider-all-controls.js" defer></script>Or you can install it localy by downloading folder muffin-slider.
Now make parrent container for your slider with id #slider.
<div id="slider"></div>Drop you images to ./assets/img/ (Path can be chaged)
Put in you JavaScript file
initSlider({
slides: [
'array.gif',
'of.webp',
'image.png',
'names.jpeg',
]
})-
slidesIt's necessary. Must be an array of images names. If you put only one slide, it will works like a still image.
Value:['array','of','strings'] -
imgPathPath to images folder, useless ifabsolutePath: true.
Default:./assets/img/
Value:'string' -
absolutePathChanging images path to absolute. Using full pathhttps://picsum.photos/1920/1080instead of local./assets/img/
Default:false
Values:true || false -
parentSelectorCSS selector of your slider container
Default:'#slider'
Value:'.css #selector' -
controlsChanging visibility of controls elements
Default:true
Values:true || 'prev-next' || 'play-pause' || false -
indicatorsChanging visibility of indicators elements
Default:true
Values:true || false -
localStyleUnlocks ability to use another path to style
Default:false
Values:true || false -
stylePathPath to style file. Useless iflocalStyle: false
Default:'./assets/css/slider.css'
Value:'./path/to/your.css' -
firstSlideNumber of first displayed slide. Counting starts from 0!
Default:0
Value:number -
intervalTime duration between slides inms.
Default:5000
Value:number -
isPlayingChanges default state of slider. Paused or not.
Default:true
Values:true || false -
inverseLOOK AT ME, I`M GOING BACKWARDS
Defautl:false
Values:true || false
Example:
initSlider({
imgPath: './assets/slider/img/',
absolutePath: false,
parentSelector: '.container',
controls: true,
indicators: true,
localStyle: false,
stylePath: './assets/slider/css/slider.css',
firstSlide: 0,
interval: 5000,
isPlaying: true,
inverse: false,
slides: [
'img_car_in_chinatown.png',
'img_car.png',
],
});You can use custom colors by changing CSS variables.
:root {
--dark-slider-10: rgba(0, 0, 0, 0.1);
--color-slider-primary: #ffffff;
--bg-color-slider-primary: #252525;
--accent-slider: #dc143c;
}Fork or clone repository. After that use in work directory npm install command. For live updating use gulp watch. For build with babel polyfils use gulp build