Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Enable paging with hash tags option #98

Open
iosscripts opened this Issue Sep 4, 2012 · 3 comments

Comments

Projects
None yet
3 participants
@ghost
Contributor

ghost commented Sep 4, 2012

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 #.

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?

@ghost
Contributor

ghost commented Sep 4, 2012

@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;
}
}
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment