/*! * jaralax library * version: 0.2 public beta * http://jarallax.com/ * * Copyright 2012, Jacko Hoogeveen * Dual licensed under the MIT or GPL Version 3 licenses. * http://jarallax.com/license.html * * compressed by: http://jscompress.com * * Date: 2/27/2012 */ Jarallax=function(a){this.jarallaxObject=[];this.animations=[];this.defaultValues=[];this.progress=0;this.controllers=[];if(a===undefined){this.controllers.push(new ControllerScroll)}else{if(a.length){this.controllers=a}else if(typeof a==="object"){this.controllers.push(a)}else{throw new Error('wrong controller data type: "'+typeof a+'". Expected "object" or "array"')}}for(var b=0;b1){a=1}else if(a<0){a=0}else{this.progress=a}for(j=0;j=0){b=parseInt(this.startValues["progress"],10)/100}if(this.endValues["progress"].indexOf("%")>=0){c=parseInt(this.endValues["progress"],10)/100}if(progress>b&&progress=0){b=parseInt(this.startValues["progress"],10)/100}if(this.endValues["progress"].indexOf("%")>=0){c=parseInt(this.endValues["progress"],10)/100}if(this.startValues["event"]){this.dispatchEvent(this.progress,a,b,c)}if(a>=b&&a<=c){for(i in this.startValues){if(i!="progress"&&i!="style"&&i!="event"){if(undefined!=this.endValues[i]){var e=Jarallax.getUnits(this.startValues[i]+"");e=e.replace("-","");var f=parseFloat(this.startValues[i]);var g=parseFloat(this.endValues[i]);var h=c-b;var j=a-b;var k=g-f;var l=Jarallax.EASING[d["easing"]](j,f,k,h,d["easing"]["power"]);l+=e;$(this.selector).css(i,l)}else{$(this.selector).css(i,this.startValues[i])}}}}this.progress=a}};JarallaxAnimation.prototype.dispatchEvent=function(a,b,c,d){var e=this.startValues["event"];var f={};f.animation=this;f.selector=this.selector;if(b>=c&&b<=d){if(e.start&&ab){f.type="reverse";e.reverse(f)}}else{if(e.complete&&ad){f.type="complete";e.complete(f)}if(e.rewinded&&a>c&&b=1){this.progress=1;this.forward=false}else if(this.progress<=0){this.progress=0;this.forward=true}if(this.forward){this.progress+=this.speed}else{this.progress-=this.speed}};ControllerTime.prototype.activate=function(a){this.jarallax=a;this.progress=0;this.interval=$.interval(this.onInterval.bind(this),this.interval)};ControllerTime.prototype.deactivate=function(a){};ControllerTime.prototype.update=function(a){};ControllerDrag=function(a,b,c){this.object=$(a);this.start=b;this.end=c;this.container="";this.width;this.startX=0;this.startY=0};ControllerDrag.prototype.activate=function(a){this.jarallax=a;this.container="#scrollbar";this.object.draggable({containment:this.container,axis:"x"});this.object.bind("drag",{me:this},this.onDrag);this.container=$(this.container);this.width=$(this.container).innerWidth()-this.object.outerWidth()};ControllerDrag.prototype.onDrag=function(a){var b=parseInt($(this).css("left"),10);var c=b/a.data.me.width;a.data.me.jarallax.setProgress(c)};ControllerDrag.prototype.deactivate=function(a){};ControllerDrag.prototype.update=function(a){this.object.css("left",a*this.width)};ControllerKeyboard=function(a,b,c){this.repetitiveInput=c;this.preventDefault=b||false;this.keys=a||{38:-.01,40:.01};this.keysState=new Object};ControllerKeyboard.prototype.activate=function(a){this.jarallax=a;$(document.documentElement).keydown({me:this},this.keyDown);$(document.documentElement).keyup({me:this},this.keyUp);for(key in this.keys){this.keysState[key]=false}};ControllerKeyboard.prototype.deactivate=function(a){};ControllerKeyboard.prototype.keyDown=function(a){var b=a.data.me;for(key in b.keys){if(key==a.keyCode){if(b.keysState[key]!==true||b.repetitiveInput){b.jarallax.setProgress(b.jarallax.progress+b.keys[key])}b.keysState[key]=true;if(b.preventDefault){a.preventDefault()}}}};ControllerKeyboard.prototype.keyUp=function(a){var b=a.data.me;for(key in b.keys){if(key==a.keyCode){b.keysState[key]=false}}};ControllerKeyboard.prototype.update=function(a){};ControllerMousewheel=function(a,b){this.sensitivity=-a;this.preventDefault=b||false};ControllerMousewheel.prototype.activate=function(a){this.jarallax=a;$("body").bind("mousewheel",{me:this},this.onScroll)};ControllerMousewheel.prototype.deactivate=function(a){this.jarallax=a};ControllerMousewheel.prototype.onScroll=function(a,b){controller=a.data.me;controller.jarallax.setProgress(controller.jarallax.progress+controller.sensitivity*b);if(controller.preventDefault){a.preventDefault()}};ControllerMousewheel.prototype.update=function(a){};ControllerIpadScroll=function(){this.x=0;this.previousX=-1;this.top=700;this.moveRight=false};ControllerIpadScroll.prototype.activate=function(a,b){this.jarallax=a;this.values=b;$("body").bind("touchmove",{me:this},this.onScroll)};ControllerIpadScroll.prototype.onScroll=function(a){a.preventDefault();var b=a.data.me;var c=a.originalEvent.touches.item(0);if(b.previousX==-1){b.previousX=c.clientX}else{if(c.clientX-b.previousX<100&&c.clientX-b.previousX>-100){if(b.moveRight){b.x-=c.clientX-b.previousX}else{b.x+=c.clientX-b.previousX}b.x=b.x<1e3?b.x:1e3;b.x=b.x>0?b.x:0}b.previousX=c.clientX;b.jarallax.setProgress(b.x/b.top)}};ControllerIpadScroll.prototype.deactivate=function(a){};ControllerIpadScroll.prototype.update=function(a){}