GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — uzerapp.github.io/js/animateSlider.js at master · uzerapp/uzerapp.github.io Expand file tree/ Copy pathanimateSlider.jsMore file actions 304 lines (261 loc) · 11.7 KB / Copy pathanimateSlider.jsFile metadata and controls304 lines (261 loc) · 11.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 // 1. load bars stacked beside eachother. // 2. only one full-width load bar appears each slide. // 3. no load bars just dots. // 4. video background. // 5. one back ground. "use strict"; /* Plugin: jQuery AnimateSlider Version 1.0.0 Author: John John */ (function($) { $.fn.animateSlider = function(slideDur) { this.each(function() { var $container = $(this); //Json Object for container $container[0].faderConfig = {}; //Private vars var slideSelector = ".slide", //Slide selector slideTimer, //Timeout activeSlide, //Index of active slide newSlide, //Index of next or prev slide $slides = $container.find(slideSelector), //All slides totalSlides = $slides.length, //Nb of slides config = $container[0].faderConfig; //Configuration // change background function function changeBG() { if ($container.attr("data-background-1")) { $(".as-background").each(function() { var indexOfSlide = $(this).data("slide-num"); if (newSlide == (indexOfSlide)) { $(this).css("opacity", 1).addClass("active-as-background"); } else { $(this).css("opacity", 0).removeClass("active-as-background"); } }); } } config = { slideDur: slideDur }; // make active dots function function activDot() { $(".as-indicator").each(function() { var indexOfSlide = $(this).data("slide-number"); if (newSlide == indexOfSlide) { $(this).addClass("active"); } else { $(this).removeClass("active"); } }); } function progress(percent, $element) { if (!$container.hasClass("show-indicators")) { var progressBarPercent = percent * $element.width() / 100; $element.find("span").animate({ width: progressBarPercent }, slideDur); } } slideTimer = setTimeout(function() { changeSlides("next"); }, config.slideDur); /** * Function to change slide * @param {type} target, next ou prev * @returns {undefined} */ function changeSlides(target) { //If want to forward if (target === "next") { //index of next slide newSlide = activeSlide + 1; if (newSlide > totalSlides - 1) { newSlide = 0; $(".as-indicator .as-load-bar").stop().width(0); } } else if (target === "prev") { newSlide = activeSlide - 1; if (newSlide < 0) { newSlide = totalSlides - 1; } } else { newSlide = target; } $(".slide" + newSlide).find(".as-load-bar").width(0); $(".slide" + activeSlide).find(".as-load-bar").stop().width(0); if (newSlide < totalSlides) { $(".slide" + newSlide).prevAll().each(function(index, element) { $(element).find(".as-load-bar").stop().css("width", "100%"); }); } animateSlides(activeSlide, newSlide); // active the curret dot changeBG(); activDot(); } if (!$container.hasClass("single-loadbar")) { var fireEventProgressBar = false; //Change slide by clicking on progress bar $("body").delegate(".as-indicator", "click", function() { if (!fireEventProgressBar) { //To avoid spam clicks fireEventProgressBar = true; setTimeout(function() { fireEventProgressBar = false; }, 1000); $this = $(this); $this.find(".as-load-bar").stop().width(0); var indexOfSlide = $this.data("slide-number"); if (indexOfSlide > activeSlide) { $this.prevAll().each(function(index, element) { $(element).find(".as-load-bar").stop().css("width", "100%"); }); } else if (indexOfSlide < activeSlide) { $this.nextAll().each(function(index, element) { $(element).find(".as-load-bar").stop().width(0); }); } newSlide = indexOfSlide; changeBG(); // active the curret dot activDot(); clearTimeout(slideTimer); animateSlides(activeSlide, newSlide); } }); slideTimer; } var arrows = $container.find(".as-nav-arrows .as-arrow"); if (arrows.length) { var fireEventArrow = false; arrows.on("click", function() { if (!fireEventArrow) { fireEventArrow = true; setTimeout(function() { fireEventArrow = false; }, 1000); var target = $(this).data("target"); clearTimeout(slideTimer); changeSlides(target); } }); slideTimer; } /** * Animation of slides * @param {type} indexOfActiveSlide * @param {type} indexOfnewSlide * @returns {undefined} */ function animateSlides(indexOfActiveSlide, indexOfnewSlide) { $slides.eq(indexOfActiveSlide).css("z-index", 5); var childsOfSlide = $slides.eq(indexOfActiveSlide).children(); $(childsOfSlide).each(function(index, element) { if (typeof $(element).data("effect-in") !== "undefined" && typeof $(element).data("effect-out") !== "undefined") { $(element).removeClass($(element).data("effect-in") + " animated"); $(element).addClass($(element).data("effect-out") + " animated slide-out"); } else { $(element).children().each(function(index, child) { if (typeof $(child).data("effect-in") !== "undefined" && typeof $(child).data("effect-out") !== "undefined") { $(child).removeClass($(child).data("effect-in") + " animated"); $(child).addClass($(child).data("effect-out") + " animated slide-out"); } }); } }); $slides.eq(indexOfActiveSlide).delay(700).queue(function(next) { $(this).css("opacity", 0); activeSlide = indexOfnewSlide; $slides.eq(indexOfActiveSlide).removeAttr("style"); showSlide($slides.eq(indexOfnewSlide), indexOfnewSlide); waitForNext(); next(); }); } //Whait for next slide function waitForNext() { slideTimer = setTimeout(function() { changeSlides("next"); }, config.slideDur); } /** * Show slides * @param {type} $element * @returns {undefined} */ function showSlide($element, indexOfNewSlide) { //Animate progress bar progress(100, $(".slide" + indexOfNewSlide)); $element.children().each(function(index, element) { $(element).delay(200).queue(function(next) { if (typeof $(this).data("effect-out") !== "undefined") { $(this).removeClass($(this).data("effect-out") + " animated slide-out"); } else { $(this).children().each(function(index, child) { $(child).removeClass($(child).data("effect-out") + " animated slide-out"); }); } $element.css({ "z-index": 4, "opacity": 1 }); if (typeof $(this).data("effect-in") !== "undefined") { $(this).stop(true, true).addClass($(this).data("effect-in") + " animated"); } else { $(this).children().each(function(i, child) { $(child).stop(true, true).addClass($(child).data("effect-in") + " animated"); }); } next(); }); }); } // $container.find(".slide").mouseenter(function() { // clearTimeout(slideTimer); // }).mouseleave(function() { // setTimeout(function() { // //index of next slide // newSlide = activeSlide + 1; // if (newSlide > totalSlides - 1) { // newSlide = 0; // $(".as-indicator .as-load-bar").stop().width(0); // } // animateSlides(activeSlide, newSlide); // slideTimer; // changeBG(); // // active the curret dot // activDot(); // }, slideDur); // }); /*Build progress bar for slides*/ for (var i = 0; i < totalSlides; i++) { var htmlProgressBar = "<div class='as-indicator slide" + i + "' data-slide-number='" + i + "'><span class='as-load-bar'></span></div>"; $(".as-indicators").append(htmlProgressBar); } // var dotWidth = 100/totalSlides; if ($container.hasClass("alltogether-loadbars")) { $(".as-indicator").width((100 / totalSlides) - 4 + "%"); } if ($container.attr("data-background-1")) { for (var i = 0; i < totalSlides; i++) { var background = $container.attr("data-background-" + i), fakeBackground = "<div class='as-background' data-slide-num='" + i + "' style='background-image: url(" + background + ")'></div>"; $container.append(fakeBackground); } } // start progress the first slide //Opacity for first element $slides.eq(0).css({ "opacity": 1, "z-index": 4 }); activeSlide = 0; progress(100, $(".slide" + activeSlide)); newSlide = 0; changeBG(); activDot(); }); }; })(jQuery); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |