I am making a custom slider (photo slider) when you click you go to the next slide. I arrived to pretty descent result BUT
When arriving at one end (right & left) of the slider I can’t figure how to make it transition as if it was an infinite slider, mine just go over all the slide up to the other end.
I thought of making a duplicate slider to transition but can’t make it work.
Do you have any suggestions?
Many thanks
var countslider = 0;
var nombreslide = 3;
var nbslidecachee = nombreslide - 1;
var limitslider = nbslidecachee * 100;
function sliderright() {
if (countslider == -limitslider) {
jQuery(".container-slider").css({"transform":"translateX(0vw)"});
countslider = 0;
}
else {
var translatevalue = countslider - 100;
jQuery(".container-slider").css({"transform":"translateX( " + translatevalue + "vw)"});
countslider = translatevalue;
}
}
jQuery('#btnslider-right').on('click', function(){sliderright()});
$(document).on("pagecreate",function(){
$("#bloc-divi").on("swipeleft",function(){sliderright()
});
});
function sliderleft() {
if (countslider == 0) {
var translatevalue = -limitslider;
jQuery(".container-slider").css({"transform":"translateX( " + translatevalue + "vw)"});
countslider = translatevalue;
}
else {
var translatevalue = countslider + 100;
jQuery(".container-slider").css({"transform":"translateX( " + translatevalue + "vw)"});
countslider = translatevalue;
}
}
jQuery('#btnslider-left').on('click', function(){sliderleft()});
jQuery('#btnslider-left').on('click', function(){console.log(countslider);});
$(document).on("pagecreate",function(){
$("#bloc-divi").on("swiperight",function(){sliderleft()
});
});
#bloc-divi{
overflow-x: hidden !important;
overflow-y: hidden !important;
}
.container-slider {
position: absolute;
width: 100vw;
height: 100vh;
background-color: grey;
transition: 0.7s ease;
}
#photo1 {
width: 50%;
height: 50%;
margin-right: auto;
margin-left: auto;
margin-top: 10%;
background-color: blue;
}
#photo2 {
width: 50%;
height: 50%;
margin-right: auto;
margin-left: auto;
margin-top: 10%;
background-color: purple;
}
#photo3 {
width: 50%;
height: 50%;
margin-right: auto;
margin-left: auto;
margin-top: 10%;
background-color: green;
}
#photo3bis {
width: 50%;
height: 50%;
margin-right: auto;
margin-left: auto;
margin-top: 10%;
background-color: green;
}
.legende1 {
width: 50%;
height: 10%;
margin-right: auto;
margin-left: auto;
margin-top: 5%;
background-color: red;
}
.legende2 {
width: 50%;
height: 10%;
margin-right: auto;
margin-left: auto;
margin-top: 5%;
background-color: red;
}
#slider-2 {
left: 100%;
}
#slider-3 {
left: 200%;
}
#slider-3bis {
left: -100%;
}
.btn-sliderS{
height: 40px;
width: 30px;
position: absolute;
margin-top: calc((100vh - 40px)/2);
background-color: yellow;
}
.btn-sliderS:hover {
cursor: pointer;
}
#btnslider-left{
left: 0;
}
#btnslider-right{
right: 0;
}
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<div id="bloc-divi">
<div id="slider-1" class="container-slider">
<div id="photo1">
</div>
<div class="legende1">
</div>
<div class="legende2">
</div>
</div>
<div id="slider-2" class="container-slider">
<div id="photo2">
</div>
<div class="legende1">
</div>
<div class="legende2">
</div>
</div>
<div id="slider-3" class="container-slider">
<div id="photo3">
</div>
<div class="legende1">
</div>
<div class="legende2">
</div>
</div>
<div id="slider-3bis" class="container-slider">
<div id="photo3bis">
</div>
<div class="legende1">
</div>
<div class="legende2">
</div>
</div>
<div id="btnslider-left" class="btn-sliderS"><
</div>
<div id="btnslider-right" class="btn-sliderS">>
</div>
</div>
amoxilin – amoxicillin 500 mg dosage amoxil 500 mg generic name
viagra vs cialis vs vardenafil – buy real vardenafil vardenafil 10 pills
generic cialis for daily use – tadalafil cost uk where to get cialis online
amoxicillin price at walmart – amoxicillin pill buy amoxicillin 500 mg online mexico
modafinil reviews – provgils.com provigil dosage
generic azithromycin 250mg – azithromycine zithromax otc
clomid tablets – clomid for sale clomid without prescription
real viagra online usa – buy cheap viagra canada sildenafil 130mg otc
cialis 10mg – rx cialis online tadalafil 5 mg
prednisone 20 mg tablet – prednisone 60 mg tablet buy prednisone online uk
where to buy amoxicillin 500 mg – amoxil no prescription amoxil 500mg
pay for assignment – buy essays cheap academia writing
cost of doxycycline 40 mg – doxycycline sale uk prednisolone 5mg tablets buy
ivermectin 500mg – iverpillcin ivermectin 12 mg
buy prednisone online usa – buy prednisone without prescription prednisone 20mg pills
prednisone 200 mg – prednisone 40mg without prescription prednisone canadian
accutane 2009 – buy cheap accutane uk accutane medicine buy
jackpot party casino – free slot games no download online casinos real money
buy erectile dysfunction medications – plusedpl male erection pills
synthroid order – oral tadalafil 5mg tadalafil 20mg uk
buy sildalis – metformin online buy cheap glucophage 500mg
buy ampicillin 250mg for sale – purchase plaquenil generic order hydroxychloroquine 200mg
plaquenil 200mg cheap – buy hydroxychloroquine 200mg generic cheap plaquenil
where to buy tadalafil on line where to get tadalafil
generic cialis tadalafil tadalafil daily online
tadalafil online with out prescription https://cialisicp.com/
what is tadalafil generic tadalafil from uk
tadalafil dosage where to buy cialis without prescription
buy cialis tadalafil goodrx
tadalafil brands tadalafil brands
tadalafil drug https://extratadalafill.com/
where to get tadalafil side effects for tadalafil
cialis without prescription tadalafil cialis
ivermectin pills http://www.ivermectinusd.com/
buy ivermectin generic ivermectin 6mg
ivermectin price buy ivermectin in canada
https://www.ivermectinusd.com/ stromectol 3 mg tablet
ivermectin pharmacy https://www.ivermectinusd.com/