diff --git a/README.md b/README.md index ce636bb..678f6c9 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ bower install --save SimpleSlider ## Usage -> version: 0.6.2-rc +> version: 0.6.2 Just import the script on html and create a new slider instance. You always have to define width and height values to your container element. diff --git a/bower.json b/bower.json index 00bcd4c..3d5172e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "SimpleSlider", - "version": "0.6.2-rc", + "version": "0.6.2", "description": "A simple javascript slider without any dependencies", "homepage": "http://ruyadorno.github.io/SimpleSlider/", "authors": [ diff --git a/dist/simpleslider.min.js b/dist/simpleslider.min.js index 77e8355..d4b9730 100644 --- a/dist/simpleslider.min.js +++ b/dist/simpleslider.min.js @@ -1 +1 @@ -!function(context,definition){"use strict";"undefined"!=typeof module&&module.exports?module.exports=definition():"function"==typeof define&&define.amd?define(function(){return window.SimpleSlider=definition()}):context.SimpleSlider=definition()}(this,function(){"use strict";function getdef(val,def){return void 0===val||null===val||""===val?def:val}function getUnit(args,transitionProperty){for(var item,count=args.length,unit="";--count>=0;)item=args[count],"string"==typeof item&&(unit=item.replace(parseInt(item,10)+"",""));return"opacity"!==transitionProperty&&""===unit&&(unit="px"),unit}function testChildrenNum(value){if(0>=value){try{console.warn("A SimpleSlider main container elementshould have at least one child.")}catch(e){}return!0}return!1}function anim(target,prop,unit,transitionDuration,startTime,elapsedTime,fromValue,toValue,easeFunc,scope,cb){function loop(_cb){window.requestAnimationFrame(function(time){0===startTime&&(startTime=time),anim(target,prop,unit,transitionDuration,startTime,time,fromValue,toValue,easeFunc,scope,_cb)})}var newValue;if(startTime>0){if(newValue=easeFunc(elapsedTime-startTime,fromValue,toValue-fromValue,transitionDuration),!(transitionDuration>=elapsedTime-startTime))return target[prop]=toValue+unit,void(scope&&cb&&(cb.call(scope),cb=null));target[prop]=newValue+unit}loop(cb)}function startSlides(container,unit,startValue,visibleValue,transitionProperty){for(var imgs=[],i=container.children.length;--i>=0;)imgs[i]=container.children[i],imgs[i].style.position="absolute",imgs[i].style.top="0"+unit,imgs[i].style.left="0"+unit,imgs[i].style[transitionProperty]=startValue+unit,imgs[i].style.zIndex=0;return imgs[0].style[transitionProperty]=visibleValue+unit,imgs[0].style.zIndex=1,imgs}function manageRemovingSlideOrder(oldSlide,newSlide){return newSlide.style.zIndex=3,oldSlide&&(oldSlide.style.zIndex=1),newSlide}function manageInsertingSlideOrder(oldSlide,newSlide){return newSlide.style.zIndex=4,oldSlide&&(oldSlide.style.zIndex=2),newSlide}function parseStringToBoolean(value){return"false"===value?!1:value}function updateVisibility(slider){document[hidden]?slider.pauseAutoPlay():slider.resumeAutoPlay()}Date.now||(Date.now=function(){return(new Date).getTime()});for(var vendors=["webkit","moz"],i=0;i1},SimpleSlider.prototype.pauseAutoPlay=function(){this.isAutoPlayable()&&(this.remainingTime=this.delay-(Date.now()-this.intervalStartTime),window.clearTimeout(this.interval),this.interval=null)},SimpleSlider.prototype.resumeAutoPlay=function(){this.startInterval()},SimpleSlider.prototype.startAnim=function(target,fromValue,toValue,cb){anim(target.style,this.trProp,this.unit,1e3*this.trTime,0,0,fromValue,toValue,this.ease,this,cb)},SimpleSlider.prototype.endAnim=function(){(this.onChangeEnd||"[object Function]"==Object.prototype.toString.call(this.onChangeEnd))&&this.onChangeEnd(this.actualIndex,this.nextIndex())},SimpleSlider.prototype.remove=function(index){this.removed=manageRemovingSlideOrder(this.removed,this.imgs[index]),this.startAnim(this.imgs[index],this.visVal,this.endVal)},SimpleSlider.prototype.insert=function(index){this.inserted=manageInsertingSlideOrder(this.inserted,this.imgs[index]),this.startAnim(this.imgs[index],this.startVal,this.visVal,this.endAnim)},SimpleSlider.prototype.change=function(newIndex){var prevIndex=this.actualIndex;this.remove(this.actualIndex),this.insert(newIndex),this.actualIndex=newIndex,(this.onChange||"[object Function]"==Object.prototype.toString.call(this.onChange))&&this.onChange(prevIndex,this.actualIndex)},SimpleSlider.prototype.next=function(){this.change(this.nextIndex()),this.startInterval()},SimpleSlider.prototype.prev=function(){this.change(this.prevIndex()),this.startInterval()},SimpleSlider.prototype.nextIndex=function(){var newIndex=this.actualIndex+1;return newIndex>=this.imgs.length&&(newIndex=0),newIndex},SimpleSlider.prototype.prevIndex=function(){var newIndex=this.actualIndex-1;return 0>newIndex&&(newIndex=this.imgs.length-1),newIndex},SimpleSlider.prototype.dispose=function(){if(window.clearTimeout(this.interval),this.imgs){for(var i=this.imgs.length;--i>=0;)this.imgs.pop();this.imgs=null}this.containerElem=null,this.interval=null,this.trProp=null,this.trTime=null,this.delay=null,this.startVal=null,this.endVal=null,this.autoPlay=null,this.actualIndex=null,this.inserted=null,this.removed=null,this.remainingTime=null,this.onChange=null,this.onChangeEnd=null},SimpleSlider}); \ No newline at end of file +!function(context,definition){"use strict";"undefined"!=typeof module&&module.exports?module.exports=definition():"function"==typeof define&&define.amd?define(function(){return window.SimpleSlider=definition()}):context.SimpleSlider=definition()}(this,function(){"use strict";function getdef(val,def){return void 0===val||null===val||""===val?def:val}function getUnit(args,transitionProperty){for(var item,count=args.length,unit="";--count>=0;)item=args[count],"string"==typeof item&&(unit=item.replace(parseInt(item,10)+"",""));return"opacity"!==transitionProperty&&""===unit&&(unit="px"),unit}function testChildrenNum(value){if(value<=0){try{console.warn("A SimpleSlider main container elementshould have at least one child.")}catch(e){}return!0}return!1}function anim(target,prop,unit,transitionDuration,startTime,elapsedTime,fromValue,toValue,easeFunc,scope,cb){function loop(_cb){window.requestAnimationFrame(function(time){0===startTime&&(startTime=time),anim(target,prop,unit,transitionDuration,startTime,time,fromValue,toValue,easeFunc,scope,_cb)})}var newValue;if(startTime>0){if(newValue=easeFunc(elapsedTime-startTime,fromValue,toValue-fromValue,transitionDuration),!(elapsedTime-startTime<=transitionDuration))return target[prop]=toValue+unit,void(scope&&cb&&(cb.call(scope),cb=null));target[prop]=newValue+unit}loop(cb)}function startSlides(container,unit,startValue,visibleValue,transitionProperty){for(var imgs=[],i=container.children.length;--i>=0;)imgs[i]=container.children[i],imgs[i].style.position="absolute",imgs[i].style.top="0"+unit,imgs[i].style.left="0"+unit,imgs[i].style[transitionProperty]=startValue+unit,imgs[i].style.zIndex=0;return imgs[0].style[transitionProperty]=visibleValue+unit,imgs[0].style.zIndex=1,imgs}function manageRemovingSlideOrder(oldSlide,newSlide){return newSlide.style.zIndex=3,oldSlide&&(oldSlide.style.zIndex=1),newSlide}function manageInsertingSlideOrder(oldSlide,newSlide){return newSlide.style.zIndex=4,oldSlide&&(oldSlide.style.zIndex=2),newSlide}function parseStringToBoolean(value){return"false"!==value&&value}function updateVisibility(slider){document[hidden]?slider.pauseAutoPlay():slider.resumeAutoPlay()}Date.now||(Date.now=function(){return(new Date).getTime()});for(var vendors=["webkit","moz"],i=0;i1},SimpleSlider.prototype.pauseAutoPlay=function(){this.isAutoPlayable()&&(this.remainingTime=this.delay-(Date.now()-this.intervalStartTime),window.clearTimeout(this.interval),this.interval=null)},SimpleSlider.prototype.resumeAutoPlay=function(){this.startInterval()},SimpleSlider.prototype.startAnim=function(target,fromValue,toValue,cb){anim(target.style,this.trProp,this.unit,1e3*this.trTime,0,0,fromValue,toValue,this.ease,this,cb)},SimpleSlider.prototype.endAnim=function(){(this.onChangeEnd||"[object Function]"==Object.prototype.toString.call(this.onChangeEnd))&&this.onChangeEnd(this.actualIndex,this.nextIndex())},SimpleSlider.prototype.remove=function(index){this.removed=manageRemovingSlideOrder(this.removed,this.imgs[index]),this.startAnim(this.imgs[index],this.visVal,this.endVal)},SimpleSlider.prototype.insert=function(index){this.inserted=manageInsertingSlideOrder(this.inserted,this.imgs[index]),this.startAnim(this.imgs[index],this.startVal,this.visVal,this.endAnim)},SimpleSlider.prototype.change=function(newIndex){var prevIndex=this.actualIndex;this.remove(this.actualIndex),this.insert(newIndex),this.actualIndex=newIndex,(this.onChange||"[object Function]"==Object.prototype.toString.call(this.onChange))&&this.onChange(prevIndex,this.actualIndex)},SimpleSlider.prototype.next=function(){this.change(this.nextIndex()),this.startInterval()},SimpleSlider.prototype.prev=function(){this.change(this.prevIndex()),this.startInterval()},SimpleSlider.prototype.nextIndex=function(){var newIndex=this.actualIndex+1;return newIndex>=this.imgs.length&&(newIndex=0),newIndex},SimpleSlider.prototype.prevIndex=function(){var newIndex=this.actualIndex-1;return newIndex<0&&(newIndex=this.imgs.length-1),newIndex},SimpleSlider.prototype.dispose=function(){if(window.clearTimeout(this.interval),this.imgs){for(var i=this.imgs.length;--i>=0;)this.imgs.pop();this.imgs=null}this.containerElem=null,this.interval=null,this.trProp=null,this.trTime=null,this.delay=null,this.startVal=null,this.endVal=null,this.autoPlay=null,this.actualIndex=null,this.inserted=null,this.removed=null,this.remainingTime=null,this.onChange=null,this.onChangeEnd=null},SimpleSlider}); \ No newline at end of file diff --git a/package.json b/package.json index 80f3e56..de75f27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-slider", - "version": "0.6.2-rc", + "version": "0.6.2", "description": "A simple javascript slider without any dependencies", "scripts": { "test": "grunt jasmine:dev"