diff --git a/CHANGELOG.md b/CHANGELOG.md index 8361bfd..ab1dce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Ideal Image Slider Changelog +Version 1.2.2 - 2014.09.12 +-------------------------- + * [Fixed] Links z-index bug + Version 1.2.1 - 2014.09.12 -------------------------- * [Fixed] Single slide bug diff --git a/README.md b/README.md index cbe3233..063fff6 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ And, as an example, here are some features that *should not* be in the core and ## Demos * [Standard Slider](http://gilbitron.github.io/Ideal-Image-Slider/demo/standard-slider.html) +* [With Links](http://gilbitron.github.io/Ideal-Image-Slider/demo/links.html) * [Using the API](http://gilbitron.github.io/Ideal-Image-Slider/demo/using-the-api.html) * [Using Events](http://gilbitron.github.io/Ideal-Image-Slider/demo/using-events.html) * [Multiple Sliders](http://gilbitron.github.io/Ideal-Image-Slider/demo/multiple-sliders.html) @@ -79,6 +80,7 @@ like this: Minimum required attributes Use data-src for on-demand loading Use data-src-2x for HiDPI devices + Links work too ... ``` diff --git a/ideal-image-slider.css b/ideal-image-slider.css index 3337450..ed762c6 100644 --- a/ideal-image-slider.css +++ b/ideal-image-slider.css @@ -1,5 +1,5 @@ /* - * Ideal Image Slider v1.2.1 + * Ideal Image Slider v1.2.2 * * By Gilbert Pellegrom * http://gilbert.pellegrom.me diff --git a/ideal-image-slider.js b/ideal-image-slider.js index 10fde03..c5f37b0 100644 --- a/ideal-image-slider.js +++ b/ideal-image-slider.js @@ -1,5 +1,5 @@ /* - * Ideal Image Slider v1.2.1 + * Ideal Image Slider v1.2.2 * * By Gilbert Pellegrom * http://gilbert.pellegrom.me diff --git a/ideal-image-slider.min.js b/ideal-image-slider.min.js index cc694ac..81d0fea 100644 --- a/ideal-image-slider.min.js +++ b/ideal-image-slider.min.js @@ -1,2 +1,2 @@ -/*! Ideal Image Slider v1.2.1 */ +/*! Ideal Image Slider v1.2.2 */ var IdealImageSlider=function(){"use strict";var a=function(a){a=a||{};for(var b=1;b1?!0:window.matchMedia&&window.matchMedia(a).matches?!0:!1},h=function(a,b,c){a.style.webkitTransitionDuration=a.style.MozTransitionDuration=a.style.msTransitionDuration=a.style.OTransitionDuration=a.style.transitionDuration=c+"ms",a.style.webkitTransform=a.style.MozTransform=a.style.msTransform=a.style.OTransform="translateX("+b+"px)"},i=function(a){a.style.removeProperty("-webkit-transition-duration"),a.style.removeProperty("-moz-transition-duration"),a.style.removeProperty("-ms-transition-duration"),a.style.removeProperty("-o-transition-duration"),a.style.removeProperty("transition-duration"),a.style.removeProperty("-webkit-transform"),a.style.removeProperty("-moz-transform"),a.style.removeProperty("-ms-transform"),a.style.removeProperty("-o-transform"),a.style.removeProperty("transform")},j={vars:{start:{},delta:{},isScrolling:void 0,direction:null},start:function(a){if(!b(this._attributes.container,this.settings.classes.animating)){var d=a.touches[0];j.vars.start={x:d.pageX,y:d.pageY,time:+new Date},j.vars.delta={},j.vars.isScrolling=void 0,j.vars.direction=null,this.stop(),this.settings.beforeChange.apply(this),c(this._attributes.container,this.settings.classes.touching)}},move:function(a){if(!b(this._attributes.container,this.settings.classes.animating)&&!(a.touches.length>1||a.scale&&1!==a.scale)){var c=a.touches[0];j.vars.delta={x:c.pageX-j.vars.start.x,y:c.pageY-j.vars.start.y},"undefined"==typeof j.vars.isScrolling&&(j.vars.isScrolling=!!(j.vars.isScrolling||Math.abs(j.vars.delta.x)20||Math.abs(j.vars.delta.x)>this._attributes.currentSlide.offsetWidth/2,f=j.vars.delta.x<0?"next":"previous",g=this.settings.transitionDuration?this.settings.transitionDuration/2:0;j.vars.isScrolling||(e?(j.vars.direction=f,"next"==j.vars.direction?(h(this._attributes.currentSlide,-this._attributes.currentSlide.offsetWidth,g),h(this._attributes.nextSlide,0,g)):(h(this._attributes.previousSlide,0,g),h(this._attributes.currentSlide,this._attributes.currentSlide.offsetWidth,g)),setTimeout(j.transitionEnd.bind(this),g)):"next"==f?(h(this._attributes.currentSlide,0,g),h(this._attributes.nextSlide,this._attributes.currentSlide.offsetWidth,g)):(h(this._attributes.previousSlide,-this._attributes.previousSlide.offsetWidth,g),h(this._attributes.currentSlide,0,g)),g&&(c(this._attributes.container,this.settings.classes.animating),setTimeout(function(){d(this._attributes.container,this.settings.classes.animating)}.bind(this),g)))}},transitionEnd:function(){if(j.vars.direction){i(this._attributes.previousSlide),i(this._attributes.currentSlide),i(this._attributes.nextSlide),d(this._attributes.container,this.settings.classes.touching),d(this._attributes.previousSlide,this.settings.classes.previousSlide),d(this._attributes.currentSlide,this.settings.classes.currentSlide),d(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var a=this._attributes.slides,b=a.indexOf(this._attributes.currentSlide);"next"==j.vars.direction?(this._attributes.previousSlide=this._attributes.currentSlide,this._attributes.currentSlide=a[b+1],this._attributes.nextSlide=a[b+2],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.nextSlide?(this._attributes.currentSlide=a[0],this._attributes.nextSlide=a[1]):"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=a[0]),f(this._attributes.nextSlide)):(this._attributes.nextSlide=this._attributes.currentSlide,this._attributes.previousSlide=a[b-2],this._attributes.currentSlide=a[b-1],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.previousSlide?(this._attributes.currentSlide=a[a.length-1],this._attributes.previousSlide=a[a.length-2]):"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=a[a.length-1]),f(this._attributes.previousSlide)),c(this._attributes.previousSlide,this.settings.classes.previousSlide),c(this._attributes.currentSlide,this.settings.classes.currentSlide),c(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),this.settings.afterChange.apply(this)}}},k=function(d){this.settings={selector:"",height:400,interval:4e3,transitionDuration:700,effect:"slide",disableNav:!1,keyboardNav:!0,previousNavSelector:"",nextNavSelector:"",classes:{container:"ideal-image-slider",slide:"iis-slide",previousSlide:"iis-previous-slide",currentSlide:"iis-current-slide",nextSlide:"iis-next-slide",previousNav:"iis-previous-nav",nextNav:"iis-next-nav",animating:"iis-is-animating",touchEnabled:"iis-touch-enabled",touching:"iis-is-touching",directionPrevious:"iis-direction-previous",directionNext:"iis-direction-next"},onInit:function(){},onStart:function(){},onStop:function(){},onDestroy:function(){},beforeChange:function(){},afterChange:function(){}},"string"==typeof d?this.settings.selector=d:"object"==typeof d&&a(this.settings,d);var h=document.querySelector(this.settings.selector);if(!h)return null;var i=e(h.children),k=[];h.innerHTML="",Array.prototype.forEach.call(i,function(b){if(b instanceof HTMLImageElement||b instanceof HTMLAnchorElement){var d=document.createElement("a"),e="",f="";if(b instanceof HTMLAnchorElement){e=b.getAttribute("href"),f=b.getAttribute("target");var i=b.querySelector("img");if(null===i)return;b=i}"undefined"!=typeof b.dataset?(a(d.dataset,b.dataset),d.dataset.src=b.dataset.src?b.dataset.src:b.src,g()&&b.dataset["src-2x"]&&(d.dataset.src=b.dataset["src-2x"])):b.getAttribute("data-src")?d.setAttribute("data-src",b.getAttribute("data-src")):d.setAttribute("data-src",b.getAttribute("src")),e&&d.setAttribute("href",e),f&&d.setAttribute("target",f),b.getAttribute("className")&&c(d,b.getAttribute("className")),b.getAttribute("id")&&d.setAttribute("id",b.id),b.getAttribute("alt")&&(d.innerHTML=b.getAttribute("alt")),d.setAttribute("role","tabpanel"),d.setAttribute("aria-hidden","true"),d.style.cssText+="-webkit-transition-duration:"+this.settings.transitionDuration+"ms;-moz-transition-duration:"+this.settings.transitionDuration+"ms;-o-transition-duration:"+this.settings.transitionDuration+"ms;transition-duration:"+this.settings.transitionDuration+"ms;",h.appendChild(d),k.push(d)}}.bind(this));var l=k;if(l.length<=1)return h.innerHTML="",Array.prototype.forEach.call(i,function(a){h.appendChild(a)}),null;if(!this.settings.disableNav){var m,n;this.settings.previousNavSelector?m=document.querySelector(this.settings.previousNavSelector):(m=document.createElement("a"),h.appendChild(m)),this.settings.nextNavSelector?n=document.querySelector(this.settings.nextNavSelector):(n=document.createElement("a"),h.appendChild(n)),c(m,this.settings.classes.previousNav),c(n,this.settings.classes.nextNav),m.addEventListener("click",function(){return b(this._attributes.container,this.settings.classes.animating)?!1:(this.stop(),void this.previousSlide())}.bind(this)),n.addEventListener("click",function(){return b(this._attributes.container,this.settings.classes.animating)?!1:(this.stop(),void this.nextSlide())}.bind(this)),("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&(this.settings.effect="slide",m.style.display="none",n.style.display="none",c(h,this.settings.classes.touchEnabled),h.addEventListener("touchstart",j.start.bind(this),!1),h.addEventListener("touchmove",j.move.bind(this),!1),h.addEventListener("touchend",j.end.bind(this),!1)),this.settings.keyboardNav&&document.addEventListener("keyup",function(a){a=a||window.event;var c="number"==typeof a.which?a.which:a.keyCode;if(37==c){if(b(this._attributes.container,this.settings.classes.animating))return!1;this.stop(),this.previousSlide()}else if(39==c){if(b(this._attributes.container,this.settings.classes.animating))return!1;this.stop(),this.nextSlide()}}.bind(this))}this._attributes={container:h,slides:l,previousSlide:"undefined"!=typeof l[l.length-1]?l[l.length-1]:l[0],currentSlide:l[0],nextSlide:"undefined"!=typeof l[1]?l[1]:l[0],timerId:0,origChildren:i},this.settings.height&&(this._attributes.container.style.height=this.settings.height+"px"),c(h,this.settings.classes.container),c(h,"iis-effect-"+this.settings.effect),Array.prototype.forEach.call(this._attributes.slides,function(a){c(a,this.settings.classes.slide)}.bind(this)),c(this._attributes.previousSlide,this.settings.classes.previousSlide),c(this._attributes.currentSlide,this.settings.classes.currentSlide),c(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),f(this._attributes.currentSlide,function(){this.settings.onInit.apply(this)}.bind(this)),f(this._attributes.previousSlide),f(this._attributes.nextSlide)};return k.prototype.get=function(a){return this._attributes?this._attributes.hasOwnProperty(a)?this._attributes[a]:void 0:null},k.prototype.set=function(a,b){return this._attributes?this._attributes[a]=b:null},k.prototype.start=function(){this._attributes&&(this._attributes.timerId=setInterval(this.nextSlide.bind(this),this.settings.interval),this.settings.onStart.apply(this),window.onblur=function(){this.stop()}.bind(this))},k.prototype.stop=function(){this._attributes&&(clearInterval(this._attributes.timerId),this._attributes.timerId=0,this.settings.onStop.apply(this))},k.prototype.previousSlide=function(){this.settings.beforeChange.apply(this),d(this._attributes.previousSlide,this.settings.classes.previousSlide),d(this._attributes.currentSlide,this.settings.classes.currentSlide),d(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var a=this._attributes.slides,b=a.indexOf(this._attributes.currentSlide);this._attributes.nextSlide=this._attributes.currentSlide,this._attributes.previousSlide=a[b-2],this._attributes.currentSlide=a[b-1],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.previousSlide?(this._attributes.currentSlide=a[a.length-1],this._attributes.previousSlide=a[a.length-2]):"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=a[a.length-1]),f(this._attributes.previousSlide),c(this._attributes.previousSlide,this.settings.classes.previousSlide),c(this._attributes.currentSlide,this.settings.classes.currentSlide),c(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),c(this._attributes.container,this.settings.classes.directionPrevious),setTimeout(function(){d(this._attributes.container,this.settings.classes.directionPrevious)}.bind(this),this.settings.transitionDuration),this.settings.transitionDuration&&(c(this._attributes.container,this.settings.classes.animating),setTimeout(function(){d(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),this.settings.afterChange.apply(this)},k.prototype.nextSlide=function(){this.settings.beforeChange.apply(this),d(this._attributes.previousSlide,this.settings.classes.previousSlide),d(this._attributes.currentSlide,this.settings.classes.currentSlide),d(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var a=this._attributes.slides,b=a.indexOf(this._attributes.currentSlide);this._attributes.previousSlide=this._attributes.currentSlide,this._attributes.currentSlide=a[b+1],this._attributes.nextSlide=a[b+2],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.nextSlide?(this._attributes.currentSlide=a[0],this._attributes.nextSlide=a[1]):"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=a[0]),f(this._attributes.nextSlide),c(this._attributes.previousSlide,this.settings.classes.previousSlide),c(this._attributes.currentSlide,this.settings.classes.currentSlide),c(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),c(this._attributes.container,this.settings.classes.directionNext),setTimeout(function(){d(this._attributes.container,this.settings.classes.directionNext)}.bind(this),this.settings.transitionDuration),this.settings.transitionDuration&&(c(this._attributes.container,this.settings.classes.animating),setTimeout(function(){d(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),this.settings.afterChange.apply(this)},k.prototype.gotoSlide=function(a){this.settings.beforeChange.apply(this),this.stop(),d(this._attributes.previousSlide,this.settings.classes.previousSlide),d(this._attributes.currentSlide,this.settings.classes.currentSlide),d(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true"),a--;var b=this._attributes.slides,e=b.indexOf(this._attributes.currentSlide);this._attributes.previousSlide=b[a-1],this._attributes.currentSlide=b[a],this._attributes.nextSlide=b[a+1],"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=b[b.length-1]),"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=b[0]),f(this._attributes.previousSlide),f(this._attributes.currentSlide),f(this._attributes.nextSlide),c(this._attributes.previousSlide,this.settings.classes.previousSlide),c(this._attributes.currentSlide,this.settings.classes.currentSlide),c(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),e>a?(c(this._attributes.container,this.settings.classes.directionPrevious),setTimeout(function(){d(this._attributes.container,this.settings.classes.directionPrevious)}.bind(this),this.settings.transitionDuration)):(c(this._attributes.container,this.settings.classes.directionNext),setTimeout(function(){d(this._attributes.container,this.settings.classes.directionNext)}.bind(this),this.settings.transitionDuration)),this.settings.transitionDuration&&(c(this._attributes.container,this.settings.classes.animating),setTimeout(function(){d(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),this.settings.afterChange.apply(this)},k.prototype.destroy=function(){clearInterval(this._attributes.timerId),this._attributes.timerId=0,this._attributes.container.innerHTML="",Array.prototype.forEach.call(this._attributes.origChildren,function(a){this._attributes.container.appendChild(a)}.bind(this)),d(this._attributes.container,this.settings.classes.container),d(this._attributes.container,"iis-effect-"+this.settings.effect),this._attributes.container.style.height="",this.settings.onDestroy.apply(this)},{_hasClass:b,_addClass:c,_removeClass:d,Slider:k}}(); \ No newline at end of file diff --git a/package.json b/package.json index 6274aad..61d5be2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ideal-image-slider", - "version": "1.2.1", + "version": "1.2.2", "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-jshint": "^0.10.0",