├── .gitattributes ├── ayaSlider.jquery.json ├── README.md ├── .gitignore └── src ├── ayaSlider-minified.js └── ayaSlider.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /ayaSlider.jquery.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ayaSlider", 3 | "title": "Flexible jQuery slider plugin", 4 | "description" : "with ayaSlider you can create a flexible slider with multiple parallax effects, there is no limits or predefined styles, you'll be able to slide any HTML element in and out with data tags", 5 | "keywords": [ 6 | "slider", 7 | "parallax", 8 | "animation" 9 | ], 10 | "demo": "http://mamod.me/ayaSlider", 11 | "version": "1.2.4", 12 | "author": { 13 | "name": "Mamod Mehyar", 14 | "url": "http://mamod.me/" 15 | }, 16 | "licenses": [ 17 | { 18 | "type": "MIT", 19 | "url": "https://github.com/mamod/ayaSlider/README.md" 20 | } 21 | ], 22 | "bugs": "https://github.com/mamod/ayaSlider/issues", 23 | "homepage": "http://mamod.me/ayaSlider", 24 | "docs": "http://mamod.me/ayaSlider", 25 | "dependencies": { 26 | "jquery": ">=1.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ayaSlider 2 | ========= 3 | 4 | Flexible jQuery slider plugin 5 | 6 | Features 7 | ======== 8 | 9 | - Embed Any HTML Element 10 | - Animate any/every element 11 | - Customize the way you like, no predefined style sheet! 12 | 13 | 14 | USAGE 15 | ===== 16 | 17 | See [ayaSlider Demo & Usage ](https://dl.dropboxusercontent.com/u/3241507/ayaslider/index.html "") 18 | 19 | 20 | HELP? 21 | ===== 22 | 23 | If you need any help or have any question just let me know 24 | 25 | [mamod.mehyar@gmail.com](mailto:mamod.mehyar@gmail.com "") 26 | 27 | 28 | LICENSE (MIT) 29 | ============= 30 | 31 | Copyright (c) 2012 Mamod Mehyar 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /src/ayaSlider-minified.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ayaSlider 3 | * MIT Licensed 4 | * @author Mamod Mehyar 5 | * http://twitter.com/mamod 6 | * http://mamod.me 7 | * version: 1.2.5 8 | */ 9 | (function(e){function l(){}e.fn.ayaSlider=function(g){var a=new l,b=e.extend({},e.fn.ayaSlider.defaultOptions,g);a.inout="in";a.items=void 0;a.currentSlide=void 0;a.parents=e(this);a.clearTimeOuts=function(){for(var c=0;c').css({opacity:b.timerOpacity,height:"100%",position:b.timerPosition,backgroundColor:b.timerColor}).appendTo(a.appendTimerTo),e(window).resize(function(){a.timer()}));a.move(f)};this.destroySlider=function(){a.items&&a.items.stop();a.clearTimeOuts();this.find(":first").replaceWith(a.firstElement); a.firstElement.show()};this.reloadSlider=function(c){b=e.extend({},b,c);this.destroySlider();a.ini(e(this))};return this.each(function(){a.ini(e(this))})};e.fn.ayaSlider.defaultOptions={delay:5E3,easeIn:"linear",easeOut:"linear",timerColor:"#000",timerPosition:"relative",timerOpacity:.5};e.fn.loopSiblings=function(g,a){var b=e(this);b.css("zIndex","2");g.previousSlide=b;var c;if("string"!==typeof a&&0<=parseInt(a))c=g.parents.find("._ayaSlider_slide:eq("+a+")");else if("previous"===a){c=b.prev("._ayaSlider_slide"); var h=c.length;0==c.length&&(c=b.nextAll("._ayaSlider_slide").eq(h-1))}else c=b.next("._ayaSlider_slide"),h=c.length,0==c.length&&(c=b.prevAll("._ayaSlider_slide").eq(h-1));c.css("zIndex","3");return c}})(jQuery); 10 | -------------------------------------------------------------------------------- /src/ayaSlider.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ayaSlider 3 | * MIT Licensed 4 | * @author Mamod Mehyar 5 | * http://twitter.com/mamod 6 | * http://mamod.me 7 | * version : 1.2.5 8 | */ 9 | 10 | (function($) { 11 | function _action(){} 12 | $.fn.ayaSlider = function(customOptions) { 13 | var action = new _action(); 14 | var options = $.extend({},$.fn.ayaSlider.defaultOptions, customOptions); 15 | action.inout = 'in'; 16 | action.items = undefined; 17 | action.currentSlide = undefined; 18 | action.parents = $(this); 19 | 20 | action.clearTimeOuts = function(){ 21 | for (var i = 0; i < action.timeOuts.length; i++){ 22 | clearTimeout(action.timeOuts[i]); 23 | } 24 | }; 25 | 26 | action.timer = function(delay){ 27 | var container = action.appendTimerTo; 28 | if (!(container && container.length)) return; 29 | 30 | action.appendTimerTo.find('._ayaSlider_timer').each(function(){ 31 | var $this = $(this); 32 | 33 | if (!delay) delay = 0; 34 | 35 | $this.stop().animate({ 36 | width : '100%', 37 | height : '100%' 38 | },{ 39 | duration : delay 40 | }); 41 | }); 42 | }; 43 | 44 | action.move = function(pack){ 45 | action.timeOuts = []; 46 | action.currentSlide = pack; 47 | if (!pack) return false; 48 | 49 | var items = pack.find('._ayaSlider_move').andSelf(); 50 | action.items = items; 51 | items.stop(); 52 | 53 | var length = items.length; 54 | pack.css({ 55 | display: 'block', 56 | opacity: 1 57 | }); 58 | 59 | if (action.appendTimerTo){ 60 | action.appendTimerTo.find('._ayaSlider_timer').stop().css({ 61 | width : 0 62 | }); 63 | } 64 | 65 | if (options.list){ 66 | var $index = pack.data('slideIndex'); 67 | var $list = $(options.list); 68 | $list.find('li').removeClass('current'); 69 | $list.find('li:eq('+$index+')').addClass('current'); 70 | } 71 | 72 | items.each(function(i){ 73 | var ele = $(this); 74 | var opt = ele.data("_options"); 75 | if (!opt) return true; 76 | 77 | var durationIn = parseFloat(opt.In.duration) || 1000+(i*300), 78 | delayIn = parseFloat(opt.In.delay) || 0, 79 | easeIn = opt.In.ease || options.easeIn || 'easeOutBack', 80 | easeOut = opt.Out.ease || options.easeOut || easeIn, 81 | durationOut = parseFloat(opt.Out.duration) || durationIn, 82 | delayOut = parseFloat(opt.Out.delay) || options.delay; 83 | 84 | var defaultIn = {}; 85 | 86 | if (typeof options.defaultIn === 'object'){ 87 | defaultIn = options.defaultIn; 88 | } 89 | 90 | if ( opt.In.top || opt.In.left || opt.In.opacity ){ 91 | defaultIn = { 92 | top: parseFloat(opt.In.top) || 0, 93 | left : parseFloat(opt.In.left) || 0 94 | }; 95 | 96 | if (opt.In.opacity){ 97 | defaultIn.opacity = parseFloat(opt.In.opacity); 98 | } 99 | } 100 | 101 | ele.css(defaultIn); 102 | var posType = ele.css('position'); 103 | if (posType == 'static'){ 104 | ele.css({ 105 | position : 'relative' 106 | }); 107 | } 108 | 109 | action.timeOuts.push(setTimeout(function(){ 110 | ele.stop().animate({ 111 | opacity : opt.opacity, 112 | left: opt.left+'px', 113 | top: opt.top+'px' 114 | },{ 115 | queue: false, 116 | duration: durationIn, 117 | complete: function(){ 118 | var css = {}; 119 | if (ele[0] !== pack[0]){ 120 | css = defaultIn; 121 | } 122 | 123 | if (opt.Out.top || opt.Out.left || opt.Out.opacity){ 124 | css = { 125 | top: parseFloat(opt.Out.top) || 0, 126 | left : parseFloat(opt.Out.left) || 0, 127 | opacity : parseFloat(opt.Out.opacity) || ele.css('opacity') || 1 128 | }; 129 | } 130 | //out animation 131 | if (ele[0] === pack[0]){ 132 | if (action.previousSlide){ 133 | action.previousSlide.hide(); 134 | } 135 | //play timer 136 | action.timer(delayOut); 137 | } 138 | 139 | if (opt.Out.opacity){ 140 | css.opacity = parseFloat(opt.Out.opacity); 141 | } 142 | 143 | if (delayOut > -1) { 144 | action.timeOuts.push(setTimeout(function(){ 145 | clearInterval(action.interval); 146 | var inter = setInterval(function(){ 147 | if (action.pause == true){ 148 | 149 | } else { 150 | clearInterval(inter); 151 | if (ele[0] === pack[0]){ 152 | action.move(pack.loopSiblings(action)); 153 | items.stop(); 154 | } 155 | 156 | ele.stop().animate(css,{ 157 | duration: durationOut, 158 | queue: false, 159 | complete: function(){}, 160 | easing : easeOut 161 | }); 162 | } 163 | },60); 164 | },delayOut)); 165 | } 166 | }, 167 | easing : easeIn 168 | }); 169 | },delayIn)); 170 | }); 171 | return false; 172 | }; 173 | 174 | action.add = function(text){ 175 | var data = {}; 176 | var options = text.split(';'); 177 | for (var x = 0; x < options.length; x++){ 178 | var values = options[x].split(':'); 179 | if (values && values.length == 2){ 180 | //if (key == 'opacity') continue; 181 | var key = values[0].replace(/\s+/,''); 182 | var value = values[1].replace(/\s+/,''); 183 | data[key] = value; 184 | } 185 | } 186 | return data; 187 | }; 188 | 189 | action.ini = function($this){ 190 | var next,previous; 191 | $this.mouseenter(function(){ 192 | action.pause = true; 193 | }).mouseleave(function(){ 194 | action.pause = false; 195 | }); 196 | 197 | //set required style 198 | $this.css({ 199 | 'position' : 'relative', 200 | 'overflow' : 'hidden' 201 | }); 202 | 203 | if (options.next) next = options.next; 204 | if (options.previous) previous = options.previous; 205 | 206 | $(previous).click(function(event){ 207 | event.stopPropagation(); 208 | //stop all previous animations 209 | if (action.items) action.items.stop(); 210 | action.clearTimeOuts(); 211 | action.currentSlide.fadeOut('slow'); 212 | action.move(action.currentSlide.loopSiblings(action,'previous')); 213 | return false; 214 | }); 215 | 216 | $(next).click(function(event){ 217 | event.stopPropagation(); 218 | //stop all previous animations 219 | if (action.items) action.items.stop(); 220 | action.clearTimeOuts(); 221 | action.currentSlide.fadeOut('fast'); 222 | action.move(action.currentSlide.loopSiblings(action)); 223 | return false; 224 | }); 225 | 226 | if (options.list){ 227 | var $list = $(options.list); 228 | $list.find('li').each(function(i){ 229 | var $li = $(this); 230 | $li.click(function(){ 231 | if ($li.hasClass('current')) return false; 232 | if (action.items) action.items.stop(); 233 | action.clearTimeOuts(); 234 | action.currentSlide.fadeOut('fast'); 235 | action.move(action.currentSlide.loopSiblings(action, i)); 236 | return false; 237 | }); 238 | }); 239 | } 240 | 241 | var _first, _height = $this.height(); 242 | $this.children().each(function(i){ 243 | var ele = $(this); 244 | ele.addClass('_ayaSlider_slide').data('slideIndex',i); 245 | ele.css({ 246 | position: 'absolute', 247 | overflow:'hidden', 248 | display: 'none', 249 | width : '100%', 250 | height : _height 251 | }); 252 | 253 | if (i == 0){ 254 | _first = ele; 255 | action.firstElement = _first.clone(); 256 | } 257 | }); 258 | 259 | $this.find('*').each(function(){ 260 | var ele = $(this); 261 | var data = { 262 | In : {}, 263 | Out : {} 264 | }; 265 | 266 | if(!ele.data("_in")){ 267 | var options = ele.data('in'); 268 | if (options) data.In = action.add(options); 269 | } 270 | 271 | if(!ele.data("_out")){ 272 | var options = ele.data('out'); 273 | if (options) data.Out = action.add(options); 274 | } 275 | 276 | data.left = 0; 277 | data.top = 0; 278 | //save opacity in data 279 | if (!ele.data('_opacity')) ele.data('_opacity',ele.css('opacity')); 280 | 281 | data.opacity = ele.data('_opacity'); 282 | ele.data("_options",data); 283 | ele.addClass('_ayaSlider_move'); 284 | }); 285 | 286 | if (options.timer){ 287 | //var appendTimerTo; 288 | if (options.timer == true){ 289 | action.appendTimerTo = $this; 290 | } else { 291 | action.appendTimerTo = $(options.timer); 292 | } 293 | 294 | $('
') 295 | .css({ 296 | opacity: options.timerOpacity, 297 | height: '100%', 298 | position : options.timerPosition, 299 | backgroundColor : options.timerColor 300 | }).appendTo(action.appendTimerTo); 301 | 302 | $(window).resize(function(){ 303 | action.timer(); 304 | }); 305 | } 306 | 307 | action.move(_first); 308 | }; 309 | 310 | this.destroySlider = function(){ 311 | if (action.items) action.items.stop(); 312 | action.clearTimeOuts(); 313 | var item = this.find(':first'); 314 | item.replaceWith(action.firstElement); 315 | action.firstElement.show(); 316 | }; 317 | 318 | this.reloadSlider = function(newoptions){ 319 | options = $.extend({},options, newoptions); 320 | this.destroySlider(); 321 | action.ini($(this)); 322 | }; 323 | 324 | return this.each(function() { 325 | action.ini($(this)); 326 | }); 327 | }; 328 | 329 | $.fn.ayaSlider.defaultOptions = { 330 | delay : 5000, 331 | easeIn : "linear", 332 | easeOut : "linear", 333 | timerColor : '#000', 334 | timerPosition : 'relative', 335 | timerOpacity : .5 336 | }; 337 | 338 | $.fn.loopSiblings = function(_action, type){ 339 | var $this = $(this); 340 | $this.css('zIndex','2'); 341 | _action.previousSlide = $this; 342 | var item; 343 | if (typeof type !== 'string' && parseInt(type) >= 0 ){ 344 | item = _action.parents.find('._ayaSlider_slide:eq('+type+')'); 345 | } else if (type === 'previous'){ 346 | item = $this.prev('._ayaSlider_slide'); 347 | var len = item.length; 348 | if (item.length == 0) { 349 | item = $this.nextAll('._ayaSlider_slide').eq(len-1); 350 | } 351 | } else { 352 | item = $this.next('._ayaSlider_slide'); 353 | var len = item.length; 354 | if (item.length == 0) { 355 | item = $this.prevAll('._ayaSlider_slide').eq(len-1); 356 | } 357 | } 358 | item.css('zIndex','3'); 359 | return item; 360 | }; 361 | })(jQuery); 362 | --------------------------------------------------------------------------------