Open iosscripts opened 12 years ago
You need to make this optional. My application relies on specific URLs. I do not want the slider to be changing my page URLs, in any way, at least i want to be able to turn that feature off. thanks :)
Also what is the case for having multiple sliders on screen? which will a hash link to?
@cobeliga, sorry I should have added that. This would have an option to - at least - to turn it on/off.
To those who want to do a simple hash change on slide change, I implemented the hash change with the following functions
var curha = "0"; var loaderInt = null;
$(document).ready(function(){
//slider
setSlider();
hashchange();
//check for hash change on interval
setInterval(function() {
if(curha != getHa()) {
hashchange();
}
}, 500);
});
function getHa(){ return window.location.hash.replace("#",""); }
function hashchange(){ var ha = getHa(); if (curha != ha && !isNaN(ha) && ha != ""){ $('.iosSlider').iosSlider('goToSlide', (parseInt(ha) + 1)); } else { ha = "0"; } curha = ha; }
function setSlider(){
$('.iosSlider').iosSlider({
snapToChildren: true,
desktopClickDrag: true,
keyboardControls: true,
onSlideComplete: function (args) {
if (!isNaN(args.currentSlideNumber)){
curha = args.currentSlideNumber;
window.location.hash = "#" + curha;
}
}
});
}
This will also enable the ability to go to a page + a specific slide following the correct # + naming convention. onSlideChange will also update the page #.