turniquet is a new type of slider for jQuery. Instead of the typical horizontal slider, this slider is following a diagonal of a div. Sliding can occur in both direction (Up or down).
Tourniquet in french is not bandage. In general it's use to describe a turnstyle.
I replaced "tourn" which almost mean "turn" in french by "turn" and got the word "turniquet".
turniquet depends on jQuery (>= 1.10.0). Include them both in end of your HTML code:
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.turniquet.js" type="text/javascript"></script>
You must use an ordered list. And add a few line of CSS.
<style type="text/css">
.container {
position: relative;
height: 600px;
}
.turniquet {
position: relative;
margin:0;
}
.turniquet li {
position:absolute;
display:block;
width:350px;
height:350px;
list-style: none;
}
</style>
<div class="container">
<ul class="turniquet">
<li><img src="http://placehold.it/350&text=Slide1" /></li>
<li><img src="http://placehold.it/350&text=Slide2" /></li>
<li><img src="http://placehold.it/350&text=Slide3" /></li>
</ul>
</div>
then in your code do:
$('.turniquet').turniquet();
This will activate the silder.
{
// These are the defaults.
zindex : 500,
direction: 'up',
reverseZindex: false,
duration: 200,
easing: 'swing',
animateOnCLick: true,
triggerUp: null,
triggerDown: null,
complete: null,
before: null,
after: null,
loop: true,
validate: function(){return true;}
}
Define what zindex the first slide should use.
Define what zindex the other slide should use +1 or -1.
Define the default direction.
Define the duration of the animation
Define what type of animation to use. This are default jQuery animation. As today there is only "easing" and "linear".
Will animate slider when clicking on any slider
Selector to use as a trigger to make the slide slide up.
$('.turniquet').turniquet({
triggerUp: '.myTriggerClass'
});
Same as "triggerUp" but for the other direction
Method to call after animation complete
Method to call before animation each slide.
$('.turniquet').turniquet({
before: function(index, element){
//element is the current element
}
});
Same a "before" but for after
Will authorize looping or not.
Method which will be called before each swipe.
$('.turniquet').turniquet({
validate: function(index){
if(index == 0 // && itsValid){
return true;
}
return false;
}
});
All code licensed under the "MIT License":http://www.opensource.org/licenses/mit-license.php. In other words you are basically free to do whatever you want. Just don't remove my name from the source.
- Added ability to disable animation's loop
- Added ability to validate slide before swiping
- Added ability to reverse zindex
- First version of turniquet