Basic HTML5 slider.
This project is maintained by jsvgoncalves
A simple slider built with Javascript and powered by jQuery.
You can customize the slider as long as it stays horizontal and you pass along all the necessary parameters to the init()
method. Future versions may support different orientations and make the slider web responsive.
$ git clone https://github.com/jsvgoncalves/margin-slider.git
js/marginslider.js
and css/marginslider.css
to your project.marginslider
, marginslider_container
, left-arrow
and right-arrow
appropriately or configure the MarginSlider.init()
.MarginSlider.init( options );
(I recommend only calling it after all the DOM has loaded, you can do so with $(window).load(function(){ .. });
.Use the following format to pass parameters to MarginSlider:
MarginSlider.init({slider: $('myslider'),
no_visible: 3,
step: 2
});
To configure your MarginSlider the following parameters are available. Additionally, I encourage you to take a look at the code and tweak it to your liking.
The marginslider container, used to wrap around the slider and create an invisible area. Example:
MarginSlider.init( { slider_container: $( 'marginslider_container' ) } );
The container for the slider, this element should have child elements that will contain the images. Example:
MarginSlider.init( { slider: $( 'myslider' ) } );
The slider_child elements. marginslider should have child elements that will contain the images. Example:
MarginSlider.init( { slider_child: $( '.marginslider li' ) } );
The button to navigate left could be anywhere on the page, it doesnt matter, it can even be the whole page <body>
.
Example:
MarginSlider.init( { bt_left: $( '.left-arrow' ) } );
The button to navigate right. Example:
MarginSlider.init( { bt_right: $( '.right-arrow' ) } );
The number of visible elements, note that if the number of visible elements it's greater than the number of total elements the slider will note move. Example:
MarginSlider.init( { no_visible: 5 } );
How many elements to advance each time the user navigates. Example:
MarginSlider.init( { step: 3 } );
The spacing between each image on the slider. Example:
MarginSlider.init( { img_margin : 15 } );
This project is maintained by João Gonçalves (@jsvgoncalves). Special thanks to João Lopes (@lopis).
Having trouble with MarginSlider? Check out the documentation at https://github.com/jsvgoncalves/margin-slider or open a new issue and I’ll help you sort it out.