iosscripts / iosslider

iosslider is a jQuery plugin which allows you to integrate a customizable, cross-browser content slider into your web presence. Designed for use as a content slider, website banner, or image gallery.
http://iosscripts.com/iosslider
432 stars 103 forks source link

Enable paging with hash tags option #98

Open iosscripts opened 12 years ago

iosscripts commented 12 years ago

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

ColColonCleaner commented 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?

iosscripts commented 12 years ago

@cobeliga, sorry I should have added that. This would have an option to - at least - to turn it on/off.

PapaSimons commented 12 years ago

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